Minor UI refactor (#11212)

This commit is contained in:
wrexbe
2022-09-11 20:42:12 -07:00
committed by GitHub
parent 56c2ad6a16
commit 35b90736b7
63 changed files with 93 additions and 147 deletions

View File

@@ -0,0 +1,51 @@
using Content.Shared.Atmos.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.UserInterface.Systems.Atmos.GasTank
{
[UsedImplicitly]
public sealed class GasTankBoundUserInterface
: BoundUserInterface
{
public GasTankBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) :
base(owner, uiKey)
{
}
private GasTankWindow? _window;
public void SetOutputPressure(in float value)
{
SendMessage(new GasTankSetPressureMessage {Pressure = value});
}
public void ToggleInternals()
{
SendMessage(new GasTankToggleInternalsMessage());
}
protected override void Open()
{
base.Open();
_window = new GasTankWindow(this);
_window.OnClose += Close;
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is GasTankBoundUserInterfaceState cast)
_window?.UpdateState(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}
}

View File

@@ -0,0 +1,210 @@
using Content.Client.Message;
using Content.Client.Resources;
using Content.Client.Stylesheets;
using Content.Shared.Atmos.Components;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.UserInterface.Systems.Atmos.GasTank
{
public sealed class GasTankWindow
: BaseWindow
{
private GasTankBoundUserInterface _owner;
private readonly Label _lblName;
private readonly BoxContainer _topContainer;
private readonly Control _contentContainer;
private readonly IResourceCache _resourceCache = default!;
private readonly RichTextLabel _lblPressure;
private readonly FloatSpinBox _spbPressure;
private readonly RichTextLabel _lblInternals;
private readonly Button _btnInternals;
public GasTankWindow(GasTankBoundUserInterface owner)
{
TextureButton btnClose;
_resourceCache = IoCManager.Resolve<IResourceCache>();
_owner = owner;
var rootContainer = new LayoutContainer {Name = "GasTankRoot"};
AddChild(rootContainer);
MouseFilter = MouseFilterMode.Stop;
var panelTex = _resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
var back = new StyleBoxTexture
{
Texture = panelTex,
Modulate = Color.FromHex("#25252A"),
};
back.SetPatchMargin(StyleBox.Margin.All, 10);
var topPanel = new PanelContainer
{
PanelOverride = back,
MouseFilter = MouseFilterMode.Pass
};
var bottomWrap = new LayoutContainer
{
Name = "BottomWrap"
};
rootContainer.AddChild(topPanel);
rootContainer.AddChild(bottomWrap);
LayoutContainer.SetAnchorPreset(topPanel, LayoutContainer.LayoutPreset.Wide);
LayoutContainer.SetMarginBottom(topPanel, -85);
LayoutContainer.SetAnchorPreset(bottomWrap, LayoutContainer.LayoutPreset.VerticalCenterWide);
LayoutContainer.SetGrowHorizontal(bottomWrap, LayoutContainer.GrowDirection.Both);
var topContainerWrap = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
(_topContainer = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
}),
new Control {MinSize = (0, 110)}
}
};
rootContainer.AddChild(topContainerWrap);
LayoutContainer.SetAnchorPreset(topContainerWrap, LayoutContainer.LayoutPreset.Wide);
var font = _resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
var topRow = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Margin = new Thickness(4, 2, 12, 2),
Children =
{
(_lblName = new Label
{
Text = Loc.GetString("gas-tank-window-label"),
FontOverride = font,
FontColorOverride = StyleNano.NanoGold,
VerticalAlignment = VAlignment.Center,
HorizontalExpand = true,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0, 0, 20, 0),
}),
(btnClose = new TextureButton
{
StyleClasses = {DefaultWindow.StyleClassWindowCloseButton},
VerticalAlignment = VAlignment.Center
})
}
};
var middle = new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#202025")},
Children =
{
(_contentContainer = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Margin = new Thickness(8, 4),
})
}
};
_topContainer.AddChild(topRow);
_topContainer.AddChild(new PanelContainer
{
MinSize = (0, 2),
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#525252ff")}
});
_topContainer.AddChild(middle);
_topContainer.AddChild(new PanelContainer
{
MinSize = (0, 2),
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#525252ff")}
});
_lblPressure = new RichTextLabel();
_contentContainer.AddChild(_lblPressure);
//internals
_lblInternals = new RichTextLabel
{MinSize = (200, 0), VerticalAlignment = VAlignment.Center};
_btnInternals = new Button {Text = Loc.GetString("gas-tank-window-internals-toggle-button") };
_contentContainer.AddChild(
new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Margin = new Thickness(0, 7, 0, 0),
Children = {_lblInternals, _btnInternals}
});
// Separator
_contentContainer.AddChild(new Control
{
MinSize = new Vector2(0, 10)
});
_contentContainer.AddChild(new Label
{
Text = Loc.GetString("gas-tank-window-output-pressure-label"),
Align = Label.AlignMode.Center
});
_spbPressure = new FloatSpinBox
{
IsValid = f => f >= 0 || f <= 3000,
Margin = new Thickness(25, 0, 25, 7)
};
_contentContainer.AddChild(_spbPressure);
// Handlers
_spbPressure.OnValueChanged += args =>
{
_owner.SetOutputPressure(args.Value);
};
_btnInternals.OnPressed += args =>
{
_owner.ToggleInternals();
};
btnClose.OnPressed += _ => Close();
}
public void UpdateState(GasTankBoundUserInterfaceState state)
{
_lblPressure.SetMarkup(Loc.GetString("gas-tank-window-tank-pressure-text", ("tankPressure", $"{state.TankPressure:0.##}")));
_btnInternals.Disabled = !state.CanConnectInternals;
_lblInternals.SetMarkup(Loc.GetString("gas-tank-window-internal-text",
("colorName" ,state.InternalsConnected ? "green" : "red"),
("status", state.InternalsConnected ? "Connected" : "Disconnected")));
if (state.OutputPressure.HasValue)
{
_spbPressure.Value = state.OutputPressure.Value;
}
}
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
{
return DragMode.Move;
}
protected override bool HasPoint(Vector2 point)
{
return false;
}
}
}

