Suit sensor and crew monitoring (#5521)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Medical.CrewMonitoring
|
||||
{
|
||||
public class CrewMonitoringBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private CrewMonitoringWindow? _menu;
|
||||
|
||||
public CrewMonitoringBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
_menu = new CrewMonitoringWindow();
|
||||
_menu.OpenCentered();
|
||||
_menu.OnClose += Close;
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case CrewMonitoringState st:
|
||||
_menu?.ShowSensors(st.Sensors);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
Title="{Loc 'crew-monitoring-user-interface-title'}"
|
||||
MinSize="450 400">
|
||||
<ScrollContainer HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<GridContainer Name="SensorsTable"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
HSeparationOverride="5"
|
||||
VSeparationOverride="20"
|
||||
Columns="3">
|
||||
<!-- Table header -->
|
||||
<Label Text="{Loc 'crew-monitoring-user-interface-name'}"
|
||||
StyleClasses="LabelHeading"/>
|
||||
<Label Text="{Loc 'crew-monitoring-user-interface-status'}"
|
||||
StyleClasses="LabelHeading"/>
|
||||
<Label Text="{Loc 'crew-monitoring-user-interface-location'}"
|
||||
StyleClasses="LabelHeading"/>
|
||||
|
||||
<!-- Table rows are filled by code -->
|
||||
</GridContainer>
|
||||
</ScrollContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Client.Medical.CrewMonitoring
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class CrewMonitoringWindow : SS14Window
|
||||
{
|
||||
private List<Control> _rowsContent = new();
|
||||
|
||||
public CrewMonitoringWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void ShowSensors(List<SuitSensorStatus> stSensors)
|
||||
{
|
||||
ClearAllSensors();
|
||||
|
||||
// add a row for each sensor
|
||||
foreach (var sensor in stSensors)
|
||||
{
|
||||
// add users name and job
|
||||
// format: UserName (Job)
|
||||
var nameLabel = new Label()
|
||||
{
|
||||
Text = $"{sensor.Name} ({sensor.Job})"
|
||||
};
|
||||
SensorsTable.AddChild(nameLabel);
|
||||
_rowsContent.Add(nameLabel);
|
||||
|
||||
// add users status and damage
|
||||
// format: IsAlive (TotalDamage)
|
||||
var statusText = Loc.GetString(sensor.IsAlive ?
|
||||
"crew-monitoring-user-interface-alive" :
|
||||
"crew-monitoring-user-interface-dead");
|
||||
if (sensor.TotalDamage != null)
|
||||
{
|
||||
statusText += $" ({sensor.TotalDamage})";
|
||||
}
|
||||
var statusLabel = new Label()
|
||||
{
|
||||
Text = statusText
|
||||
};
|
||||
SensorsTable.AddChild(statusLabel);
|
||||
_rowsContent.Add(statusLabel);
|
||||
|
||||
// add users positions
|
||||
// format: (x, y)
|
||||
string posText;
|
||||
if (sensor.Coordinates != null)
|
||||
{
|
||||
// todo: add locations names (kitchen, bridge, etc)
|
||||
var pos = sensor.Coordinates.Value.Position;
|
||||
var x = (int) pos.X;
|
||||
var y = (int) pos.Y;
|
||||
posText = $"({x}, {y})";
|
||||
}
|
||||
else
|
||||
{
|
||||
posText = Loc.GetString("crew-monitoring-user-interface-no-info");
|
||||
}
|
||||
var posLabel = new Label()
|
||||
{
|
||||
Text = posText
|
||||
};
|
||||
SensorsTable.AddChild(posLabel);
|
||||
_rowsContent.Add(posLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearAllSensors()
|
||||
{
|
||||
foreach (var child in _rowsContent)
|
||||
{
|
||||
SensorsTable.RemoveChild(child);
|
||||
}
|
||||
_rowsContent.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user