Add directional icons to crew monitors (#7404)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
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;
|
||||
using Robust.Shared.Map;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
|
||||
namespace Content.Client.Medical.CrewMonitoring
|
||||
{
|
||||
@@ -14,15 +15,21 @@ namespace Content.Client.Medical.CrewMonitoring
|
||||
{
|
||||
private List<Control> _rowsContent = new();
|
||||
|
||||
public static int IconSize = 16; // XAML has a `VSeparationOverride` of 20 for each row.
|
||||
|
||||
public CrewMonitoringWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void ShowSensors(List<SuitSensorStatus> stSensors)
|
||||
public void ShowSensors(List<SuitSensorStatus> stSensors, Vector2 worldPosition, Angle worldRotation, bool snap, float precision)
|
||||
{
|
||||
ClearAllSensors();
|
||||
|
||||
// TODO scroll container
|
||||
// TODO filter by name & occupation
|
||||
// TODO make each row a xaml-control. Get rid of some of this c# control creation.
|
||||
|
||||
// add a row for each sensor
|
||||
foreach (var sensor in stSensors)
|
||||
{
|
||||
@@ -53,28 +60,43 @@ namespace Content.Client.Medical.CrewMonitoring
|
||||
|
||||
// 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);
|
||||
var box = GetPositionBox(sensor.Coordinates, worldPosition, worldRotation, snap, precision);
|
||||
SensorsTable.AddChild(box);
|
||||
_rowsContent.Add(box);
|
||||
}
|
||||
}
|
||||
|
||||
private BoxContainer GetPositionBox(MapCoordinates? coordinates, Vector2 sensorPosition, Angle sensorRotation, bool snap, float precision)
|
||||
{
|
||||
var box = new BoxContainer() { Orientation = LayoutOrientation.Horizontal };
|
||||
|
||||
if (coordinates == null)
|
||||
{
|
||||
var dirIcon = new DirectionIcon()
|
||||
{
|
||||
SetSize = (IconSize, IconSize),
|
||||
Margin = new(0, 0, 4, 0)
|
||||
};
|
||||
box.AddChild(dirIcon);
|
||||
box.AddChild(new Label() { Text = Loc.GetString("crew-monitoring-user-interface-no-info") });
|
||||
}
|
||||
else
|
||||
{
|
||||
// todo: add locations names (kitchen, bridge, etc)
|
||||
var pos = (Vector2i) coordinates.Value.Position;
|
||||
var relPos = coordinates.Value.Position - sensorPosition;
|
||||
var dirIcon = new DirectionIcon(relPos, sensorRotation, snap, minDistance: precision)
|
||||
{
|
||||
SetSize = (IconSize, IconSize),
|
||||
Margin = new(0, 0, 4, 0)
|
||||
};
|
||||
box.AddChild(dirIcon);
|
||||
box.AddChild(new Label() { Text = pos.ToString() });
|
||||
}
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
private void ClearAllSensors()
|
||||
{
|
||||
foreach (var child in _rowsContent)
|
||||
|
||||
Reference in New Issue
Block a user