Skip to content

Commit

Permalink
Fix breaking window close buttons in KKS maker
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jun 10, 2021
1 parent d25a8e5 commit a8fa165
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Core_Fix_MakerOptimizations/Core.MakerOptimizations.Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ private static IEnumerator OnMakerLoaded()
* Changing tab parent out of canvas is same as setactive, canvas needs to recalculate everything
*/

#if KK
var kkKiyaseExists = GameObject.Find("KK_Kiyase") != null;
#endif
var treeTop = GameObject.Find("CvsMenuTree");

foreach (Transform mainTab in treeTop.transform)
Expand All @@ -94,14 +96,28 @@ private static IEnumerator OnMakerLoaded()

var innerContent = subTab.Cast<Transform>().FirstOrDefault(x =>
{
#if KK
// Needed for KK_Kiyase to not crash, it uses slides under this tab
if (kkKiyaseExists && x.GetComponent<CvsBreast>() != null) return false;
#endif
// Tab pages have raycast controllers on them, buttons have only image
return x.GetComponent<UI_RaycastCtrl>() != null;
})?.gameObject;
if (innerContent == null) continue;

#if KKS
// Needed in KKS because the close action is set in a coroutine which doesn't finish because we disable the gameobject
foreach (var window in innerContent.GetComponentsInChildren<CustomSelectWindow>())
{
window.btnClose.OnClickAsObservable().Subscribe(_ =>
{
if (window.tglReference)
window.tglReference.isOn = false;
});
}
#endif

void SetTabActive(bool val) => innerContent.SetActive(val && (topMenuToggle == null || topMenuToggle.isOn));

toggle.onValueChanged.AddListener(SetTabActive);
Expand Down

0 comments on commit a8fa165

Please sign in to comment.