Files
wwdpublic/Content.Client/Atmos/Monitor/UI/AirAlarmBoundUserInterface.cs
eoineoineoin ebc0753aca Remove client state from server AirAlarmComponent (#31236)
* Remove client state from server AirAlarmComponent

Send information for all connected devices, not just the ones for the
current tab, as attempting to limit this breaks multiple users viewing
the same UI.

Fixes #12842

* Send device data as a list, rather than a dictionary

---------

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
(cherry picked from commit b0375f115c17564ecec1e58bf6851644fee1b723)
2025-09-27 12:21:07 +03:00

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();
}
}