View File

@@ -0,0 +1,15 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ghost-target-window-title'}"
MinSize="450 450"
SetSize="450 450">
<ScrollContainer VerticalExpand="True"
HorizontalExpand="True"
HScrollEnabled="False">
<BoxContainer Name="ButtonContainer"
Orientation="Vertical"
VerticalExpand="True"
SeparationOverride="5">
<!-- Target buttons get added here by code -->
</BoxContainer>
</ScrollContainer>
</DefaultWindow>

View File

@@ -0,0 +1,73 @@
using System.Linq;
using Content.Shared.Ghost;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Systems.Ghost.Controls
{
[GenerateTypedNameReferences]
public sealed partial class GhostTargetWindow : DefaultWindow
{
private readonly IEntityNetworkManager _netManager;
private List<(string, EntityUid)> _warps = new();
public GhostTargetWindow(IEntityNetworkManager netManager)
{
RobustXamlLoader.Load(this);
_netManager = netManager;
}
public void UpdateWarps(IEnumerable<GhostWarp> warps)
{
// Server COULD send these sorted but how about we just use the client to do it instead
_warps = warps
.OrderBy(w => w.IsWarpPoint)
.ThenBy(w => w.DisplayName, Comparer<string>.Create(
(x, y) => string.Compare(x, y, StringComparison.Ordinal)))
.Select(w =>
{
var name = w.IsWarpPoint
? Loc.GetString("ghost-target-window-current-button", ("name", w.DisplayName))
: w.DisplayName;
return (name, w.Entity);
})
.ToList();
}
public void Populate()
{
ButtonContainer.DisposeAllChildren();
AddButtons();
}
private void AddButtons()
{
foreach (var (name, warp) in _warps)
{
var currentButtonRef = new Button
{
Text = name,
TextAlign = Label.AlignMode.Right,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
MinSize = (340, 20),
ClipText = true,
};
currentButtonRef.OnPressed += _ =>
{
var msg = new GhostWarpToTargetRequestEvent(warp);
_netManager.SendSystemNetworkMessage(msg);
};
ButtonContainer.AddChild(currentButtonRef);
}
}
}
}

View File

