Skip to content

Commit

Permalink
Remove KKS accessory window scrolling code for compat with new moreaccs
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 5, 2021
1 parent 488392d commit 5c8f978
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/Shared.KKalike/Maker/MakerInterfaceCreator.KK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,15 @@ private static void CreateCustomAccessoryWindowControls()
var tglSlot01GameObject = customAcsChangeSlot.transform.FindLoop("tglSlot01");
if (tglSlot01GameObject == null) throw new ArgumentNullException(nameof(tglSlot01GameObject));
var container = tglSlot01GameObject.transform.parent;
#if KK || KKS
#if KK
//Set source early rather than search every time
var original_scroll = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/03_ClothesTop/tglTop/TopTop/Scroll View").transform.GetComponent<ScrollRect>();
#if KKS
var content_image = original_scroll.content.GetComponent<Image>();
#endif
var scroll_bar_area_sprite = original_scroll.verticalScrollbar.GetComponent<Image>().sprite;
var scroll_bar_handle_sprite = original_scroll.verticalScrollbar.image.sprite;

#if KK
var root = container.parent.parent.parent;
root.Find("tglCopy").GetComponent<LayoutElement>().minWidth = 200f;
root.Find("tglChange").GetComponent<LayoutElement>().minWidth = 200f;
#endif
foreach (var slotTransform in container.Cast<Transform>())
{
var layout = slotTransform.GetComponent<LayoutElement>();
Expand All @@ -307,11 +302,8 @@ private static void CreateCustomAccessoryWindowControls()
}
}
CreateCustomControlsInSubCategory(slotTransform, _accessoryWindowEntries, true);
#if KK || KKS
#if KK
var listParent = slotTransform.Cast<Transform>().Where(x => x.name.EndsWith("Top")).First();
#if KKS
GameObject.DestroyImmediate(listParent.GetComponent<Image>());//Destroy image that contains scrollbar
#endif
var elements = new List<Transform>();
foreach (Transform t in listParent)
elements.Add(t);
Expand All @@ -333,24 +325,13 @@ private static void CreateCustomAccessoryWindowControls()
scroll.verticalScrollbar.image.sprite = scroll_bar_handle_sprite;
scroll.verticalScrollbar.GetComponent<Image>().sprite = scroll_bar_area_sprite;

#if KKS
//Add image that doesn't contain scroll bar
var image = scroll.content.gameObject.AddComponent<Image>();
image.sprite = content_image.sprite;
image.type = content_image.type;
#endif
Object.DestroyImmediate(scroll.horizontalScrollbar.gameObject);
var content = scroll.content.transform;
Object.Destroy(scroll.GetComponent<Image>());

var s_LE = scroll.gameObject.AddComponent<LayoutElement>();
#if KK
var height = (GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/04_AccessoryTop/Slots").transform as RectTransform).rect.height;
var width = 400f;
#else
var height = 875f; //Slots from KK doesn't exist
var width = 400f;
#endif
s_LE.preferredHeight = height;
s_LE.preferredWidth = width;

Expand All @@ -373,12 +354,14 @@ private static void CreateCustomAccessoryWindowControls()
internal static void OnMakerAccSlotAdded(Transform newSlotTransform)
{
// Necessary because MoreAccessories copies existing slot, so controls get copied but with no events hooked up
#if KK || KKS
#if KK || KKS // not sure if necessary? is this useful in EC as well?
//KeelsChildNeglect(newSlotTransform, 0); //used to print children paths in case it's needed in the future, like horizontal support or something
if (!MakerAPI.InsideAndLoaded)
{
return;//Maker slots are added before CreateCustomAccessoryWindowControls is called. don't create controls yet
}
#endif
#if KK
//find Content where controls are placed, additional Slots are copies of first slot as such they are currently named downstream Slot01
newSlotTransform = newSlotTransform.Find("Slot01Top/tglSlot01ScrollView/Viewport/Content");
#endif
Expand Down

0 comments on commit 5c8f978

Please sign in to comment.