mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
* Change 'Departamental' to 'Departmental' * Undo typo fixes for comments * Add pipe layering * Add the pressure release valve * Add the pressure release valve * Fix the gas pump * Fix the signal valve appearing thrice * Fix the signal valve appearing thrice --------- Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com> Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using Content.Shared.Atmos.Piping.Binary.Components;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Localizations;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Atmos.UI;
|
|
|
|
public sealed class GasPressureRegulatorBoundUserInterface(EntityUid owner, Enum uiKey)
|
|
: BoundUserInterface(owner, uiKey)
|
|
{
|
|
private GasPressureRegulatorWindow? _window;
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<GasPressureRegulatorWindow>();
|
|
|
|
_window.SetEntity(Owner);
|
|
|
|
_window.ThresholdPressureChanged += OnThresholdChanged;
|
|
|
|
if (EntMan.TryGetComponent(Owner, out GasPressureRegulatorComponent? comp))
|
|
_window.SetThresholdPressureInput(comp.Threshold);
|
|
|
|
Update();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
if (_window == null)
|
|
return;
|
|
|
|
_window.Title = Identity.Name(Owner, EntMan);
|
|
|
|
if (!EntMan.TryGetComponent(Owner, out GasPressureRegulatorComponent? comp))
|
|
return;
|
|
|
|
_window.SetThresholdPressureLabel(comp.Threshold);
|
|
_window.UpdateInfo(comp.InletPressure, comp.OutletPressure, comp.FlowRate);
|
|
}
|
|
|
|
private void OnThresholdChanged(string newThreshold)
|
|
{
|
|
var sentThreshold = 0f;
|
|
|
|
if (UserInputParser.TryFloat(newThreshold, out var parsedNewThreshold) && parsedNewThreshold >= 0 &&
|
|
!float.IsInfinity(parsedNewThreshold))
|
|
{
|
|
sentThreshold = parsedNewThreshold;
|
|
}
|
|
|
|
// Autofill to zero if the user inputs an invalid value.
|
|
_window?.SetThresholdPressureInput(sentThreshold);
|
|
|
|
SendPredictedMessage(new GasPressureRegulatorChangeThresholdMessage(sentThreshold));
|
|
}
|
|
}
|