mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-06-09 10:06:46 +02:00
118b83165b
* Switch button for gas filter power * Switch button for gas mixer power * Switch button for gas pump power * Switch button for thermomachine power * Switch button for space heater power * Remove redundant switch labels
63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Atmos;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Atmos.UI
|
|
{
|
|
/// <summary>
|
|
/// Client-side UI used to control a gas pressure pump.
|
|
/// </summary>
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class GasPressurePumpWindow : FancyWindow
|
|
{
|
|
public event Action<bool>? ToggleStatusButtonPressed;
|
|
public event Action<float>? PumpOutputPressureChanged;
|
|
|
|
public float MaxPressure
|
|
{
|
|
get => _maxPressure;
|
|
set
|
|
{
|
|
_maxPressure = value;
|
|
|
|
PumpPressureOutputInput.Value = MathF.Min(value, PumpPressureOutputInput.Value);
|
|
}
|
|
}
|
|
|
|
private float _maxPressure = Atmospherics.MaxOutputPressure;
|
|
|
|
public GasPressurePumpWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
ToggleStatusButton.OnToggled += _ => ToggleStatusButtonPressed?.Invoke(ToggleStatusButton.Pressed);
|
|
|
|
PumpPressureOutputInput.OnValueChanged += _ => SetOutputPressureButton.Disabled = false;
|
|
|
|
SetOutputPressureButton.OnPressed += _ =>
|
|
{
|
|
PumpPressureOutputInput.Value = Math.Clamp(PumpPressureOutputInput.Value, 0f, _maxPressure);
|
|
PumpOutputPressureChanged?.Invoke(PumpPressureOutputInput.Value);
|
|
SetOutputPressureButton.Disabled = true;
|
|
};
|
|
|
|
SetMaxPressureButton.OnPressed += _ =>
|
|
{
|
|
PumpPressureOutputInput.Value = _maxPressure;
|
|
SetOutputPressureButton.Disabled = false;
|
|
};
|
|
}
|
|
|
|
public void SetOutputPressure(float pressure)
|
|
{
|
|
PumpPressureOutputInput.Value = pressure;
|
|
}
|
|
|
|
public void SetPumpStatus(bool enabled)
|
|
{
|
|
ToggleStatusButton.Pressed = enabled;
|
|
}
|
|
}
|
|
}
|