Delta-v/Content.Client/Atmos/UI/GasVolumePumpWindow.xaml.cs

56 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using Content.Client.Atmos.EntitySystems;
using Content.Client.UserInterface.Controls;
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 sealed partial class GasVolumePumpWindow : FancyWindow
{
public event Action<bool>? ToggleStatusButtonPressed;
public event Action<string>? PumpTransferRateChanged;
public GasVolumePumpWindow()
{
RobustXamlLoader.Load(this);
ToggleStatusButton.OnToggled += _ => ToggleStatusButtonPressed?.Invoke(ToggleStatusButton.Pressed);
PumpTransferRateInput.OnTextChanged += _ => SetTransferRateButton.Disabled = false;
SetTransferRateButton.OnPressed += _ =>
{
PumpTransferRateChanged?.Invoke(PumpTransferRateInput.Text ??= "");
SetTransferRateButton.Disabled = true;
};
SetMaxRateButton.OnPressed += _ =>
{
PumpTransferRateInput.Text = Atmospherics.MaxTransferRate.ToString(CultureInfo.CurrentCulture);
SetTransferRateButton.Disabled = false;
};
}
public void SetTransferRate(float rate)
{
PumpTransferRateInput.Text = rate.ToString(CultureInfo.CurrentCulture);
}
public void SetPumpStatus(bool enabled)
{
ToggleStatusButton.Pressed = enabled;
}
}
}