Cloning Rework (#8972)

Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
Rane
2022-08-04 00:05:17 -04:00
committed by GitHub
parent 37f9e825ea
commit 2f4849eae1
41 changed files with 928 additions and 1227 deletions

View File

@@ -0,0 +1,51 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Content.Shared.Cloning.CloningConsole;
namespace Content.Client.CloningConsole.UI
{
[UsedImplicitly]
public sealed class CloningConsoleBoundUserInterface : BoundUserInterface
{
private CloningConsoleWindow? _window;
public CloningConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new CloningConsoleWindow
{
Title = Loc.GetString("cloning-console-window-title")
};
_window.OnClose += Close;
_window.CloneButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.Clone));
_window.EjectButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.Eject));
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_window?.Populate((CloningConsoleBoundUserInterfaceState) state);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
if (_window != null)
{
_window.OnClose -= Close;
_window.CloneButton.OnPressed -= _ => SendMessage(new UiButtonPressedMessage(UiButton.Clone));
_window.EjectButton.OnPressed -= _ => SendMessage(new UiButtonPressedMessage(UiButton.Eject));
}
_window?.Dispose();
}
}
}

View File

@@ -0,0 +1,65 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'comp-pda-ui-menu-title'}"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
SetSize="400 400"
MinSize="400 400">
<TabContainer Name="MasterTabContainer">
<BoxContainer Name="Scanner"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
MinSize="100 150">
<PanelContainer VerticalExpand="True" StyleClasses="Inset">
<BoxContainer Name="GeneticScannerContents" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" Text="{Loc 'cloning-console-window-scanner-details-label'}" />
<BoxContainer Orientation="Horizontal" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ScannerInfoLabel"
Access="Public"
HorizontalExpand="True" />
<Button Name="CloneButton"
Access="Public"
Text="{Loc 'cloning-console-window-clone-button-text'}"
HorizontalAlignment="Right"
VerticalAlignment="Center" />
</BoxContainer>
<Label Name="CloningActivity"
Text="{Loc 'cloning-console-component-msg-empty'}"
Access="Public"
HorizontalAlignment="Center"
HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="GeneticScannerMissing" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-no-scanner-detected-label'}" />
</BoxContainer>
<BoxContainer Name="GeneticScannerFar" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-scanner-far-label'}" />
</BoxContainer>
</PanelContainer>
<Control MinSize="50 5" />
<PanelContainer VerticalExpand="True" StyleClasses="Inset">
<BoxContainer Name="CloningPodContents" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" Text="{Loc 'cloning-console-window-pod-details-label'}" />
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ClonerInfoLabel"
Access="Public"
HorizontalExpand="True" />
<RichTextLabel Name="ClonerBrainActivity"
Access="Public"
HorizontalExpand="True"/>
<Button Name="EjectButton"
Access="Public"
Text="{Loc 'cloning-console-eject-body-button'}"
HorizontalAlignment="Right"
VerticalAlignment="Center" />
</BoxContainer>
</BoxContainer>
<BoxContainer Name="CloningPodMissing" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-no-clone-pod-detected-label'}" />
</BoxContainer>
<BoxContainer Name="CloningPodFar" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-clone-pod-far-label'}" />
</BoxContainer>
</PanelContainer>
</BoxContainer>
</TabContainer>
</DefaultWindow>

View File

@@ -0,0 +1,113 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Client.Message;
using Robust.Shared.Timing;
using Content.Shared.Cloning.CloningConsole;
namespace Content.Client.CloningConsole.UI
{
[GenerateTypedNameReferences]
public partial class CloningConsoleWindow : DefaultWindow
{
[Dependency] private readonly IGameTiming _timing = default!;
public CloningConsoleWindow()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
}
private CloningConsoleBoundUserInterfaceState? _lastUpdate;
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
}
public void Populate(CloningConsoleBoundUserInterfaceState state)
{
_lastUpdate = state;
// BUILD SCANNER UI
if (state.ScannerConnected)
{
if (!state.ScannerInRange)
{
GeneticScannerFar.Visible = true;
GeneticScannerContents.Visible = false;
GeneticScannerMissing.Visible = false;
return;
}
GeneticScannerContents.Visible = true;
GeneticScannerFar.Visible = false;
GeneticScannerMissing.Visible = false;
CloneButton.Disabled = state.CloningStatus != ClonerStatus.Ready;
switch (state.CloningStatus)
{
case ClonerStatus.NoClonerDetected:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-no-cloner"));
break;
case ClonerStatus.Ready:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-ready"));
break;
case ClonerStatus.ClonerOccupied:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-occupied"));
break;
case ClonerStatus.ScannerEmpty:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-empty"));
break;
case ClonerStatus.ScannerOccupantAlive:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-scanner-occupant-alive"));
break;
case ClonerStatus.OccupantMetaphyiscal:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-already-alive"));
break;
case ClonerStatus.NoMindDetected:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-no-mind"));
break;
}
// Set label depending on if scanner is occupied or not.
ScannerInfoLabel.SetMarkup(state.ScannerBodyInfo != null ?
Loc.GetString("cloning-console-window-scanner-id", ("scannerOccupantName", state.ScannerBodyInfo)) :
Loc.GetString("cloning-console-window-id-blank"));
}
else
{
// Scanner is missing, set error message visible
GeneticScannerContents.Visible = false;
GeneticScannerFar.Visible = false;
GeneticScannerMissing.Visible = true;
}
// BUILD ClONER UI
if (state.ClonerConnected)
{
if (!state.ClonerInRange)
{
CloningPodFar.Visible = true;
CloningPodContents.Visible = false;
CloningPodMissing.Visible = false;
return;
}
CloningPodContents.Visible = true;
CloningPodFar.Visible = false;
CloningPodMissing.Visible = false;
ClonerBrainActivity.SetMarkup(Loc.GetString(state.MindPresent ? "cloning-console-mind-present-text" : "cloning-console-no-mind-activity-text"));
// Set label depending if clonepod is occupied or not
ClonerInfoLabel.SetMarkup(state.ClonerBodyInfo != null ?
Loc.GetString("cloning-console-window-pod-id", ("podOccupantName", state.ClonerBodyInfo)) :
Loc.GetString("cloning-console-window-id-blank"));
}
else
{
// Clone pod is missing, set error message visible
CloningPodContents.Visible = false;
CloningPodFar.Visible = false;
CloningPodMissing.Visible = true;
}
}
}
}