Files
tbd-station-14/Content.Client/GameObjects/Components/MedicalScanner/MedicalScannerWindow.cs
SoulSloth dc77c399b9 Add 'Scan DNA' function to medical scanner (#1783)
* Add art assets for cloning

* Added a 'Scan DNA' button to the medical scanner

* Made the UI update unconditional for the medical scanner until checks for power changes are in place

* Update Medical scanner to reflect powered status and fix #1774

* added a 'scan dna' button the the medical scanner that will add the contained bodies Uid to a list in CloningSystem, fixed an issue with the menu not populating if the scanner starts in an unpowered state

* Add disabling logic to 'Scan DNA' button on medical scanner

* Removed un-used libraries

* changed scan dna button to Scan and Save DNA
2020-08-19 16:23:20 +02:00

75 lines
2.4 KiB
C#

using System.Text;
using Content.Shared.Damage;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Interfaces.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;
protected override Vector2? CustomSize => (485, 90);
public MedicalScannerWindow()
{
Contents.AddChild(new VBoxContainer
{
Children =
{
(ScanButton = new Button
{
Text = "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;
}
}
}
}