@@ -0,0 +1,13 @@
<BoxContainer xmlns="https://spacestation14.io"
Orientation="Horizontal">
<Button Name="RequestButton"
Access="Public"
Text="{Loc 'ghost-roles-window-request-role-button'}"
StyleClasses="OpenRight"
HorizontalAlignment="Left"/>
<Button Name="FollowButton"
Access="Public"
Text="{Loc 'ghost-roles-window-follow-role-button'}"
StyleClasses="OpenLeft"
HorizontalAlignment="Right"/>
</BoxContainer>

View File

@@ -0,0 +1,9 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles;
[GenerateTypedNameReferences]
public sealed partial class GhostRoleEntryButtons : BoxContainer
{
}

View File

@@ -0,0 +1,13 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ghost-roles-window-title'}">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True">
<RichTextLabel Name="TopBanner" VerticalExpand="True"/>
<Button Name="RequestButton"
Text="{Loc 'ghost-roles-window-request-role-button'}"
Disabled="True"
TextAlign="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,52 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[GenerateTypedNameReferences]
public sealed partial class GhostRoleRulesWindow : DefaultWindow
{
[Dependency] private readonly IConfigurationManager _cfg = IoCManager.Resolve<IConfigurationManager>();
private float _timer;
public GhostRoleRulesWindow(string rules, Action<BaseButton.ButtonEventArgs> requestAction)
{
RobustXamlLoader.Load(this);
var ghostRoleTime = _cfg.GetCVar(CCVars.GhostRoleTime);
_timer = ghostRoleTime;
if (ghostRoleTime > 0f)
{
RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button-timer", ("time", $"{_timer:0.0}"));
TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer", ("time", ghostRoleTime))));
RequestButton.Disabled = true;
}
RequestButton.OnPressed += requestAction;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!RequestButton.Disabled) return;
if (_timer > 0.0)
{
_timer -= args.DeltaSeconds;
RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button-timer", ("time", $"{_timer:0.0}"));
}
else
{
RequestButton.Disabled = false;
RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button");
}
}
}
}

View File

@@ -0,0 +1,16 @@
<BoxContainer xmlns="https://spacestation14.io"
Orientation="Vertical"
HorizontalExpand="True"
Margin="0 0 8 8">
<Label Name="Title"
StyleClasses="LabelKeyText"/>
<PanelContainer StyleClasses="HighDivider" />
<RichTextLabel Name="Description"
Margin="0 4"/>
<BoxContainer Name="Buttons"
HorizontalAlignment="Left"
Orientation="Vertical"
SeparationOverride="5">
<!-- Buttons are added here by code -->
</BoxContainer>
</BoxContainer>

View File

@@ -0,0 +1,32 @@
using System;
using Content.Shared.Ghost.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[GenerateTypedNameReferences]
public sealed partial class GhostRolesEntry : BoxContainer
{
public event Action<GhostRoleInfo>? OnRoleSelected;
public event Action<GhostRoleInfo>? OnRoleFollow;
public GhostRolesEntry(string name, string description, IEnumerable<GhostRoleInfo> roles)
{
RobustXamlLoader.Load(this);
Title.Text = name;
Description.SetMessage(description);
foreach (var role in roles)
{
var button = new GhostRoleEntryButtons();
button.RequestButton.OnPressed += _ => OnRoleSelected?.Invoke(role);
button.FollowButton.OnPressed += _ => OnRoleFollow?.Invoke(role);
Buttons.AddChild(button);
}
}
}
}

View File

