2022-06-28 22:54:08 +10:00
|
|
|
using Content.Shared.Research.Components;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Content.Shared.Research.Prototypes;
|
2021-03-10 14:48:29 +01:00
|
|
|
using JetBrains.Annotations;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Robust.Client.UserInterface;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
namespace Content.Client.Research.UI;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
[UsedImplicitly]
|
|
|
|
|
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
|
|
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
[ViewVariables]
|
2023-05-15 16:17:30 -04:00
|
|
|
private ResearchConsoleMenu? _consoleMenu;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
public ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
2023-05-15 16:17:30 -04:00
|
|
|
{
|
|
|
|
|
}
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
var owner = Owner;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
_consoleMenu = this.CreateWindow<ResearchConsoleMenu>();
|
|
|
|
|
_consoleMenu.SetEntity(owner);
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
_consoleMenu.OnTechnologyCardPressed += id =>
|
2019-09-03 22:51:19 +02:00
|
|
|
{
|
2023-05-15 16:17:30 -04:00
|
|
|
SendMessage(new ConsoleUnlockTechnologyMessage(id));
|
|
|
|
|
};
|
2022-12-20 17:39:57 -05:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
_consoleMenu.OnServerButtonPressed += () =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new ConsoleServerSelectionMessage());
|
|
|
|
|
};
|
2024-07-21 14:48:13 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnProtoReload(PrototypesReloadedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
base.OnProtoReload(args);
|
|
|
|
|
|
|
|
|
|
if (!args.WasModified<TechnologyPrototype>())
|
|
|
|
|
return;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
if (State is not ResearchConsoleBoundInterfaceState rState)
|
|
|
|
|
return;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
_consoleMenu?.UpdatePanels(rState);
|
|
|
|
|
_consoleMenu?.UpdateInformationPanel(rState);
|
2023-05-15 16:17:30 -04:00
|
|
|
}
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
|
|
|
{
|
|
|
|
|
base.UpdateState(state);
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2023-05-15 16:17:30 -04:00
|
|
|
if (state is not ResearchConsoleBoundInterfaceState castState)
|
|
|
|
|
return;
|
|
|
|
|
_consoleMenu?.UpdatePanels(castState);
|
|
|
|
|
_consoleMenu?.UpdateInformationPanel(castState);
|
|
|
|
|
}
|
2019-09-03 22:51:19 +02:00
|
|
|
}
|