Files
tbd-station-14/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs
Dakota a8a73a611e 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
2025-03-21 11:15:39 +11:00

68 lines
1.8 KiB
C#

using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Ghost.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Systems.Ghost.Widgets;
[GenerateTypedNameReferences]
public sealed partial class GhostGui : UIWidget
{
public GhostTargetWindow TargetWindow { get; }
public event Action? RequestWarpsPressed;
public event Action? ReturnToBodyPressed;
public event Action? GhostRolesPressed;
private int _prevNumberRoles;
public GhostGui()
{
RobustXamlLoader.Load(this);
TargetWindow = new GhostTargetWindow();
MouseFilter = MouseFilterMode.Ignore;
GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesButton.StyleClasses.Remove(StyleBase.ButtonCaution);
}
public void Hide()
{
TargetWindow.Close();
Visible = false;
}
public void Update(int? roles, bool? canReturnToBody)
{
ReturnToBodyButton.Disabled = !canReturnToBody ?? true;
if (roles != null)
{
GhostRolesButton.Text = Loc.GetString("ghost-gui-ghost-roles-button", ("count", roles));
if (roles > _prevNumberRoles)
{
GhostRolesButton.StyleClasses.Add(StyleBase.ButtonCaution);
}
_prevNumberRoles = (int)roles;
}
TargetWindow.Populate();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
TargetWindow.Dispose();
}
}
}