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,6 @@
using Content.Shared.SprayPainter;
using Content.Shared.SprayPainter.Components;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.SprayPainter.UI;
@@ -10,9 +10,6 @@ public sealed class SprayPainterBoundUserInterface : BoundUserInterface
[ViewVariables]
private SprayPainterWindow? _window;
[ViewVariables]
private SprayPainterSystem? _painter;
public SprayPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -21,27 +18,15 @@ public sealed class SprayPainterBoundUserInterface : BoundUserInterface
{
base.Open();
if (!EntMan.TryGetComponent<SprayPainterComponent>(Owner, out var comp))
return;
_window = this.CreateWindow<SprayPainterWindow>();
_window = new SprayPainterWindow();
_painter = EntMan.System<SprayPainterSystem>();
_window.OnClose += Close;
_window.OnSpritePicked = OnSpritePicked;
_window.OnColorPicked = OnColorPicked;
_window.Populate(_painter.Entries, comp.Index, comp.PickedColor, comp.ColorPalette);
_window.OpenCentered();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Dispose();
if (EntMan.TryGetComponent(Owner, out SprayPainterComponent? comp))
{
_window.Populate(EntMan.System<SprayPainterSystem>().Entries, comp.Index, comp.PickedColor, comp.ColorPalette);
}
}
private void OnSpritePicked(ItemList.ItemListSelectedEventArgs args)