| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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? ReturnToLobbyPressed;
- public event Action? GhostRolesPressed;
- public GhostGui()
- {
- RobustXamlLoader.Load(this);
- TargetWindow = new GhostTargetWindow();
- MouseFilter = MouseFilterMode.Ignore;
- GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
- ReturnToLobbyButton.OnPressed += _ => ReturnToLobbyPressed?.Invoke();
- ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
- GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
- }
- 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 > 0)
- {
- GhostRolesButton.StyleClasses.Add(StyleBase.ButtonCaution);
- }
- else
- {
- GhostRolesButton.StyleClasses.Remove(StyleBase.ButtonCaution);
- }
- }
- TargetWindow.Populate();
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- if (disposing)
- {
- TargetWindow.Dispose();
- }
- }
- }
|