From: Dakota <72140289+1337Dakota@users.noreply.github.com> Date: Fri, 21 Mar 2025 00:15:39 +0000 (+0100) Subject: feat: Ghost Role Button only turns red when new ghost roles are added (#35970) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a8a73a611e0cb458bd51864678e2cad00c064b27;p=space-station-14.git feat: Ghost Role Button only turns red when new ghost roles are added (#35970) * feat: Ghost Role Button only turns red when new ghost roles are added * fix: Make _prevNumberRoles private --- diff --git a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs index 0f64e8a275..db16895d59 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs @@ -14,6 +14,7 @@ public sealed partial class GhostGui : UIWidget public event Action? RequestWarpsPressed; public event Action? ReturnToBodyPressed; public event Action? GhostRolesPressed; + private int _prevNumberRoles; public GhostGui() { @@ -26,6 +27,7 @@ public sealed partial class GhostGui : UIWidget GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke(); ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke(); GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke(); + GhostRolesButton.OnPressed += _ => GhostRolesButton.StyleClasses.Remove(StyleBase.ButtonCaution); } public void Hide() @@ -41,14 +43,13 @@ public sealed partial class GhostGui : UIWidget if (roles != null) { GhostRolesButton.Text = Loc.GetString("ghost-gui-ghost-roles-button", ("count", roles)); - if (roles > 0) + + if (roles > _prevNumberRoles) { GhostRolesButton.StyleClasses.Add(StyleBase.ButtonCaution); } - else - { - GhostRolesButton.StyleClasses.Remove(StyleBase.ButtonCaution); - } + + _prevNumberRoles = (int)roles; } TargetWindow.Populate();