@@ -20,7 +20,8 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
|||||||
public NetEntity NetEntity;
|
public NetEntity NetEntity;
|
||||||
public EntityCoordinates? Coordinates;
|
public EntityCoordinates? Coordinates;
|
||||||
|
|
||||||
private IResourceCache _cache;
|
private readonly IEntityManager _entManager;
|
||||||
|
private readonly IResourceCache _cache;
|
||||||
|
|
||||||
private Dictionary<AtmosAlarmType, string> _alarmStrings = new Dictionary<AtmosAlarmType, string>()
|
private Dictionary<AtmosAlarmType, string> _alarmStrings = new Dictionary<AtmosAlarmType, string>()
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,7 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
|||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
|
_entManager = IoCManager.Resolve<IEntityManager>();
|
||||||
_cache = IoCManager.Resolve<IResourceCache>();
|
_cache = IoCManager.Resolve<IResourceCache>();
|
||||||
|
|
||||||
NetEntity = uid;
|
NetEntity = uid;
|
||||||
@@ -75,6 +77,9 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
|||||||
|
|
||||||
public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlertsFocusDeviceData? focusData = null)
|
public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlertsFocusDeviceData? focusData = null)
|
||||||
{
|
{
|
||||||
|
NetEntity = entry.NetEntity;
|
||||||
|
Coordinates = _entManager.GetCoordinates(entry.Coordinates);
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
var normalFont = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf"), 11);
|
var normalFont = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf"), 11);
|
||||||
|
|
||||||
@@ -104,18 +109,18 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
|||||||
if (focusData != null)
|
if (focusData != null)
|
||||||
{
|
{
|
||||||
// Update temperature
|
// Update temperature
|
||||||
var tempK = (FixedPoint2) focusData.Value.TemperatureData.Item1;
|
var tempK = (FixedPoint2)focusData.Value.TemperatureData.Item1;
|
||||||
var tempC = (FixedPoint2) TemperatureHelpers.KelvinToCelsius(tempK.Float());
|
var tempC = (FixedPoint2)TemperatureHelpers.KelvinToCelsius(tempK.Float());
|
||||||
|
|
||||||
TemperatureLabel.Text = Loc.GetString("atmos-alerts-window-temperature-value", ("valueInC", tempC), ("valueInK", tempK));
|
TemperatureLabel.Text = Loc.GetString("atmos-alerts-window-temperature-value", ("valueInC", tempC), ("valueInK", tempK));
|
||||||
TemperatureLabel.FontColorOverride = GetAlarmStateColor(focusData.Value.TemperatureData.Item2);
|
TemperatureLabel.FontColorOverride = GetAlarmStateColor(focusData.Value.TemperatureData.Item2);
|
||||||
|
|
||||||
// Update pressure
|
// Update pressure
|
||||||
PressureLabel.Text = Loc.GetString("atmos-alerts-window-pressure-value", ("value", (FixedPoint2) focusData.Value.PressureData.Item1));
|
PressureLabel.Text = Loc.GetString("atmos-alerts-window-pressure-value", ("value", (FixedPoint2)focusData.Value.PressureData.Item1));
|
||||||
PressureLabel.FontColorOverride = GetAlarmStateColor(focusData.Value.PressureData.Item2);
|
PressureLabel.FontColorOverride = GetAlarmStateColor(focusData.Value.PressureData.Item2);
|
||||||
|
|
||||||
// Update oxygenation
|
// Update oxygenation
|
||||||
var oxygenPercent = (FixedPoint2) 0f;
|
var oxygenPercent = (FixedPoint2)0f;
|
||||||
var oxygenAlert = AtmosAlarmType.Invalid;
|
var oxygenAlert = AtmosAlarmType.Invalid;
|
||||||
|
|
||||||
if (focusData.Value.GasData.TryGetValue(Gas.Oxygen, out var oxygenData))
|
if (focusData.Value.GasData.TryGetValue(Gas.Oxygen, out var oxygenData))
|
||||||
@@ -155,7 +160,7 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
|||||||
// Add an entry for each gas
|
// Add an entry for each gas
|
||||||
foreach ((var gas, (var mol, var percent, var alert)) in gasData)
|
foreach ((var gas, (var mol, var percent, var alert)) in gasData)
|
||||||
{
|
{
|
||||||
var gasPercent = (FixedPoint2) 0f;
|
var gasPercent = (FixedPoint2)0f;
|
||||||
gasPercent = percent * 100f;
|
gasPercent = percent * 100f;
|
||||||
|
|
||||||
if (!_gasShorthands.TryGetValue(gas, out var gasShorthand))
|
if (!_gasShorthands.TryGetValue(gas, out var gasShorthand))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Content.Client.Stylesheets;
|
|||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Shared.Atmos.Components;
|
using Content.Shared.Atmos.Components;
|
||||||
using Content.Shared.Atmos.Monitor;
|
using Content.Shared.Atmos.Monitor;
|
||||||
|
using Content.Shared.Pinpointer;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
@@ -28,6 +29,8 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
|
|
||||||
private AtmosAlertsComputerEntry[]? _airAlarms = null;
|
private AtmosAlertsComputerEntry[]? _airAlarms = null;
|
||||||
private AtmosAlertsComputerEntry[]? _fireAlarms = null;
|
private AtmosAlertsComputerEntry[]? _fireAlarms = null;
|
||||||
|
private IEnumerable<AtmosAlertsComputerEntry>? _allAlarms = null;
|
||||||
|
|
||||||
private IEnumerable<AtmosAlertsComputerEntry>? _activeAlarms = null;
|
private IEnumerable<AtmosAlertsComputerEntry>? _activeAlarms = null;
|
||||||
private Dictionary<NetEntity, float> _deviceSilencingProgress = new();
|
private Dictionary<NetEntity, float> _deviceSilencingProgress = new();
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
stationName = stationMetaData.EntityName;
|
stationName = stationMetaData.EntityName;
|
||||||
|
|
||||||
var msg = new FormattedMessage();
|
var msg = new FormattedMessage();
|
||||||
msg.AddMarkup(Loc.GetString("atmos-alerts-window-station-name", ("stationName", stationName)));
|
msg.TryAddMarkup(Loc.GetString("atmos-alerts-window-station-name", ("stationName", stationName)), out _);
|
||||||
|
|
||||||
StationName.SetMessage(msg);
|
StationName.SetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -110,7 +113,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
|
|
||||||
foreach (var device in console.AtmosDevices)
|
foreach (var device in console.AtmosDevices)
|
||||||
{
|
{
|
||||||
var alarmState = GetAlarmState(device.NetEntity, device.Group);
|
var alarmState = GetAlarmState(device.NetEntity);
|
||||||
|
|
||||||
if (toggledAlarmState != alarmState)
|
if (toggledAlarmState != alarmState)
|
||||||
continue;
|
continue;
|
||||||
@@ -162,11 +165,11 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
// Retain alarm data for use inbetween updates
|
// Retain alarm data for use inbetween updates
|
||||||
_airAlarms = airAlarms;
|
_airAlarms = airAlarms;
|
||||||
_fireAlarms = fireAlarms;
|
_fireAlarms = fireAlarms;
|
||||||
|
_allAlarms = airAlarms.Concat(fireAlarms);
|
||||||
|
|
||||||
var allAlarms = airAlarms.Concat(fireAlarms);
|
|
||||||
var silenced = console.SilencedDevices;
|
var silenced = console.SilencedDevices;
|
||||||
|
|
||||||
_activeAlarms = allAlarms.Where(x => x.AlarmState > AtmosAlarmType.Normal &&
|
_activeAlarms = _allAlarms.Where(x => x.AlarmState > AtmosAlarmType.Normal &&
|
||||||
(!silenced.Contains(x.NetEntity) || _deviceSilencingProgress.ContainsKey(x.NetEntity)));
|
(!silenced.Contains(x.NetEntity) || _deviceSilencingProgress.ContainsKey(x.NetEntity)));
|
||||||
|
|
||||||
// Reset nav map data
|
// Reset nav map data
|
||||||
@@ -179,7 +182,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
if (!NavMap.Visible)
|
if (!NavMap.Visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var alarmState = GetAlarmState(device.NetEntity, device.Group);
|
var alarmState = GetAlarmState(device.NetEntity);
|
||||||
|
|
||||||
if (_trackedEntity != device.NetEntity)
|
if (_trackedEntity != device.NetEntity)
|
||||||
{
|
{
|
||||||
@@ -305,9 +308,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
// On click
|
// On click
|
||||||
newEntryContainer.FocusButton.OnButtonUp += args =>
|
newEntryContainer.FocusButton.OnButtonUp += args =>
|
||||||
{
|
{
|
||||||
var prevTrackedEntity = _trackedEntity;
|
if (_trackedEntity == newEntryContainer.NetEntity)
|
||||||
|
|
||||||
if (_trackedEntity == entry.NetEntity)
|
|
||||||
{
|
{
|
||||||
_trackedEntity = null;
|
_trackedEntity = null;
|
||||||
}
|
}
|
||||||
@@ -315,20 +316,22 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_trackedEntity = newEntryContainer.NetEntity;
|
_trackedEntity = newEntryContainer.NetEntity;
|
||||||
NavMap.CenterToCoordinates(_entManager.GetCoordinates(entry.Coordinates));
|
|
||||||
|
if (newEntryContainer.Coordinates != null)
|
||||||
|
NavMap.CenterToCoordinates(newEntryContainer.Coordinates.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send message to console that the focus has changed
|
// Send message to console that the focus has changed
|
||||||
SendFocusChangeMessageAction?.Invoke(_trackedEntity);
|
SendFocusChangeMessageAction?.Invoke(_trackedEntity);
|
||||||
|
|
||||||
// Update affected UI elements across all tables
|
// Update affected UI elements across all tables
|
||||||
UpdateConsoleTable(console, AlertsTable, _trackedEntity, prevTrackedEntity);
|
UpdateConsoleTable(console, AlertsTable, _trackedEntity);
|
||||||
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity, prevTrackedEntity);
|
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity);
|
||||||
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity, prevTrackedEntity);
|
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity);
|
||||||
};
|
};
|
||||||
|
|
||||||
// On toggling the silence check box
|
// On toggling the silence check box
|
||||||
newEntryContainer.SilenceCheckBox.OnToggled += _ => OnSilenceAlertsToggled(entry.NetEntity, newEntryContainer.SilenceCheckBox.Pressed);
|
newEntryContainer.SilenceCheckBox.OnToggled += _ => OnSilenceAlertsToggled(newEntryContainer.NetEntity, newEntryContainer.SilenceCheckBox.Pressed);
|
||||||
|
|
||||||
// Add the entry to the current table
|
// Add the entry to the current table
|
||||||
table.AddChild(newEntryContainer);
|
table.AddChild(newEntryContainer);
|
||||||
@@ -345,48 +348,33 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entryContainer = tableChild as AtmosAlarmEntryContainer;
|
var entryContainer = (AtmosAlarmEntryContainer)tableChild;
|
||||||
var silenced = console.SilencedDevices;
|
|
||||||
|
|
||||||
if (entryContainer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
entryContainer.UpdateEntry(entry, entry.NetEntity == _trackedEntity, focusData);
|
entryContainer.UpdateEntry(entry, entry.NetEntity == _trackedEntity, focusData);
|
||||||
entryContainer.SilenceCheckBox.Pressed = (silenced.Contains(entry.NetEntity) || _deviceSilencingProgress.ContainsKey(entry.NetEntity));
|
|
||||||
|
if (_trackedEntity != entry.NetEntity)
|
||||||
|
{
|
||||||
|
var silenced = console.SilencedDevices;
|
||||||
|
entryContainer.SilenceCheckBox.Pressed = (silenced.Contains(entry.NetEntity) || _deviceSilencingProgress.ContainsKey(entry.NetEntity));
|
||||||
|
}
|
||||||
|
|
||||||
entryContainer.SilenceAlarmProgressBar.Visible = (table == AlertsTable && _deviceSilencingProgress.ContainsKey(entry.NetEntity));
|
entryContainer.SilenceAlarmProgressBar.Visible = (table == AlertsTable && _deviceSilencingProgress.ContainsKey(entry.NetEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateConsoleTable(AtmosAlertsComputerComponent console, Control table, NetEntity? currTrackedEntity, NetEntity? prevTrackedEntity)
|
private void UpdateConsoleTable(AtmosAlertsComputerComponent console, Control table, NetEntity? currTrackedEntity)
|
||||||
{
|
{
|
||||||
foreach (var child in table.Children)
|
foreach (var tableChild in table.Children)
|
||||||
{
|
{
|
||||||
if (child is not AtmosAlarmEntryContainer)
|
if (tableChild is not AtmosAlarmEntryContainer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var castAlert = (AtmosAlarmEntryContainer) child;
|
var entryContainer = (AtmosAlarmEntryContainer)tableChild;
|
||||||
|
|
||||||
if (castAlert.NetEntity == prevTrackedEntity)
|
if (entryContainer.NetEntity != currTrackedEntity)
|
||||||
castAlert.RemoveAsFocus();
|
entryContainer.RemoveAsFocus();
|
||||||
|
|
||||||
else if (castAlert.NetEntity == currTrackedEntity)
|
else if (entryContainer.NetEntity == currTrackedEntity)
|
||||||
castAlert.SetAsFocus();
|
entryContainer.SetAsFocus();
|
||||||
|
|
||||||
if (castAlert?.Coordinates == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var device = console.AtmosDevices.FirstOrNull(x => x.NetEntity == castAlert.NetEntity);
|
|
||||||
|
|
||||||
if (device == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var alarmState = GetAlarmState(device.Value.NetEntity, device.Value.Group);
|
|
||||||
|
|
||||||
if (currTrackedEntity != device.Value.NetEntity &&
|
|
||||||
!ShowInactiveAlarms.Pressed &&
|
|
||||||
alarmState <= AtmosAlarmType.Normal)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
AddTrackedEntityToNavMap(device.Value, alarmState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,8 +422,13 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
var t = remainingTime - args.DeltaSeconds;
|
var t = remainingTime - args.DeltaSeconds;
|
||||||
|
|
||||||
if (t <= 0)
|
if (t <= 0)
|
||||||
|
{
|
||||||
_deviceSilencingProgress.Remove(device);
|
_deviceSilencingProgress.Remove(device);
|
||||||
|
|
||||||
|
if (device == _trackedEntity)
|
||||||
|
_trackedEntity = null;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
_deviceSilencingProgress[device] = t;
|
_deviceSilencingProgress[device] = t;
|
||||||
}
|
}
|
||||||
@@ -512,7 +505,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
if (control == null || control is not AtmosAlarmEntryContainer)
|
if (control == null || control is not AtmosAlarmEntryContainer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (((AtmosAlarmEntryContainer) control).NetEntity == _trackedEntity)
|
if (((AtmosAlarmEntryContainer)control).NetEntity == _trackedEntity)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
nextScrollPosition += control.Height;
|
nextScrollPosition += control.Height;
|
||||||
@@ -524,10 +517,9 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AtmosAlarmType GetAlarmState(NetEntity netEntity, AtmosAlertsComputerGroup group)
|
private AtmosAlarmType GetAlarmState(NetEntity netEntity)
|
||||||
{
|
{
|
||||||
var alarms = (group == AtmosAlertsComputerGroup.AirAlarm) ? _airAlarms : _fireAlarms;
|
var alarmState = _allAlarms?.FirstOrNull(x => x.NetEntity == netEntity)?.AlarmState;
|
||||||
var alarmState = alarms?.FirstOrNull(x => x.NetEntity == netEntity)?.AlarmState;
|
|
||||||
|
|
||||||
if (alarmState == null)
|
if (alarmState == null)
|
||||||
return AtmosAlarmType.Invalid;
|
return AtmosAlarmType.Invalid;
|
||||||
|
|||||||
Reference in New Issue
Block a user