@@ -0,0 +1,84 @@
using System.Linq;
using Content.Client.Eui;
using Content.Shared.Eui;
using Content.Shared.Ghost.Roles;
using JetBrains.Annotations;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[UsedImplicitly]
public sealed class GhostRolesEui : BaseEui
{
private readonly GhostRolesWindow _window;
private GhostRoleRulesWindow? _windowRules = null;
private uint _windowRulesId = 0;
public GhostRolesEui()
{
_window = new GhostRolesWindow();
_window.OnRoleRequested += info =>
{
if (_windowRules != null)
_windowRules.Close();
_windowRules = new GhostRoleRulesWindow(info.Rules, _ =>
{
SendMessage(new GhostRoleTakeoverRequestMessage(info.Identifier));
});
_windowRulesId = info.Identifier;
_windowRules.OnClose += () =>
{
_windowRules = null;
};
_windowRules.OpenCentered();
};
_window.OnRoleFollow += info =>
{
SendMessage(new GhostRoleFollowRequestMessage(info.Identifier));
};
_window.OnClose += () =>
{
SendMessage(new GhostRoleWindowCloseMessage());
};
}
public override void Opened()
{
base.Opened();
_window.OpenCentered();
}
public override void Closed()
{
base.Closed();
_window.Close();
_windowRules?.Close();
}
public override void HandleState(EuiStateBase state)
{
base.HandleState(state);
if (state is not GhostRolesEuiState ghostState) return;
_window.ClearEntries();
var groupedRoles = ghostState.GhostRoles.GroupBy(
role => (role.Name, role.Description));
foreach (var group in groupedRoles)
{
var name = group.Key.Name;
var description = group.Key.Description;
_window.AddEntry(name, description, group);
}
var closeRulesWindow = ghostState.GhostRoles.All(role => role.Identifier != _windowRulesId);
if (closeRulesWindow)
{
_windowRules?.Close();
}
}
}
}

View File

@@ -0,0 +1,15 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ghost-roles-window-title'}"
MinSize="375 275">
<Label Name="NoRolesMessage"
Text="{Loc 'ghost-roles-window-no-roles-available-label'}"
VerticalAlignment="Top" />
<ScrollContainer VerticalExpand="True"
HScrollEnabled="False">
<BoxContainer Orientation="Vertical"
Name="EntryContainer"
VerticalExpand="True">
<!-- Ghost role entries are added here by code -->
</BoxContainer>
</ScrollContainer>
</DefaultWindow>

View File

@@ -0,0 +1,30 @@
using System;
using Content.Shared.Ghost.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[GenerateTypedNameReferences]
public sealed partial class GhostRolesWindow : DefaultWindow
{
public event Action<GhostRoleInfo>? OnRoleRequested;
public event Action<GhostRoleInfo>? OnRoleFollow;
public void ClearEntries()
{
NoRolesMessage.Visible = true;
EntryContainer.DisposeAllChildren();
}
public void AddEntry(string name, string description, IEnumerable<GhostRoleInfo> roles)
{
NoRolesMessage.Visible = false;
var entry = new GhostRolesEntry(name, description, roles);
entry.OnRoleSelected += OnRoleRequested;
entry.OnRoleFollow += OnRoleFollow;
EntryContainer.AddChild(entry);
}
}
}

View File

@@ -0,0 +1,78 @@
using Content.Client.Eui;
using Content.Shared.Eui;
using Content.Shared.Ghost.Roles;
using JetBrains.Annotations;
using Robust.Client.Console;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[UsedImplicitly]
public sealed class MakeGhostRoleEui : BaseEui
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
private readonly MakeGhostRoleWindow _window;
public MakeGhostRoleEui()
{
_window = new MakeGhostRoleWindow();
_window.OnClose += OnClose;
_window.OnMake += OnMake;
}
public override void HandleState(EuiStateBase state)
{
if (state is not MakeGhostRoleEuiState uiState)
{
return;
}
_window.SetEntity(uiState.EntityUid);
}
public override void Opened()
{
base.Opened();
_window.OpenCentered();
}
private void OnMake(EntityUid uid, string name, string description, string rules, bool makeSentient)
{
var player = _playerManager.LocalPlayer;
if (player == null)
{
return;
}
var makeGhostRoleCommand =
$"makeghostrole " +
$"\"{CommandParsing.Escape(uid.ToString())}\" " +
$"\"{CommandParsing.Escape(name)}\" " +
$"\"{CommandParsing.Escape(description)}\" " +
$"\"{CommandParsing.Escape(rules)}\"";
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);
if (makeSentient)
{
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(uid.ToString())}\"";
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
}
_window.Close();
}
private void OnClose()
{
base.Closed();
SendMessage(new MakeGhostRoleWindowClosedMessage());
}
}
}

View File

