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.Client.NetworkConfigurator.Systems;
using Content.Shared.DeviceNetwork;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.NetworkConfigurator;
@@ -35,14 +36,12 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
switch (UiKey)
{
case NetworkConfiguratorUiKey.List:
_listMenu = new NetworkConfiguratorListMenu(this);
_listMenu.OnClose += Close;
_listMenu = this.CreateWindow<NetworkConfiguratorListMenu>();
_listMenu.ClearButton.OnPressed += _ => OnClearButtonPressed();
_listMenu.OpenCenteredRight();
_listMenu.OnRemoveAddress += OnRemoveButtonPressed;
break;
case NetworkConfiguratorUiKey.Configure:
_configurationMenu = new NetworkConfiguratorConfigurationMenu();
_configurationMenu.OnClose += Close;
_configurationMenu = this.CreateWindow<NetworkConfiguratorConfigurationMenu>();
_configurationMenu.Set.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Set);
_configurationMenu.Add.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Add);
//_configurationMenu.Edit.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Edit);
@@ -50,12 +49,24 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
_configurationMenu.Copy.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Copy);
_configurationMenu.Show.OnPressed += OnShowPressed;
_configurationMenu.Show.Pressed = _netConfig.ConfiguredListIsTracked(Owner);
_configurationMenu.OpenCentered();
_configurationMenu.OnRemoveAddress += OnRemoveButtonPressed;
break;
case NetworkConfiguratorUiKey.Link:
_linkMenu = new NetworkConfiguratorLinkMenu(this);
_linkMenu.OnClose += Close;
_linkMenu.OpenCentered();
_linkMenu = this.CreateWindow<NetworkConfiguratorLinkMenu>();
_linkMenu.OnLinkDefaults += args =>
{
SendMessage(new NetworkConfiguratorLinksSaveMessage(args));
};
_linkMenu.OnToggleLink += (left, right) =>
{
SendMessage(new NetworkConfiguratorToggleLinkMessage(left, right));
};
_linkMenu.OnClearLinks += () =>
{
SendMessage(new NetworkConfiguratorClearLinksMessage());
};
break;
}
}
@@ -83,16 +94,6 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_linkMenu?.Dispose();
_listMenu?.Dispose();
_configurationMenu?.Dispose();
}
private void OnClearButtonPressed()
{
SendMessage(new NetworkConfiguratorClearDevicesMessage());