Files
tbd-station-14/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.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

63 lines
1.6 KiB
C#

using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
namespace Content.Client.Research.UI;
[UsedImplicitly]
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ResearchConsoleMenu? _consoleMenu;
public ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
var owner = Owner;
_consoleMenu = this.CreateWindow<ResearchConsoleMenu>();
_consoleMenu.SetEntity(owner);
_consoleMenu.OnTechnologyCardPressed += id =>
{
SendMessage(new ConsoleUnlockTechnologyMessage(id));
};
_consoleMenu.OnServerButtonPressed += () =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
}
public override void OnProtoReload(PrototypesReloadedEventArgs args)
{
base.OnProtoReload(args);
if (!args.WasModified<TechnologyPrototype>())
return;
if (State is not ResearchConsoleBoundInterfaceState rState)
return;
_consoleMenu?.UpdatePanels(rState);
_consoleMenu?.UpdateInformationPanel(rState);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not ResearchConsoleBoundInterfaceState castState)
return;
_consoleMenu?.UpdatePanels(castState);
_consoleMenu?.UpdateInformationPanel(castState);
}
}