* 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
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using Content.Shared.Research.Components;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Research.UI
|
|
{
|
|
public sealed class ResearchClientBoundUserInterface : BoundUserInterface
|
|
{
|
|
[ViewVariables]
|
|
private ResearchClientServerSelectionMenu? _menu;
|
|
|
|
public ResearchClientBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
SendMessage(new ResearchClientSyncMessage());
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
_menu = this.CreateWindow<ResearchClientServerSelectionMenu>();
|
|
_menu.OnServerSelected += SelectServer;
|
|
_menu.OnServerDeselected += DeselectServer;
|
|
}
|
|
|
|
public void SelectServer(int serverId)
|
|
{
|
|
SendMessage(new ResearchClientServerSelectedMessage(serverId));
|
|
}
|
|
|
|
public void DeselectServer()
|
|
{
|
|
SendMessage(new ResearchClientServerDeselectedMessage());
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
if (state is not ResearchClientBoundInterfaceState rState) return;
|
|
_menu?.Populate(rState.ServerCount, rState.ServerNames, rState.ServerIds, rState.SelectedServerId);
|
|
}
|
|
}
|
|
}
|