Remove some BUI boilerplate (#28399)

* Remove some BUI boilerplate

- The disposals overrides got removed due to the helper method handling it.
- Replace window creation with CreateWindow helper.
- Fixed some stinky code which would cause exceptions.

* More

* moar

* weh

* done

* More BUIs

* More updates

* weh

* moar

* look who it is

* weh

* merge

* weh

* fixes
This commit is contained in:
metalgearsloth
2024-07-20 15:40:16 +10:00
committed by GitHub
parent 4aba9ec131
commit cbf329a82d
137 changed files with 1094 additions and 1753 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Kitchen;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Prototypes;
@@ -8,8 +9,6 @@ namespace Content.Client.Kitchen.UI
{
public sealed class ReagentGrinderBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[ViewVariables]
private GrinderMenu? _menu;
@@ -21,20 +20,13 @@ namespace Content.Client.Kitchen.UI
{
base.Open();
_menu = new GrinderMenu(this, EntMan, _prototypeManager);
_menu.OpenCentered();
_menu.OnClose += Close;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
{
return;
}
_menu?.Dispose();
_menu = this.CreateWindow<GrinderMenu>();
_menu.OnToggleAuto += ToggleAutoMode;
_menu.OnGrind += StartGrinding;
_menu.OnJuice += StartJuicing;
_menu.OnEjectAll += EjectAll;
_menu.OnEjectBeaker += EjectBeaker;
_menu.OnEjectChamber += EjectChamberContent;
}
protected override void UpdateState(BoundUserInterfaceState state)
@@ -52,27 +44,27 @@ namespace Content.Client.Kitchen.UI
_menu?.HandleMessage(message);
}
public void ToggleAutoMode(BaseButton.ButtonEventArgs args)
public void ToggleAutoMode()
{
SendMessage(new ReagentGrinderToggleAutoModeMessage());
}
public void StartGrinding(BaseButton.ButtonEventArgs? _ = null)
public void StartGrinding()
{
SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Grind));
}
public void StartJuicing(BaseButton.ButtonEventArgs? _ = null)
public void StartJuicing()
{
SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Juice));
}
public void EjectAll(BaseButton.ButtonEventArgs? _ = null)
public void EjectAll()
{
SendMessage(new ReagentGrinderEjectChamberAllMessage());
}
public void EjectBeaker(BaseButton.ButtonEventArgs? _ = null)
public void EjectBeaker()
{
SendMessage(new ItemSlotButtonPressedEvent(SharedReagentGrinder.BeakerSlotId));
}