Re-organize all projects (#4166)
This commit is contained in:
16
Content.Client/MedicalScanner/MedicalScannerComponent.cs
Normal file
16
Content.Client/MedicalScanner/MedicalScannerComponent.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.MedicalScanner;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.MedicalScanner
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMedicalScannerComponent))]
|
||||
public class MedicalScannerComponent : SharedMedicalScannerComponent
|
||||
{
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Content.Client/MedicalScanner/MedicalScannerVisualizer.cs
Normal file
58
Content.Client/MedicalScanner/MedicalScannerVisualizer.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent.MedicalScannerStatus;
|
||||
|
||||
namespace Content.Client.MedicalScanner
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MedicalScannerVisualizer : 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 "closed";
|
||||
case Open: return "open";
|
||||
case Red: return "closed";
|
||||
case Death: return "closed";
|
||||
case Green: return "occupied";
|
||||
case Yellow: return "closed";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
||||
}
|
||||
}
|
||||
|
||||
private string StatusToTerminalStateId(MedicalScannerStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Off: return "off_unlit";
|
||||
case Open: return "idle_unlit";
|
||||
case Red: return "red_unlit";
|
||||
case Death: return "red_unlit";
|
||||
case Green: return "idle_unlit";
|
||||
case Yellow: return "maint_unlit";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
||||
}
|
||||
}
|
||||
|
||||
public enum MedicalScannerVisualLayers : byte
|
||||
{
|
||||
Machine,
|
||||
Terminal,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.MedicalScanner.UI
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MedicalScannerBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private MedicalScannerWindow? _window;
|
||||
|
||||
public MedicalScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new MedicalScannerWindow
|
||||
{
|
||||
Title = Owner.Owner.Name,
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window.ScanButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.ScanDNA));
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
_window?.Populate((MedicalScannerBoundUserInterfaceState) state);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Content.Client/MedicalScanner/UI/MedicalScannerWindow.cs
Normal file
76
Content.Client/MedicalScanner/UI/MedicalScannerWindow.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.Text;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.MedicalScanner.UI
|
||||
{
|
||||
public class MedicalScannerWindow : SS14Window
|
||||
{
|
||||
public readonly Button ScanButton;
|
||||
private readonly Label _diagnostics;
|
||||
public MedicalScannerWindow()
|
||||
{
|
||||
SetSize = (250, 100);
|
||||
|
||||
Contents.AddChild(new VBoxContainer
|
||||
{
|
||||
Children =
|
||||
{
|
||||
(ScanButton = new Button
|
||||
{
|
||||
Text = Loc.GetString("Scan and Save DNA")
|
||||
}),
|
||||
(_diagnostics = new Label
|
||||
{
|
||||
Text = ""
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Populate(MedicalScannerBoundUserInterfaceState state)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
|
||||
if (!state.Entity.HasValue ||
|
||||
!state.HasDamage() ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Entity.Value, out var entity))
|
||||
{
|
||||
_diagnostics.Text = Loc.GetString("No patient data.");
|
||||
ScanButton.Disabled = true;
|
||||
SetSize = (250, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Append($"{entity.Name}{Loc.GetString("'s health:")}\n");
|
||||
|
||||
foreach (var (@class, classAmount) in state.DamageClasses)
|
||||
{
|
||||
text.Append($"\n{Loc.GetString("{0}: {1}", @class, classAmount)}");
|
||||
|
||||
foreach (var type in @class.ToTypes())
|
||||
{
|
||||
if (!state.DamageTypes.TryGetValue(type, out var typeAmount))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
text.Append($"\n- {Loc.GetString("{0}: {1}", type, typeAmount)}");
|
||||
}
|
||||
|
||||
text.Append("\n");
|
||||
}
|
||||
|
||||
_diagnostics.Text = text.ToString();
|
||||
ScanButton.Disabled = state.IsScanned;
|
||||
|
||||
SetSize = (250, 575);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user