Adds UIs for volume and pressure pumps (#5155)

* Adds UIs for volume and pressure pumps

* Update Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs

* Update Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs

Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
ike709
2021-11-04 19:41:56 -05:00
committed by GitHub
parent b4f0051ca3
commit 17e1b7827e
12 changed files with 532 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Localization;
namespace Content.Client.Atmos.UI
{
/// <summary>
/// Client-side UI used to control a gas pressure pump.
/// </summary>
[GenerateTypedNameReferences]
public partial class GasPressurePumpWindow : SS14Window
{
public bool PumpStatus = true;
public event Action? ToggleStatusButtonPressed;
public event Action<string>? PumpOutputPressureChanged;
public GasPressurePumpWindow()
{
RobustXamlLoader.Load(this);
ToggleStatusButton.OnPressed += _ => SetPumpStatus(!PumpStatus);
ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();
PumpPressureOutputInput.OnTextChanged += _ => SetOutputPressureButton.Disabled = false;
SetOutputPressureButton.OnPressed += _ =>
{
PumpOutputPressureChanged?.Invoke(PumpPressureOutputInput.Text ??= "");
SetOutputPressureButton.Disabled = true;
};
SetMaxPressureButton.OnPressed += _ =>
{
PumpPressureOutputInput.Text = Atmospherics.MaxOutputPressure.ToString(CultureInfo.InvariantCulture);
SetOutputPressureButton.Disabled = false;
};
}
public void SetOutputPressure(float pressure)
{
PumpPressureOutputInput.Text = pressure.ToString(CultureInfo.InvariantCulture);
}
public void SetPumpStatus(bool enabled)
{
PumpStatus = enabled;
if (enabled)
{
ToggleStatusButton.Text = Loc.GetString("comp-gas-pump-ui-status-enabled");
}
else
{
ToggleStatusButton.Text = Loc.GetString("comp-gas-pump-ui-status-disabled");
}
}
}
}