Files
wwdpublic/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs
astriloqua f133ae7740 QoL for Ghost Role UI (#2284)
# Description

Ports over collapsible ghost role user interface, alongside making the
ghost roles button red only when count increases from last view.
Video under media.

---

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/user-attachments/assets/c23ca06d-a4ef-413d-be3a-6980b456e5f3

</p>
</details>

---

# Changelog

🆑
- tweak: Ported over ghost role UI QoL

---------

Co-authored-by: MilenVolf <63782763+MilenVolf@users.noreply.github.com>
Co-authored-by: Intoxicating-Innocence <188202277+Intoxicating-Innocence@users.noreply.github.com>
Co-authored-by: Dakota <72140289+1337Dakota@users.noreply.github.com>
Co-authored-by: Timfa <timfalken@hotmail.com>
2025-07-20 13:10:18 +10:00

79 lines
2.4 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;
using Content.Client._Goobstation.UserInterface.Systems.Ghost.Controls;
namespace Content.Client.UserInterface.Systems.Ghost.Widgets;
[GenerateTypedNameReferences]
public sealed partial class GhostGui : UIWidget
{
public GhostTargetWindow TargetWindow { get; }
public GhostBarRulesWindow GhostBarWindow { get; }
public event Action? RequestWarpsPressed;
public event Action? ReturnToBodyPressed;
public event Action? GhostRolesPressed;
public event Action? GhostBarPressed; // Goobstation - Ghost Bar
public event Action? ReturnToRoundPressed;
private int _prevNumberRoles;
public GhostGui()
{
RobustXamlLoader.Load(this);
TargetWindow = new GhostTargetWindow();
GhostBarWindow = new GhostBarRulesWindow();
MouseFilter = MouseFilterMode.Ignore;
GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesButton.StyleClasses.Remove(StyleBase.ButtonDanger);
GhostBarButton.OnPressed += _ => GhostBarPressed?.Invoke(); // Goobstation - Ghost Bar
ReturnToRound.OnPressed += _ => ReturnToRoundPressed?.Invoke();
}
public void Hide()
{
TargetWindow.Close();
GhostBarWindow.Close(); // Goobstation - Ghost Bar
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.ButtonDanger);
}
_prevNumberRoles = (int)roles;
}
TargetWindow.Populate();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
TargetWindow.Dispose();
GhostBarWindow.Dispose(); // Goobstation - Ghost Bar
}
}
}