@@ -20,7 +20,8 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
||||
public NetEntity NetEntity;
|
||||
public EntityCoordinates? Coordinates;
|
||||
|
||||
private IResourceCache _cache;
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly IResourceCache _cache;
|
||||
|
||||
private Dictionary<AtmosAlarmType, string> _alarmStrings = new Dictionary<AtmosAlarmType, string>()
|
||||
{
|
||||
@@ -47,6 +48,7 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
_entManager = IoCManager.Resolve<IEntityManager>();
|
||||
_cache = IoCManager.Resolve<IResourceCache>();
|
||||
|
||||
NetEntity = uid;
|
||||
@@ -75,6 +77,9 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
|
||||
|
||||
public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlertsFocusDeviceData? focusData = null)
|
||||
{
|
||||
NetEntity = entry.NetEntity;
|
||||
Coordinates = _entManager.GetCoordinates(entry.Coordinates);
|
||||
|
||||
// Load fonts
|
||||
var normalFont = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf"), 11);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Atmos.Components;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Pinpointer;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -28,6 +29,8 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
|
||||
private AtmosAlertsComputerEntry[]? _airAlarms = null;
|
||||
private AtmosAlertsComputerEntry[]? _fireAlarms = null;
|
||||
private IEnumerable<AtmosAlertsComputerEntry>? _allAlarms = null;
|
||||
|
||||
private IEnumerable<AtmosAlertsComputerEntry>? _activeAlarms = null;
|
||||
private Dictionary<NetEntity, float> _deviceSilencingProgress = new();
|
||||
|
||||
@@ -65,7 +68,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
stationName = stationMetaData.EntityName;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -110,7 +113,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
|
||||
foreach (var device in console.AtmosDevices)
|
||||
{
|
||||
var alarmState = GetAlarmState(device.NetEntity, device.Group);
|
||||
var alarmState = GetAlarmState(device.NetEntity);
|
||||
|
||||
if (toggledAlarmState != alarmState)
|
||||
continue;
|
||||
@@ -162,11 +165,11 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
// Retain alarm data for use inbetween updates
|
||||
_airAlarms = airAlarms;
|
||||
_fireAlarms = fireAlarms;
|
||||
_allAlarms = airAlarms.Concat(fireAlarms);
|
||||
|
||||
var allAlarms = airAlarms.Concat(fireAlarms);
|
||||
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)));
|
||||
|
||||
// Reset nav map data
|
||||
@@ -179,7 +182,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
if (!NavMap.Visible)
|
||||
continue;
|
||||
|
||||
var alarmState = GetAlarmState(device.NetEntity, device.Group);
|
||||
var alarmState = GetAlarmState(device.NetEntity);
|
||||
|
||||
if (_trackedEntity != device.NetEntity)
|
||||
{
|
||||
@@ -305,9 +308,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
// On click
|
||||
newEntryContainer.FocusButton.OnButtonUp += args =>
|
||||
{
|
||||
var prevTrackedEntity = _trackedEntity;
|
||||
|
||||
if (_trackedEntity == entry.NetEntity)
|
||||
if (_trackedEntity == newEntryContainer.NetEntity)
|
||||
{
|
||||
_trackedEntity = null;
|
||||
}
|
||||
@@ -315,20 +316,22 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
else
|
||||
{
|
||||
_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
|
||||
SendFocusChangeMessageAction?.Invoke(_trackedEntity);
|
||||
|
||||
// Update affected UI elements across all tables
|
||||
UpdateConsoleTable(console, AlertsTable, _trackedEntity, prevTrackedEntity);
|
||||
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity, prevTrackedEntity);
|
||||
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity, prevTrackedEntity);
|
||||
UpdateConsoleTable(console, AlertsTable, _trackedEntity);
|
||||
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity);
|
||||
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity);
|
||||
};
|
||||
|
||||
// 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
|
||||
table.AddChild(newEntryContainer);
|
||||
@@ -345,48 +348,33 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
return;
|
||||
}
|
||||
|
||||
var entryContainer = tableChild as AtmosAlarmEntryContainer;
|
||||
var silenced = console.SilencedDevices;
|
||||
|
||||
if (entryContainer == null)
|
||||
return;
|
||||
var entryContainer = (AtmosAlarmEntryContainer)tableChild;
|
||||
|
||||
entryContainer.UpdateEntry(entry, entry.NetEntity == _trackedEntity, focusData);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
var castAlert = (AtmosAlarmEntryContainer) child;
|
||||
var entryContainer = (AtmosAlarmEntryContainer)tableChild;
|
||||
|
||||
if (castAlert.NetEntity == prevTrackedEntity)
|
||||
castAlert.RemoveAsFocus();
|
||||
if (entryContainer.NetEntity != currTrackedEntity)
|
||||
entryContainer.RemoveAsFocus();
|
||||
|
||||
else if (castAlert.NetEntity == currTrackedEntity)
|
||||
castAlert.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);
|
||||
else if (entryContainer.NetEntity == currTrackedEntity)
|
||||
entryContainer.SetAsFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,8 +422,13 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
var t = remainingTime - args.DeltaSeconds;
|
||||
|
||||
if (t <= 0)
|
||||
{
|
||||
_deviceSilencingProgress.Remove(device);
|
||||
|
||||
if (device == _trackedEntity)
|
||||
_trackedEntity = null;
|
||||
}
|
||||
|
||||
else
|
||||
_deviceSilencingProgress[device] = t;
|
||||
}
|
||||
@@ -524,10 +517,9 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
return false;
|
||||
}
|
||||
|
||||
private AtmosAlarmType GetAlarmState(NetEntity netEntity, AtmosAlertsComputerGroup group)
|
||||
private AtmosAlarmType GetAlarmState(NetEntity netEntity)
|
||||
{
|
||||
var alarms = (group == AtmosAlertsComputerGroup.AirAlarm) ? _airAlarms : _fireAlarms;
|
||||
var alarmState = alarms?.FirstOrNull(x => x.NetEntity == netEntity)?.AlarmState;
|
||||
var alarmState = _allAlarms?.FirstOrNull(x => x.NetEntity == netEntity)?.AlarmState;
|
||||
|
||||
if (alarmState == null)
|
||||
return AtmosAlarmType.Invalid;
|
||||
|
||||
Reference in New Issue
Block a user