mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* commit * also flipped * oops * fuck it added to the UI * fix micro annoyance * Unify components also doesn't work yet * reuse the existing UI also clean up the UI also applying state headache * cheat code * flippy * More interface changes * yaml ;p * private tagger * betterer tagger * private unit window * limit tagger window * access blocked * typo * validate --------- Co-authored-by: iaada <iaada@users.noreply.github.com>
90 lines
2.8 KiB
C#
90 lines
2.8 KiB
C#
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Disposal.Components;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Disposal.Unit
|
|
{
|
|
/// <summary>
|
|
/// Client-side UI used to control a <see cref="Shared.Disposal.Components.DisposalUnitComponent"/>
|
|
/// </summary>
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class DisposalUnitWindow : FancyWindow
|
|
{
|
|
// Values for managing the pressure bar
|
|
private TimeSpan _fullPressure;
|
|
private float _pressurePerSecond;
|
|
|
|
public event Action<DisposalUnitUiButton>? OnTogglePower;
|
|
public event Action<DisposalUnitUiButton>? OnEject;
|
|
public event Action<DisposalUnitUiButton>? OnEngage;
|
|
public event Action? OnChangeRouting;
|
|
|
|
public DisposalUnitWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
Power.OnPressed += args => TogglePower(args.Button.Pressed);
|
|
Eject.OnPressed += _ => BeginEject();
|
|
Engage.OnPressed += _ => BeginEngage();
|
|
Routing.OnPressed += _ => ChangeRouting();
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
PressureBar.UpdatePressure(_fullPressure, _pressurePerSecond);
|
|
}
|
|
|
|
public void Populate(bool powered, bool engaged, DisposalsPressureState disposalState, TimeSpan fullPressure, float pressurePerSecond)
|
|
{
|
|
ToggleUnitStateText(powered);
|
|
UnitState.Text = Loc.GetString($"disposal-unit-state-{disposalState}");
|
|
|
|
_fullPressure = fullPressure;
|
|
_pressurePerSecond = pressurePerSecond;
|
|
|
|
Power.Pressed = powered;
|
|
Engage.Pressed = engaged;
|
|
}
|
|
|
|
public void PopulateRouting(bool editable, bool accessible)
|
|
{
|
|
Routing.Visible = editable;
|
|
|
|
Routing.Disabled = !accessible;
|
|
Routing.ToolTip = accessible ? null : Loc.GetString("generic-no-access");
|
|
}
|
|
|
|
/// <summary>
|
|
/// This trick is used to hide power being unpredicted so the UI feels responsive.
|
|
/// </summary>
|
|
private void ToggleUnitStateText(bool powered)
|
|
{
|
|
UnitState.Visible = powered;
|
|
UnitStateUnpowered.Visible = !powered;
|
|
}
|
|
|
|
private void TogglePower(bool powered)
|
|
{
|
|
ToggleUnitStateText(powered);
|
|
OnTogglePower?.Invoke(DisposalUnitUiButton.Power);
|
|
}
|
|
|
|
private void BeginEject()
|
|
{
|
|
OnEject?.Invoke(DisposalUnitUiButton.Eject);
|
|
}
|
|
|
|
private void BeginEngage()
|
|
{
|
|
OnEngage?.Invoke(DisposalUnitUiButton.Engage);
|
|
}
|
|
|
|
private void ChangeRouting()
|
|
{
|
|
OnChangeRouting?.Invoke();
|
|
}
|
|
}
|
|
}
|