fish-station/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.cs
Fildrance 1f2d80297c
feat: RnD tech research console now have reroll feature (#32931)
* feat: RnD tech research console now have reroll feature

* fix: disable Rediscover button when there is not enough currency or user have no access

* refactor: xml-doc, extract method, minor simplify xaml

* minor cleanup after review

* refactor: change sending research server points amount into BUI from state to  ResearchServerComponent (using AfterAutoHandleStateEvent)

* feat: now tech rerolls will have cooldown to ensure no one can spam-spend all dept budget instantly

* refactor: revert unneeded code

* refactor: whitespaces

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-12-18 21:06:24 +00:00

62 lines
1.7 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(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[ViewVariables]
private ResearchConsoleMenu? _consoleMenu;
protected override void Open()
{
base.Open();
_consoleMenu = this.CreateWindow<ResearchConsoleMenu>();
_consoleMenu.SetEntity(Owner);
_consoleMenu.OnTechnologyRediscoverPressed += () =>
{
SendMessage(new ConsoleRediscoverTechnologyMessage());
};
_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);
}
}