Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -5,12 +5,13 @@ namespace Content.Client.Atmos.UI
{
public sealed class GasAnalyzerBoundUserInterface : BoundUserInterface
{
public GasAnalyzerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasAnalyzerWindow? _window;
public GasAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private GasAnalyzerWindow? _window;
protected override void Open()
{
base.Open();

View File

@@ -1,7 +1,6 @@
using Content.Shared.Atmos.Piping.Binary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -11,10 +10,10 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasCanisterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasCanisterWindow? _window;
public GasCanisterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasCanisterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -24,7 +23,7 @@ namespace Content.Client.Atmos.UI
_window = new GasCanisterWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -12,10 +12,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasFilterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private const float MaxTransferRate = Atmospherics.MaxTransferRate;
[ViewVariables]
private GasFilterWindow? _window;
public GasFilterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasFilterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -23,11 +26,11 @@ namespace Content.Client.Atmos.UI
{
base.Open();
var atmosSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
var atmosSystem = EntMan.System<AtmosphereSystem>();
_window = new GasFilterWindow(atmosSystem.Gases);
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -81,7 +84,7 @@ namespace Content.Client.Atmos.UI
_window.SetTransferRate(cast.TransferRate);
if (cast.FilteredGas is not null)
{
var atmos = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
var atmos = EntMan.System<AtmosphereSystem>();
var gas = atmos.GetGas((Gas) cast.FilteredGas);
var gasName = Loc.GetString(gas.Name);
_window.SetGasFiltered(gas.ID, gasName);

View File

@@ -1,11 +1,7 @@
using System;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Trinary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -15,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasMixerBoundUserInterface : BoundUserInterface
{
private GasMixerWindow? _window;
[ViewVariables]
private const float MaxPressure = Atmospherics.MaxOutputPressure;
public GasMixerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasMixerWindow? _window;
public GasMixerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -29,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasMixerWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -49,8 +47,9 @@ namespace Content.Client.Atmos.UI
private void OnMixerOutputPressurePressed(string value)
{
float pressure = float.TryParse(value, out var parsed) ? parsed : 0f;
if (pressure > MaxPressure) pressure = MaxPressure;
var pressure = float.TryParse(value, out var parsed) ? parsed : 0f;
if (pressure > MaxPressure)
pressure = MaxPressure;
SendMessage(new GasMixerChangeOutputPressureMessage(pressure));
}
@@ -58,11 +57,12 @@ namespace Content.Client.Atmos.UI
private void OnMixerSetPercentagePressed(string value)
{
// We don't need to send both nodes because it's just 100.0f - node
float node = float.TryParse(value, out var parsed) ? parsed : 1.0f;
var node = float.TryParse(value, out var parsed) ? parsed : 1.0f;
node = Math.Clamp(node, 0f, 100.0f);
if (_window is not null) node = _window.NodeOneLastEdited ? node : 100.0f - node;
if (_window is not null)
node = _window.NodeOneLastEdited ? node : 100.0f - node;
SendMessage(new GasMixerChangeNodePercentageMessage(node));
}

View File

@@ -1,11 +1,7 @@
using System;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Trinary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -15,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasPressurePumpBoundUserInterface : BoundUserInterface
{
private GasPressurePumpWindow? _window;
[ViewVariables]
private const float MaxPressure = Atmospherics.MaxOutputPressure;
public GasPressurePumpBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasPressurePumpWindow? _window;
public GasPressurePumpBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -29,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasPressurePumpWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -1,9 +1,6 @@
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Piping.Unary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -13,12 +10,16 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasThermomachineBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasThermomachineWindow? _window;
[ViewVariables]
private float _minTemp = 0.0f;
[ViewVariables]
private float _maxTemp = 0.0f;
public GasThermomachineBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasThermomachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -28,7 +29,7 @@ namespace Content.Client.Atmos.UI
_window = new GasThermomachineWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -2,7 +2,6 @@
using Content.Shared.Atmos.Piping.Binary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -12,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasVolumePumpBoundUserInterface : BoundUserInterface
{
private GasVolumePumpWindow? _window;
[ViewVariables]
private const float MaxTransferRate = Atmospherics.MaxTransferRate;
public GasVolumePumpBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasVolumePumpWindow? _window;
public GasVolumePumpBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -26,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasVolumePumpWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -45,8 +46,9 @@ namespace Content.Client.Atmos.UI
private void OnPumpTransferRatePressed(string value)
{
float rate = float.TryParse(value, out var parsed) ? parsed : 0f;
if (rate > MaxTransferRate) rate = MaxTransferRate;
var rate = float.TryParse(value, out var parsed) ? parsed : 0f;
if (rate > MaxTransferRate)
rate = MaxTransferRate;
SendMessage(new GasVolumePumpChangeTransferRateMessage(rate));
}