copy-settings-to-all-similar for scrubbers and vents in air alarms (#18363)

This commit is contained in:
Ilya246
2023-08-09 22:20:19 +04:00
committed by GitHub
parent aee88e1721
commit d3244b6049
9 changed files with 71 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
_window.OnClose += Close;
_window.AtmosDeviceDataChanged += OnDeviceDataChanged;
_window.AtmosDeviceDataCopied += OnDeviceDataCopied;
_window.AtmosAlarmThresholdChanged += OnThresholdChanged;
_window.AirAlarmModeChanged += OnAirAlarmModeChanged;
_window.AutoModeChanged += OnAutoModeChanged;
@@ -47,6 +48,11 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
{
SendMessage(new AirAlarmUpdateDeviceDataMessage(address, data));
}
private void OnDeviceDataCopied(IAtmosDeviceData data)
{
SendMessage(new AirAlarmCopyDeviceDataMessage(data));
}
private void OnAirAlarmModeChanged(AirAlarmMode mode)
{

View File

@@ -18,6 +18,7 @@ namespace Content.Client.Atmos.Monitor.UI;
public sealed partial class AirAlarmWindow : FancyWindow
{
public event Action<string, IAtmosDeviceData>? AtmosDeviceDataChanged;
public event Action<IAtmosDeviceData>? AtmosDeviceDataCopied;
public event Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged;
public event Action<AirAlarmMode>? AirAlarmModeChanged;
public event Action<bool>? AutoModeChanged;
@@ -137,6 +138,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
{
var control= new PumpControl(pump, addr);
control.PumpDataChanged += AtmosDeviceDataChanged!.Invoke;
control.PumpDataCopied += AtmosDeviceDataCopied!.Invoke;
_pumps.Add(addr, control);
CVentContainer.AddChild(control);
}
@@ -151,6 +153,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
{
var control = new ScrubberControl(scrubber, addr);
control.ScrubberDataChanged += AtmosDeviceDataChanged!.Invoke;
control.ScrubberDataCopied += AtmosDeviceDataCopied!.Invoke;
_scrubbers.Add(addr, control);
CScrubberContainer.AddChild(control);
}

View File

@@ -19,7 +19,7 @@
<OptionButton Name="CPressureCheck" />
</BoxContainer>
</BoxContainer>
<!-- Lower row: pressure bounds -->
<!-- Lower row: pressure bounds, copy settings -->
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Text="{Loc 'air-alarm-ui-vent-external-bound-label'}" Margin="0 0 0 1" />
@@ -30,6 +30,9 @@
<FloatSpinBox Name="CInternalBound" HorizontalExpand="True" />
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin ="0 0 0 2">
<Button Name="CCopySettings" Text="{Loc 'air-alarm-ui-widget-copy'}" ToolTip="{Loc 'air-alarm-ui-widget-copy-tooltip'}" />
</BoxContainer>
</BoxContainer>
</CollapsibleBody>
</Collapsible>

View File

@@ -17,6 +17,7 @@ public sealed partial class PumpControl : BoxContainer
private string _address;
public event Action<string, IAtmosDeviceData>? PumpDataChanged;
public event Action<IAtmosDeviceData>? PumpDataCopied;
private CheckBox _enabled => CEnableDevice;
private CollapsibleHeading _addressLabel => CAddress;
@@ -24,6 +25,7 @@ public sealed partial class PumpControl : BoxContainer
private OptionButton _pressureCheck => CPressureCheck;
private FloatSpinBox _externalBound => CExternalBound;
private FloatSpinBox _internalBound => CInternalBound;
private Button _copySettings => CCopySettings;
public PumpControl(GasVentPumpData data, string address)
{
@@ -84,6 +86,11 @@ public sealed partial class PumpControl : BoxContainer
_data.PressureChecks = (VentPressureBound) args.Id;
PumpDataChanged?.Invoke(_address, _data);
};
_copySettings.OnPressed += _ =>
{
PumpDataCopied?.Invoke(_data);
};
}
public void ChangeData(GasVentPumpData data)

View File

@@ -8,7 +8,7 @@
<BoxContainer Orientation="Horizontal" Margin="0 0 0 2">
<CheckBox Name="CEnableDevice" Text="{Loc 'air-alarm-ui-widget-enable'}" />
</BoxContainer>
<!-- Upper row: toggle, direction, volume rate, widenet -->
<!-- Upper row: toggle, direction, volume rate, widenet, copy settings -->
<BoxContainer Orientation="Horizontal" Margin="0 0 0 2" HorizontalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Text="{Loc 'air-alarm-ui-scrubber-pump-direction-label'}" Margin="0 0 0 1"/>
@@ -22,6 +22,9 @@
<BoxContainer>
<CheckBox Name="CWideNet" Text="{Loc 'air-alarm-ui-scrubber-wide-net-label'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin ="0 0 0 2">
<Button Name="CCopySettings" Text="{Loc 'air-alarm-ui-widget-copy'}" ToolTip="{Loc 'air-alarm-ui-widget-copy-tooltip'}" />
</BoxContainer>
<!-- Lower row: every single gas -->
<Collapsible Orientation="Vertical" Margin="2 2 2 2">
<CollapsibleHeading Title="Gas filters" />

View File

@@ -20,12 +20,14 @@ public sealed partial class ScrubberControl : BoxContainer
private string _address;
public event Action<string, IAtmosDeviceData>? ScrubberDataChanged;
public event Action<IAtmosDeviceData>? ScrubberDataCopied;
private CheckBox _enabled => CEnableDevice;
private CollapsibleHeading _addressLabel => CAddress;
private OptionButton _pumpDirection => CPumpDirection;
private FloatSpinBox _volumeRate => CVolumeRate;
private CheckBox _wideNet => CWideNet;
private Button _copySettings => CCopySettings;
private GridContainer _gases => CGasContainer;
private Dictionary<Gas, Button> _gasControls = new();
@@ -75,6 +77,11 @@ public sealed partial class ScrubberControl : BoxContainer
_data.PumpDirection = (ScrubberPumpDirection) args.Id;
ScrubberDataChanged?.Invoke(_address, _data);
};
_copySettings.OnPressed += _ =>
{
ScrubberDataCopied?.Invoke(_data);
};
foreach (var value in Enum.GetValues<Gas>())
{