Cleaner BoundUserInterfaces (#17736)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user