MedicalScannerWindow to XAML UI (#4641)

This commit is contained in:
Visne
2021-09-19 19:36:09 +02:00
committed by GitHub
parent 9e5628ab5e
commit 73171835f1
2 changed files with 17 additions and 23 deletions

View File

@@ -0,0 +1,9 @@
<SS14Window xmlns="https://spacestation14.io"
MinSize="250 100"
SetSize="250 100">
<BoxContainer Orientation="Vertical">
<Button Name="ScanButtonProtected"
Text="{Loc 'medical-scanner-window-save-button-text'}" />
<Label Name="Diagnostics" />
</BoxContainer>
</SS14Window>

View File

@@ -8,35 +8,20 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.MedicalScanner.UI namespace Content.Client.MedicalScanner.UI
{ {
public class MedicalScannerWindow : SS14Window [GenerateTypedNameReferences]
public partial class MedicalScannerWindow : SS14Window
{ {
public readonly Button ScanButton; public Button ScanButton => ScanButtonProtected;
private readonly Label _diagnostics;
public MedicalScannerWindow() public MedicalScannerWindow()
{ {
SetSize = (250, 100); RobustXamlLoader.Load(this);
Contents.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
(ScanButton = new Button
{
Text = Loc.GetString("medical-scanner-window-save-button-text")
}),
(_diagnostics = new Label
{
Text = string.Empty
})
}
});
} }
public void Populate(MedicalScannerBoundUserInterfaceState state) public void Populate(MedicalScannerBoundUserInterfaceState state)
@@ -47,7 +32,7 @@ namespace Content.Client.MedicalScanner.UI
!state.HasDamage() || !state.HasDamage() ||
!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Entity.Value, out var entity)) !IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Entity.Value, out var entity))
{ {
_diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text"); Diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text");
ScanButton.Disabled = true; ScanButton.Disabled = true;
SetSize = (250, 100); SetSize = (250, 100);
} }
@@ -85,7 +70,7 @@ namespace Content.Client.MedicalScanner.UI
text.Append('\n'); text.Append('\n');
} }
_diagnostics.Text = text.ToString(); Diagnostics.Text = text.ToString();
ScanButton.Disabled = state.IsScanned; ScanButton.Disabled = state.IsScanned;
// TODO MEDICALSCANNER resize window based on the length of text / number of damage types? // TODO MEDICALSCANNER resize window based on the length of text / number of damage types?