Files
tbd-station-14/Content.Client/GameObjects/Components/MedicalScanner/MedicalScannerWindow.cs
Pieter-Jan Briers b898443f28 WPF layout (#3346)
2021-02-21 12:38:56 +01:00

75 lines
2.3 KiB
C#

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 Robust.Shared.Maths;
using static Content.Shared.GameObjects.Components.Medical.SharedMedicalScannerComponent;
namespace Content.Client.GameObjects.Components.MedicalScanner
{
public class MedicalScannerWindow : SS14Window
{
public readonly Button ScanButton;
private readonly Label _diagnostics;
public MedicalScannerWindow()
{
MinSize = SetSize = (485, 90);
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;
}
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;
}
}
}
}