Files
space-station-14/Content.Client/Nuke/NukeBoundUserInterface.cs
metalgearsloth cbf329a82d 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
2024-07-20 15:40:16 +10:00

66 lines
1.7 KiB
C#

using Content.Shared.Containers.ItemSlots;
using Content.Shared.Nuke;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
namespace Content.Client.Nuke
{
[UsedImplicitly]
public sealed class NukeBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private NukeMenu? _menu;
public NukeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
_menu = this.CreateWindow<NukeMenu>();
_menu.OnKeypadButtonPressed += i =>
{
SendMessage(new NukeKeypadMessage(i));
};
_menu.OnEnterButtonPressed += () =>
{
SendMessage(new NukeKeypadEnterMessage());
};
_menu.OnClearButtonPressed += () =>
{
SendMessage(new NukeKeypadClearMessage());
};
_menu.EjectButton.OnPressed += _ =>
{
SendMessage(new ItemSlotButtonPressedEvent(SharedNukeComponent.NukeDiskSlotId));
};
_menu.AnchorButton.OnPressed += _ =>
{
SendMessage(new NukeAnchorMessage());
};
_menu.ArmButton.OnPressed += _ =>
{
SendMessage(new NukeArmedMessage());
};
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_menu == null)
return;
switch (state)
{
case NukeUiState msg:
_menu.UpdateState(msg);
break;
}
}
}
}