ECS AME (#16779)
This commit is contained in:
55
Content.Client/Ame/UI/AmeControllerBoundUserInterface.cs
Normal file
55
Content.Client/Ame/UI/AmeControllerBoundUserInterface.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Content.Shared.Ame;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Ame.UI
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class AmeControllerBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private AmeWindow? _window;
|
||||
|
||||
public AmeControllerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new AmeWindow(this);
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the ui each time new state data is sent from the server.
|
||||
/// </summary>
|
||||
/// <param name="state">
|
||||
/// Data of the <see cref="SharedReagentDispenserComponent"/> that this ui represents.
|
||||
/// Sent from the server.
|
||||
/// </param>
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
var castState = (AmeControllerBoundUserInterfaceState) state;
|
||||
_window?.UpdateState(castState); //Update window state
|
||||
}
|
||||
|
||||
public void ButtonPressed(UiButton button)
|
||||
{
|
||||
SendMessage(new UiButtonPressedMessage(button));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
Content.Client/Ame/UI/AmeWindow.xaml
Normal file
46
Content.Client/Ame/UI/AmeWindow.xaml
Normal file
@@ -0,0 +1,46 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
Title="{Loc 'ame-window-title'}"
|
||||
MinSize="250 250">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'ame-window-engine-status-label'}" />
|
||||
<Label Text=" " />
|
||||
<Label Name="InjectionStatus" Text="{Loc 'ame-window-engine-injection-status-not-injecting-label'}" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="ToggleInjection"
|
||||
Text="{Loc 'ame-window-toggle-injection-button'}"
|
||||
StyleClasses="OpenBoth"
|
||||
Disabled="True" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'ame-window-fuel-status-label'}" />
|
||||
<Label Text=" " />
|
||||
<Label Name="FuelAmount" Text="{Loc 'ame-window-fuel-not-inserted-text'}" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="EjectButton"
|
||||
Text="{Loc 'ame-window-eject-button'}"
|
||||
StyleClasses="OpenBoth"
|
||||
Disabled="True" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'ame-window-injection-amount-label'}" />
|
||||
<Label Text=" " />
|
||||
<Label Name="InjectionAmount" Text="0" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="IncreaseFuelButton"
|
||||
Text="{Loc 'ame-window-increase-fuel-button'}"
|
||||
StyleClasses="OpenRight" />
|
||||
<Button Name="DecreaseFuelButton"
|
||||
Text="{Loc 'ame-window-decrease-fuel-button'}"
|
||||
StyleClasses="OpenLeft" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'ame-window-core-count-label'}" />
|
||||
<Label Text=" " />
|
||||
<Label Name="CoreCount" Text="0" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
69
Content.Client/Ame/UI/AmeWindow.xaml.cs
Normal file
69
Content.Client/Ame/UI/AmeWindow.xaml.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.Ame;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Ame.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class AmeWindow : DefaultWindow
|
||||
{
|
||||
public AmeWindow(AmeControllerBoundUserInterface ui)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
EjectButton.OnPressed += _ => ui.ButtonPressed(UiButton.Eject);
|
||||
ToggleInjection.OnPressed += _ => ui.ButtonPressed(UiButton.ToggleInjection);
|
||||
IncreaseFuelButton.OnPressed += _ => ui.ButtonPressed(UiButton.IncreaseFuel);
|
||||
DecreaseFuelButton.OnPressed += _ => ui.ButtonPressed(UiButton.DecreaseFuel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the UI state when new state data is received from the server.
|
||||
/// </summary>
|
||||
/// <param name="state">State data sent by the server.</param>
|
||||
public void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
var castState = (AmeControllerBoundUserInterfaceState) state;
|
||||
|
||||
// Disable all buttons if not powered
|
||||
if (Contents.Children != null)
|
||||
{
|
||||
ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower);
|
||||
EjectButton.Disabled = false;
|
||||
}
|
||||
|
||||
if (!castState.HasFuelJar)
|
||||
{
|
||||
EjectButton.Disabled = true;
|
||||
ToggleInjection.Disabled = true;
|
||||
FuelAmount.Text = Loc.GetString("ame-window-fuel-not-inserted-text");
|
||||
}
|
||||
else
|
||||
{
|
||||
EjectButton.Disabled = false;
|
||||
ToggleInjection.Disabled = false;
|
||||
FuelAmount.Text = $"{castState.FuelAmount}";
|
||||
}
|
||||
|
||||
if (!castState.IsMaster)
|
||||
{
|
||||
ToggleInjection.Disabled = true;
|
||||
}
|
||||
|
||||
if (!castState.Injecting)
|
||||
{
|
||||
InjectionStatus.Text = Loc.GetString("ame-window-engine-injection-status-not-injecting-label") + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
InjectionStatus.Text = Loc.GetString("ame-window-engine-injection-status-injecting-label") + " ";
|
||||
}
|
||||
|
||||
CoreCount.Text = $"{castState.CoreCount}";
|
||||
InjectionAmount.Text = $"{castState.InjectionAmount}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user