* Cleanup `ScrubberControl.xaml.cs` * Minor cleanups * Another pile of minor cleanups * Apply requested changes * Rename "which" into "bound". Add whitespace after "if"
81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using Content.Shared.Atmos;
|
|
using Content.Shared.Atmos.Monitor;
|
|
using Content.Shared.Atmos.Monitor.Components;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Atmos.Monitor.UI;
|
|
|
|
public sealed class AirAlarmBoundUserInterface : BoundUserInterface
|
|
{
|
|
private AirAlarmWindow? _window;
|
|
|
|
public AirAlarmBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<AirAlarmWindow>();
|
|
_window.SetEntity(Owner);
|
|
|
|
_window.AtmosDeviceDataChanged += OnDeviceDataChanged;
|
|
_window.AtmosDeviceDataCopied += OnDeviceDataCopied;
|
|
_window.AtmosAlarmThresholdChanged += OnThresholdChanged;
|
|
_window.AirAlarmModeChanged += OnAirAlarmModeChanged;
|
|
_window.AutoModeChanged += OnAutoModeChanged;
|
|
_window.ResyncAllRequested += ResyncAllDevices;
|
|
}
|
|
|
|
private void ResyncAllDevices()
|
|
{
|
|
SendMessage(new AirAlarmResyncAllDevicesMessage());
|
|
}
|
|
|
|
private void OnDeviceDataChanged(string address, IAtmosDeviceData data)
|
|
{
|
|
SendMessage(new AirAlarmUpdateDeviceDataMessage(address, data));
|
|
}
|
|
|
|
private void OnDeviceDataCopied(IAtmosDeviceData data)
|
|
{
|
|
SendMessage(new AirAlarmCopyDeviceDataMessage(data));
|
|
}
|
|
|
|
private void OnAirAlarmModeChanged(AirAlarmMode mode)
|
|
{
|
|
SendMessage(new AirAlarmUpdateAlarmModeMessage(mode));
|
|
}
|
|
|
|
private void OnAutoModeChanged(bool enabled)
|
|
{
|
|
SendMessage(new AirAlarmUpdateAutoModeMessage(enabled));
|
|
}
|
|
|
|
private void OnThresholdChanged(string address, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null)
|
|
{
|
|
SendMessage(new AirAlarmUpdateAlarmThresholdMessage(address, type, threshold, gas));
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (state is not AirAlarmUIState cast || _window == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_window.UpdateState(cast);
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
|
|
if (disposing)
|
|
_window?.Dispose();
|
|
}
|
|
}
|