@@ -0,0 +1,30 @@
<DefaultWindow Title="{Loc Make Ghost Role}"
xmlns="https://spacestation14.io">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Name="RoleEntityLabel" Text="Entity" />
<Label Name="RoleEntity" Text="" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="RoleNameLabel" Text="Role Name" />
<LineEdit Name="RoleName" HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="RoleDescriptionLabel" Text="Role Description" />
<LineEdit Name="RoleDescription" HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="RoleRulesLabel" Text="Role Rules" />
<LineEdit Name="RoleRules" HorizontalExpand="True" Text="{Loc ghost-role-component-default-rules}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="MakeSentientLabel" Text="Make Sentient" />
<CheckBox Name="MakeSentientCheckbox" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Button Name="MakeButton" Text="Make" />
</BoxContainer>
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,52 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.GameObjects;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[GenerateTypedNameReferences]
public sealed partial class MakeGhostRoleWindow : DefaultWindow
{
public delegate void MakeRole(EntityUid uid, string name, string description, string rules, bool makeSentient);
public MakeGhostRoleWindow()
{
RobustXamlLoader.Load(this);
MakeSentientLabel.MinSize = (150, 0);
RoleEntityLabel.MinSize = (150, 0);
RoleNameLabel.MinSize = (150, 0);
RoleName.MinSize = (300, 0);
RoleDescriptionLabel.MinSize = (150, 0);
RoleDescription.MinSize = (300, 0);
RoleRulesLabel.MinSize = (150, 0);
RoleRules.MinSize = (300, 0);
MakeButton.OnPressed += OnPressed;
}
private EntityUid? EntityUid { get; set; }
public event MakeRole? OnMake;
public void SetEntity(EntityUid uid)
{
EntityUid = uid;
var entManager = IoCManager.Resolve<IEntityManager>();
RoleName.Text = entManager.GetComponent<MetaDataComponent>(uid).EntityName;
RoleEntity.Text = $"{uid}";
}
private void OnPressed(ButtonEventArgs args)
{
if (EntityUid == null)
{
return;
}
OnMake?.Invoke(EntityUid.Value, RoleName.Text, RoleDescription.Text, RoleRules.Text, MakeSentientCheckbox.Pressed);
}
}
}

View File

@@ -0,0 +1,84 @@
using Content.Client.Ghost;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Ghost.Controls;
using Content.Shared.Ghost;
using Robust.Client.Console;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.UserInterface.Systems.Ghost
{
public sealed class GhostGui : Control
{
private readonly Button _returnToBody = new() {Text = Loc.GetString("ghost-gui-return-to-body-button") };
private readonly Button _ghostWarp = new() {Text = Loc.GetString("ghost-gui-ghost-warp-button") };
private readonly Button _ghostRoles = new();
private readonly GhostComponent _owner;
private readonly GhostSystem _system;
public GhostTargetWindow? TargetWindow { get; }
public GhostGui(GhostComponent owner, GhostSystem system, IEntityNetworkManager eventBus)
{
IoCManager.InjectDependencies(this);
_owner = owner;
_system = system;
TargetWindow = new GhostTargetWindow(eventBus);
MouseFilter = MouseFilterMode.Ignore;
_ghostWarp.OnPressed += _ =>
{
eventBus.SendSystemNetworkMessage(new GhostWarpsRequestEvent());
TargetWindow.Populate();
TargetWindow.OpenCentered();
};
_returnToBody.OnPressed += _ =>
{
var msg = new GhostReturnToBodyRequest();
eventBus.SendSystemNetworkMessage(msg);
};
_ghostRoles.OnPressed += _ => IoCManager.Resolve<IClientConsoleHost>()
.RemoteExecuteCommand(null, "ghostroles");
AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Children =
{
_returnToBody,
_ghostWarp,
_ghostRoles,
}
});
}
public void Update()
{
_returnToBody.Disabled = !_owner.CanReturnToBody;
_ghostRoles.Text = Loc.GetString("ghost-gui-ghost-roles-button", ("count", _system.AvailableGhostRoleCount));
if (_system.AvailableGhostRoleCount != 0)
{
_ghostRoles.StyleClasses.Add(StyleBase.ButtonCaution);
}
else
{
_ghostRoles.StyleClasses.Remove(StyleBase.ButtonCaution);
}
TargetWindow?.Populate();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
TargetWindow?.Dispose();
}
}
}
}