committed by
Pieter-Jan Briers
parent
415ac8fa46
commit
364279e0f7
@@ -0,0 +1,33 @@
|
||||
using Robust.Client.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using static Content.Shared.GameObjects.Components.Medical.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.MedicalScanner
|
||||
{
|
||||
public class MedicalScannerBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
public MedicalScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
private MedicalScannerWindow _window;
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new MedicalScannerWindow
|
||||
{
|
||||
Title = Owner.Owner.Name,
|
||||
Size = (485, 90),
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
_window.Populate((MedicalScannerBoundUserInterfaceState) state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using static Content.Shared.GameObjects.Components.Medical.SharedMedicalScannerComponent;
|
||||
using static Content.Shared.GameObjects.Components.Medical.SharedMedicalScannerComponent.MedicalScannerStatus;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.MedicalScanner
|
||||
{
|
||||
public class MedicalScannerVisualizer2D : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
if (!component.TryGetData(MedicalScannerVisuals.Status, out MedicalScannerStatus status)) return;
|
||||
sprite.LayerSetState(MedicalScannerVisualLayers.Machine, StatusToMachineStateId(status));
|
||||
sprite.LayerSetState(MedicalScannerVisualLayers.Terminal, StatusToTerminalStateId(status));
|
||||
}
|
||||
|
||||
private string StatusToMachineStateId(MedicalScannerStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Off: return "scanner_off";
|
||||
case Open: return "scanner_open";
|
||||
case Red: return "scanner_red";
|
||||
case Death: return "scanner_death";
|
||||
case Green: return "scanner_green";
|
||||
case Yellow: return "scanner_yellow";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
||||
}
|
||||
}
|
||||
|
||||
private string StatusToTerminalStateId(MedicalScannerStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Off: return "scanner_terminal_off";
|
||||
case Open: return "scanner_terminal_blue";
|
||||
case Red: return "scanner_terminal_red";
|
||||
case Death: return "scanner_terminal_dead";
|
||||
case Green: return "scanner_terminal_green";
|
||||
case Yellow: return "scanner_terminal_blue";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
||||
}
|
||||
}
|
||||
|
||||
public enum MedicalScannerVisualLayers
|
||||
{
|
||||
Machine,
|
||||
Terminal,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.GameObjects.Components.Medical.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.MedicalScanner
|
||||
{
|
||||
public class MedicalScannerWindow : SS14Window
|
||||
{
|
||||
public MedicalScannerWindow()
|
||||
{
|
||||
}
|
||||
|
||||
public void Populate(MedicalScannerBoundUserInterfaceState state)
|
||||
{
|
||||
Contents.RemoveAllChildren();
|
||||
var text = new StringBuilder();
|
||||
if (state.MaxHealth == 0)
|
||||
{
|
||||
text.Append("No patient data.");
|
||||
} else
|
||||
{
|
||||
text.Append($"Patient's health: {state.CurrentHealth}/{state.MaxHealth}\n");
|
||||
|
||||
if (state.DamageDictionary != null)
|
||||
{
|
||||
foreach (var (dmgType, amount) in state.DamageDictionary)
|
||||
{
|
||||
text.Append($"\n{dmgType}: {amount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Contents.AddChild(new Label(){Text = text.ToString()});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user