Files
tbd-station-14/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
Nemanja 73e94dfa92 Lathe Categories (#24247)
* Lathe Categories

* serilog my beloathed
2024-01-19 17:45:03 -07:00

63 lines
1.6 KiB
C#

using Content.Shared.Lathe;
using Content.Shared.Research.Components;
using JetBrains.Annotations;
namespace Content.Client.Lathe.UI
{
[UsedImplicitly]
public sealed class LatheBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private LatheMenu? _menu;
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new LatheMenu(this);
_menu.OnClose += Close;
_menu.OnServerListButtonPressed += _ =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
_menu.RecipeQueueAction += (recipe, amount) =>
{
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
};
_menu.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
switch (state)
{
case LatheUpdateState msg:
if (_menu != null)
_menu.Recipes = msg.Recipes;
_menu?.PopulateRecipes();
_menu?.UpdateCategories();
_menu?.PopulateQueueList(msg.Queue);
_menu?.SetQueueInfo(msg.CurrentlyProducing);
break;
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
}
}
}