number of things, fixing warnings, AtmosAlarmType instead of AtmosMonitorAlarmType

This commit is contained in:
vulppine
2022-08-29 07:37:26 -07:00
parent cb5ffe0f3d
commit e0bf77490d
24 changed files with 177 additions and 148 deletions

View File

@@ -9,7 +9,7 @@ public sealed class AtmosAlarmableVisualsComponent : Component
public string LayerMap { get; } = string.Empty;
[DataField("alarmStates")]
public readonly Dictionary<AtmosMonitorAlarmType, string> AlarmStates = new();
public readonly Dictionary<AtmosAlarmType, string> AlarmStates = new();
[DataField("hideOnDepowered")]
public readonly List<string>? HideOnDepowered;

View File

@@ -14,27 +14,39 @@ public sealed class AtmosAlarmableVisualsSystem : VisualizerSystem<AtmosAlarmabl
{
protected override void OnAppearanceChange(EntityUid uid, AtmosAlarmableVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null || !args.Sprite.LayerMapTryGet(component.LayerMap, out int layer))
if (args.Sprite == null || !args.Sprite.LayerMapTryGet(component.LayerMap, out var layer))
return;
if (args.AppearanceData.TryGetValue(PowerDeviceVisuals.Powered, out var poweredObject)
&& poweredObject is bool powered)
if (!args.AppearanceData.TryGetValue(PowerDeviceVisuals.Powered, out var poweredObject) ||
poweredObject is not bool powered)
{
if (component.HideOnDepowered != null)
foreach (var visLayer in component.HideOnDepowered)
if (args.Sprite.LayerMapTryGet(visLayer, out int powerVisibilityLayer))
args.Sprite.LayerSetVisible(powerVisibilityLayer, powered);
return;
}
if (component.SetOnDepowered != null && !powered)
foreach (var (setLayer, powerState) in component.SetOnDepowered)
if (args.Sprite.LayerMapTryGet(setLayer, out int setStateLayer))
args.Sprite.LayerSetState(setStateLayer, new RSI.StateId(powerState));
if (component.HideOnDepowered != null)
{
foreach (var visLayer in component.HideOnDepowered)
{
if (args.Sprite.LayerMapTryGet(visLayer, out int powerVisibilityLayer))
args.Sprite.LayerSetVisible(powerVisibilityLayer, powered);
}
}
if (args.AppearanceData.TryGetValue(AtmosMonitorVisuals.AlarmType, out var alarmTypeObject)
&& alarmTypeObject is AtmosMonitorAlarmType alarmType
&& powered
&& component.AlarmStates.TryGetValue(alarmType, out var state))
args.Sprite.LayerSetState(layer, new RSI.StateId(state));
if (component.SetOnDepowered != null && !powered)
{
foreach (var (setLayer, powerState) in component.SetOnDepowered)
{
if (args.Sprite.LayerMapTryGet(setLayer, out int setStateLayer))
args.Sprite.LayerSetState(setStateLayer, new RSI.StateId(powerState));
}
}
if (args.AppearanceData.TryGetValue(AtmosMonitorVisuals.AlarmType, out var alarmTypeObject)
&& alarmTypeObject is AtmosAlarmType alarmType
&& powered
&& component.AlarmStates.TryGetValue(alarmType, out var state))
{
args.Sprite.LayerSetState(layer, new RSI.StateId(state));
}
}
}

View File

@@ -13,7 +13,8 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
private AirAlarmWindow? _window;
public AirAlarmBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{}
{
}
protected override void Open()
{
@@ -21,7 +22,10 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
_window = new AirAlarmWindow();
if (State != null) UpdateState(State);
if (State != null)
{
UpdateState(State);
}
_window.OpenCentered();

View File

@@ -50,7 +50,9 @@ public sealed partial class AirAlarmWindow : DefaultWindow
RobustXamlLoader.Load(this);
foreach (var mode in Enum.GetValues<AirAlarmMode>())
{
_modes.AddItem($"{mode}", (int) mode);
}
_modes.OnItemSelected += args =>
{

View File

@@ -29,7 +29,7 @@ public sealed partial class PumpControl : BoxContainer
{
RobustXamlLoader.Load(this);
this.Name = address;
Name = address;
_data = data;
_address = address;
@@ -60,7 +60,9 @@ public sealed partial class PumpControl : BoxContainer
_externalBound.IsValid += value => value >= 0;
foreach (var value in Enum.GetValues<VentPumpDirection>())
{
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value);
}
_pumpDirection.SelectId((int) _data.PumpDirection);
_pumpDirection.OnItemSelected += args =>
@@ -71,7 +73,9 @@ public sealed partial class PumpControl : BoxContainer
};
foreach (var value in Enum.GetValues<VentPressureBound>())
{
_pressureCheck.AddItem(Loc.GetString($"{value}"), (int) value);
}
_pressureCheck.SelectId((int) _data.PressureChecks);
_pressureCheck.OnItemSelected += args =>

View File

@@ -34,7 +34,7 @@ public sealed partial class ScrubberControl : BoxContainer
{
RobustXamlLoader.Load(this);
this.Name = address;
Name = address;
_data = data;
_address = address;
@@ -64,7 +64,9 @@ public sealed partial class ScrubberControl : BoxContainer
_volumeRate.IsValid += value => value >= 0;
foreach (var value in Enum.GetValues<ScrubberPumpDirection>())
{
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value);
}
_pumpDirection.SelectId((int) _data.PumpDirection);
_pumpDirection.OnItemSelected += args =>
@@ -116,7 +118,9 @@ public sealed partial class ScrubberControl : BoxContainer
var intersect = _data.FilterGases.Intersect(data.FilterGases);
foreach (var value in Enum.GetValues<Gas>())
{
if (!intersect.Contains(value))
_gasControls[value].Pressed = false;
}
}
}

View File

@@ -208,18 +208,18 @@ public sealed partial class ThresholdControl : BoxContainer
_modifier = modifier > 0 ? modifier : 1;
_value = value;
this.HorizontalExpand = true;
this.Orientation = LayoutOrientation.Vertical;
HorizontalExpand = true;
Orientation = LayoutOrientation.Vertical;
this.AddChild(new Label { Text = Loc.GetString($"air-alarm-ui-thresholds-{name}") });
AddChild(new Label { Text = Loc.GetString($"air-alarm-ui-thresholds-{name}") });
_bound = new FloatSpinBox(.01f, 2);
this.AddChild(_bound);
AddChild(_bound);
_boundEnabled = new CheckBox
{
Text = Loc.GetString("Enabled")
};
this.AddChild(_boundEnabled);
AddChild(_boundEnabled);
_bound.Value = ModifiedValue ?? 0;
_lastValue = _value ?? 0;
@@ -289,7 +289,9 @@ public sealed partial class ThresholdControl : BoxContainer
OnValidBoundChanged!.Invoke();
}
private bool ValidateThreshold(float value) => (_value != null) && (value >= 0);
private bool ValidateThreshold(float value)
{
return _value != null && value >= 0;
}
}
}