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:
65
Content.Client/Atmos/UI/GasVolumePumpWindow.xaml.cs
Normal file
65
Content.Client/Atmos/UI/GasVolumePumpWindow.xaml.cs
Normal 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 volume pump.
|
||||
/// </summary>
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GasVolumePumpWindow : SS14Window
|
||||
{
|
||||
public bool PumpStatus = true;
|
||||
|
||||
public event Action? ToggleStatusButtonPressed;
|
||||
public event Action<string>? PumpTransferRateChanged;
|
||||
|
||||
public GasVolumePumpWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
ToggleStatusButton.OnPressed += _ => SetPumpStatus(!PumpStatus);
|
||||
ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();
|
||||
|
||||
PumpTransferRateInput.OnTextChanged += _ => SetTransferRateButton.Disabled = false;
|
||||
SetTransferRateButton.OnPressed += _ =>
|
||||
{
|
||||
PumpTransferRateChanged?.Invoke(PumpTransferRateInput.Text ??= "");
|
||||
SetTransferRateButton.Disabled = true;
|
||||
};
|
||||
|
||||
SetMaxRateButton.OnPressed += _ =>
|
||||
{
|
||||
PumpTransferRateInput.Text = Atmospherics.MaxTransferRate.ToString(CultureInfo.InvariantCulture);
|
||||
SetTransferRateButton.Disabled = false;
|
||||
};
|
||||
}
|
||||
|
||||
public void SetTransferRate(float rate)
|
||||
{
|
||||
PumpTransferRateInput.Text = rate.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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user