ui updates (no sensors yet)

This commit is contained in:
vulppine
2022-08-18 07:03:37 -07:00
parent 10e10b4bae
commit 531f0cb0e5
3 changed files with 27 additions and 27 deletions

View File

@@ -47,34 +47,21 @@ namespace Content.Client.Atmos.Monitor.UI
SendMessage(new AirAlarmUpdateAlarmModeMessage(mode)); SendMessage(new AirAlarmUpdateAlarmModeMessage(mode));
} }
private void OnThresholdChanged(AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null) private void OnThresholdChanged(string address, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null)
{ {
SendMessage(new AirAlarmUpdateAlarmThresholdMessage(type, threshold, gas)); SendMessage(new AirAlarmUpdateAlarmThresholdMessage(address, type, threshold, gas));
} }
protected override void ReceiveMessage(BoundUserInterfaceMessage message) protected override void UpdateState(BoundUserInterfaceState state)
{ {
if (_window == null) base.UpdateState(state);
return;
switch (message) if (state is not AirAlarmUIState cast || _window == null)
{ {
case AirAlarmSetAddressMessage addrMsg: return;
_window.SetAddress(addrMsg.Address);
break;
case AirAlarmUpdateDeviceDataMessage deviceMsg:
_window.UpdateDeviceData(deviceMsg.Address, deviceMsg.Data);
break;
case AirAlarmUpdateAlarmModeMessage alarmMsg:
_window.UpdateModeSelector(alarmMsg.Mode);
break;
case AirAlarmUpdateAlarmThresholdMessage thresholdMsg:
_window.UpdateThreshold(ref thresholdMsg);
break;
case AirAlarmUpdateAirDataMessage airDataMsg:
_window.UpdateGasData(ref airDataMsg.AirData);
break;
} }
_window.UpdateState(cast);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)

View File

@@ -19,7 +19,7 @@ namespace Content.Client.Atmos.Monitor.UI
public sealed partial class AirAlarmWindow : DefaultWindow public sealed partial class AirAlarmWindow : DefaultWindow
{ {
public event Action<string, IAtmosDeviceData>? AtmosDeviceDataChanged; public event Action<string, IAtmosDeviceData>? AtmosDeviceDataChanged;
public event Action<AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged; public event Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged;
public event Action<AirAlarmMode>? AirAlarmModeChanged; public event Action<AirAlarmMode>? AirAlarmModeChanged;
public event Action<string>? ResyncDeviceRequested; public event Action<string>? ResyncDeviceRequested;
public event Action? ResyncAllRequested; public event Action? ResyncAllRequested;
@@ -34,9 +34,6 @@ namespace Content.Client.Atmos.Monitor.UI
private BoxContainer _gasReadout => CGasContainer; private BoxContainer _gasReadout => CGasContainer;
private BoxContainer _ventDevices => CVentContainer; private BoxContainer _ventDevices => CVentContainer;
private BoxContainer _scrubberDevices => CScrubberContainer; private BoxContainer _scrubberDevices => CScrubberContainer;
private BoxContainer _pressureThreshold => CPressureThreshold;
private BoxContainer _temperatureThreshold => CTemperatureThreshold;
private BoxContainer _gasThreshold => CGasThresholdContainer;
private Dictionary<string, PumpControl> _pumps = new(); private Dictionary<string, PumpControl> _pumps = new();
private Dictionary<string, ScrubberControl> _scrubbers = new(); private Dictionary<string, ScrubberControl> _scrubbers = new();
@@ -85,11 +82,24 @@ namespace Content.Client.Atmos.Monitor.UI
}; };
} }
public void UpdateState(AirAlarmUIState state)
{
_pressure.SetMarkup(Loc.GetString("air-alarm-ui-window-pressure", ("pressure", $"{state.PressureAverage:0.##}")));
_temperature.SetMarkup(Loc.GetString("air-alarm-ui-window-temperature", ("tempC", $"{TemperatureHelpers.KelvinToCelsius(state.TemperatureAverage):0.#}"), ("temperature", $"{state.TemperatureAverage:0.##}")));
_alarmState.SetMarkup(Loc.GetString("air-alarm-ui-window-alarm-state", ("state", $"{state.AlarmType}")));
UpdateModeSelector(state.Mode);
foreach (var (addr, dev) in state.DeviceData)
{
UpdateDeviceData(addr, dev);
}
}
public void SetAddress(string address) public void SetAddress(string address)
{ {
_address.Text = address; _address.Text = address;
} }
/*
public void UpdateGasData(ref AirAlarmAirData state) public void UpdateGasData(ref AirAlarmAirData state)
{ {
_pressure.SetMarkup(Loc.GetString("air-alarm-ui-window-pressure", ("pressure", $"{state.Pressure:0.##}"))); _pressure.SetMarkup(Loc.GetString("air-alarm-ui-window-pressure", ("pressure", $"{state.Pressure:0.##}")));
@@ -100,6 +110,7 @@ namespace Content.Client.Atmos.Monitor.UI
foreach (var (gas, amount) in state.Gases) foreach (var (gas, amount) in state.Gases)
_gasLabels[gas].Text = Loc.GetString("air-alarm-ui-gases", ("gas", $"{gas}"), ("amount", $"{amount:0.####}"), ("percentage", $"{(amount / state.TotalMoles):0.##}")); _gasLabels[gas].Text = Loc.GetString("air-alarm-ui-gases", ("gas", $"{gas}"), ("amount", $"{amount:0.####}"), ("percentage", $"{(amount / state.TotalMoles):0.##}"));
} }
*/
public void UpdateModeSelector(AirAlarmMode mode) public void UpdateModeSelector(AirAlarmMode mode)
{ {
@@ -143,6 +154,7 @@ namespace Content.Client.Atmos.Monitor.UI
_deviceTotal.Text = $"{_pumps.Count + _scrubbers.Count}"; _deviceTotal.Text = $"{_pumps.Count + _scrubbers.Count}";
} }
/*
public void UpdateThreshold(ref AirAlarmUpdateAlarmThresholdMessage message) public void UpdateThreshold(ref AirAlarmUpdateAlarmThresholdMessage message)
{ {
switch (message.Type) switch (message.Type)
@@ -188,5 +200,6 @@ namespace Content.Client.Atmos.Monitor.UI
break; break;
} }
} }
*/
} }
} }

View File

@@ -524,8 +524,8 @@ namespace Content.Server.Atmos.Monitor.Systems
return; return;
} }
var pressure = CalculatePressureAverage(uid, alarm); var pressure = CalculatePressureAverage(alarm);
var temperature = CalculateTemperatureAverage(uid, alarm); var temperature = CalculateTemperatureAverage(alarm);
var dataToSend = new Dictionary<string, IAtmosDeviceData>(); var dataToSend = new Dictionary<string, IAtmosDeviceData>();
if (alarm.CurrentTab != AirAlarmTab.Settings) if (alarm.CurrentTab != AirAlarmTab.Settings)