Skip to content

Commit

Permalink
Display enabled state on top level button
Browse files Browse the repository at this point in the history
  • Loading branch information
flibber-hk committed Sep 22, 2022
1 parent 4c8011e commit 06ec899
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions SkillUpgrades/RM/MenuHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MenuHolder
internal VerticalItemPanel suVIP;
internal MenuElementFactory<RandoSettings> suMEF;

internal SmallButton JumpToDRPage;
internal SmallButton JumpToSUPage;

private static MenuHolder _instance = null;
internal static MenuHolder Instance => _instance ?? (_instance = new MenuHolder());
Expand All @@ -31,17 +31,32 @@ public static void Hook()

private bool HandleButton(MenuPage landingPage, out SmallButton button)
{
JumpToDRPage = new(landingPage, "SkillUpgrades");
JumpToDRPage.AddHideAndShowEvent(landingPage, MainPage);
button = JumpToDRPage;
JumpToSUPage = new(landingPage, "SkillUpgrades");
JumpToSUPage.AddHideAndShowEvent(landingPage, MainPage);
SetTopLevelButtonColor();

button = JumpToSUPage;
return true;
}

private void SetTopLevelButtonColor()
{
if (JumpToSUPage != null)
{
JumpToSUPage.Text.color = RandomizerInterop.RandoSettings.Any ? Colors.TRUE_COLOR : Colors.DEFAULT_COLOR;
}
}

private void ConstructMenu(MenuPage landingPage)
{
MainPage = new MenuPage("SkillUpgrades", landingPage);
suMEF = new(MainPage, RandomizerInterop.RandoSettings);
suVIP = new(MainPage, new(0, 300), 50f, true, suMEF.Elements);
foreach (IValueElement e in suMEF.Elements)
{
e.SelfChanged += obj => SetTopLevelButtonColor();
}

Localize(suMEF);
}
}
Expand Down

0 comments on commit 06ec899

Please sign in to comment.