diff --git a/Content.Client/AME/UI/AMEWindow.xaml.cs b/Content.Client/AME/UI/AMEWindow.xaml.cs index c55a18efcf..90c345faf7 100644 --- a/Content.Client/AME/UI/AMEWindow.xaml.cs +++ b/Content.Client/AME/UI/AMEWindow.xaml.cs @@ -1,3 +1,4 @@ +using Content.Client.UserInterface; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -35,7 +36,7 @@ namespace Content.Client.AME.UI // Disable all buttons if not powered if (Contents.Children != null) { - SetButtonDisabledRecursive(Contents, !castState.HasPower); + ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower); EjectButton.Disabled = false; } diff --git a/Content.Client/Chemistry/UI/ChemMasterWindow.cs b/Content.Client/Chemistry/UI/ChemMasterWindow.cs index 1bd7b63202..5f3a895e35 100644 --- a/Content.Client/Chemistry/UI/ChemMasterWindow.cs +++ b/Content.Client/Chemistry/UI/ChemMasterWindow.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using Content.Client.Stylesheets; +using Content.Client.UserInterface; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; using Robust.Client.Graphics; @@ -279,7 +280,7 @@ namespace Content.Client.Chemistry.UI UpdatePanelInfo(castState); if (Contents.Children != null) { - SetButtonDisabledRecursive(Contents, !castState.HasPower); + ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower); EjectButton.Disabled = !castState.HasBeaker; } } diff --git a/Content.Client/Chemistry/UI/ReagentDispenserWindow.cs b/Content.Client/Chemistry/UI/ReagentDispenserWindow.cs index 4dc65be1ad..34311fb74d 100644 --- a/Content.Client/Chemistry/UI/ReagentDispenserWindow.cs +++ b/Content.Client/Chemistry/UI/ReagentDispenserWindow.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Content.Client.Stylesheets; +using Content.Client.UserInterface; using Content.Shared.Chemistry.Dispenser; using Content.Shared.Chemistry.Reagent; using Robust.Client.Graphics; @@ -186,7 +187,7 @@ namespace Content.Client.Chemistry.UI // Disable all buttons if not powered if (Contents.Children != null) { - SetButtonDisabledRecursive(Contents, !castState.HasPower); + ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower); EjectButton.Disabled = false; } diff --git a/Content.Client/UserInterface/ButtonHelpers.cs b/Content.Client/UserInterface/ButtonHelpers.cs new file mode 100644 index 0000000000..38abc8684c --- /dev/null +++ b/Content.Client/UserInterface/ButtonHelpers.cs @@ -0,0 +1,31 @@ +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.UserInterface +{ + public static class ButtonHelpers + { + /// + /// This searches recursively through all the children of "parent" + /// and sets the Disabled value of any buttons found to "val" + /// + /// The control which childrens get searched + /// The value to which disabled gets set + public static void SetButtonDisabledRecursive(Control parent, bool val) + { + foreach (var child in parent.Children) + { + if (child is Button but) + { + but.Disabled = val; + continue; + } + + if (child.ChildCount > 0) + { + SetButtonDisabledRecursive(child, val); + } + } + } + } +}