Re-organize all projects (#4166)
This commit is contained in:
@@ -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