Reapply "Remove some BUI boilerplate" (#30214) (#30219)

* Reapply "Remove some BUI boilerplate" (#30214)

This reverts commit cb0ba66be3.

* Fix gas tank

* Fix PA

* Fix microwave

* Comms console underwrap

* Fix rcd

* log wehs
This commit is contained in:
metalgearsloth
2024-07-21 14:48:13 +10:00
committed by GitHub
parent 87e52e50b4
commit edb05e36bb
137 changed files with 1102 additions and 1757 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Client.UserInterface;
using Content.Shared.Ame.Components;
using Robust.Client.AutoGenerated;
@@ -9,15 +10,17 @@ namespace Content.Client.Ame.UI
[GenerateTypedNameReferences]
public sealed partial class AmeWindow : DefaultWindow
{
public AmeWindow(AmeControllerBoundUserInterface ui)
public event Action<UiButton>? OnAmeButton;
public AmeWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
EjectButton.OnPressed += _ => ui.ButtonPressed(UiButton.Eject);
ToggleInjection.OnPressed += _ => ui.ButtonPressed(UiButton.ToggleInjection);
IncreaseFuelButton.OnPressed += _ => ui.ButtonPressed(UiButton.IncreaseFuel);
DecreaseFuelButton.OnPressed += _ => ui.ButtonPressed(UiButton.DecreaseFuel);
EjectButton.OnPressed += _ => OnAmeButton?.Invoke(UiButton.Eject);
ToggleInjection.OnPressed += _ => OnAmeButton?.Invoke(UiButton.ToggleInjection);
IncreaseFuelButton.OnPressed += _ => OnAmeButton?.Invoke(UiButton.IncreaseFuel);
DecreaseFuelButton.OnPressed += _ => OnAmeButton?.Invoke(UiButton.DecreaseFuel);
}
/// <summary>
@@ -29,7 +32,7 @@ namespace Content.Client.Ame.UI
var castState = (AmeControllerBoundUserInterfaceState) state;
// Disable all buttons if not powered
if (Contents.Children != null)
if (Contents.Children.Any())
{
ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower);
EjectButton.Disabled = false;
@@ -65,8 +68,8 @@ namespace Content.Client.Ame.UI
CoreCount.Text = $"{castState.CoreCount}";
InjectionAmount.Text = $"{castState.InjectionAmount}";
// format power statistics to pretty numbers
CurrentPowerSupply.Text = $"{castState.CurrentPowerSupply.ToString("N1")}";
TargetedPowerSupply.Text = $"{castState.TargetedPowerSupply.ToString("N1")}";
CurrentPowerSupply.Text = $"{castState.CurrentPowerSupply:N1}";
TargetedPowerSupply.Text = $"{castState.TargetedPowerSupply:N1}";
}
}
}