Slight rework of menu side buttons

main
copygirl 6 months ago
parent fdd34928e8
commit d6696fa701
  1. 20
      ui/Menu.cs

@ -5,15 +5,12 @@ public partial class Menu : CenterContainer
public override void _Ready()
{
foreach (var child in SideButtons.GetChildren())
if ((child is BaseButton button) && button.ToggleMode)
button.Pressed += () => {
for (var i = 0; i < Tabs.GetTabCount(); i++)
if (Tabs.GetTabControl(i).Name == button.Name)
Tabs.CurrentTab = i;
// Make sure you can't "detoggle" the button.
button.Disabled = true;
};
foreach (var button in SideButtons.GetChildren().OfType<Button>())
button.Pressed += () => {
for (var i = 0; i < Tabs.GetTabCount(); i++)
if (Tabs.GetTabControl(i).Name == button.Name)
Tabs.CurrentTab = i;
};
}
public override void _Input(InputEvent @event)
@ -36,9 +33,8 @@ public partial class Menu : CenterContainer
public void OnTabChanged(int tabIndex)
{
var tabName = Tabs.GetTabControl(tabIndex).Name;
foreach (var child in SideButtons.GetChildren())
if ((child is BaseButton button) && button.ToggleMode)
button.Disabled = button.ButtonPressed = button.Name == tabName;
foreach (var button in SideButtons.GetChildren().OfType<Button>())
button.Disabled = button.Name == tabName;
}
public void OnReturnPressed()

Loading…
Cancel
Save