2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Lathe;
|
2022-12-25 16:22:23 -05:00
|
|
|
using Content.Shared.Research.Components;
|
2022-09-16 19:49:05 -04:00
|
|
|
using JetBrains.Annotations;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Robust.Client.UserInterface;
|
2019-04-26 15:51:05 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Lathe.UI
|
2019-04-26 15:51:05 +02:00
|
|
|
{
|
2022-09-16 19:49:05 -04:00
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class LatheBoundUserInterface : BoundUserInterface
|
2019-04-26 15:51:05 +02:00
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
[ViewVariables]
|
|
|
|
|
private LatheMenu? _menu;
|
|
|
|
|
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
2019-04-26 15:51:05 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
|
2025-02-23 23:57:57 +11:00
|
|
|
_menu = this.CreateWindowCenteredRight<LatheMenu>();
|
2024-07-21 14:48:13 +10:00
|
|
|
_menu.SetEntity(Owner);
|
2023-08-17 12:22:01 -05:00
|
|
|
|
2022-09-16 19:49:05 -04:00
|
|
|
_menu.OnServerListButtonPressed += _ =>
|
2019-09-03 22:51:19 +02:00
|
|
|
{
|
2022-12-25 16:22:23 -05:00
|
|
|
SendMessage(new ConsoleServerSelectionMessage());
|
2019-09-03 22:51:19 +02:00
|
|
|
};
|
2023-08-17 12:22:01 -05:00
|
|
|
|
2022-09-16 19:49:05 -04:00
|
|
|
_menu.RecipeQueueAction += (recipe, amount) =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
|
|
|
|
|
};
|
2019-04-26 15:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-16 19:49:05 -04:00
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
2019-04-26 15:51:05 +02:00
|
|
|
{
|
2022-09-16 19:49:05 -04:00
|
|
|
base.UpdateState(state);
|
2019-04-26 15:51:05 +02:00
|
|
|
|
2022-09-16 19:49:05 -04:00
|
|
|
switch (state)
|
2019-04-26 15:51:05 +02:00
|
|
|
{
|
2022-09-16 19:49:05 -04:00
|
|
|
case LatheUpdateState msg:
|
|
|
|
|
if (_menu != null)
|
|
|
|
|
_menu.Recipes = msg.Recipes;
|
2024-01-19 19:45:03 -05:00
|
|
|
_menu?.PopulateRecipes();
|
|
|
|
|
_menu?.UpdateCategories();
|
2023-08-29 01:36:07 +01:00
|
|
|
_menu?.PopulateQueueList(msg.Queue);
|
|
|
|
|
_menu?.SetQueueInfo(msg.CurrentlyProducing);
|
2019-04-26 15:51:05 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|