Slight rework of menu side buttons

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

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

Loading…
Cancel
Save