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;
|
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();
|
|
|
|
|
|
2020-04-09 00:28:56 +02:00
|
|
|
_menu = new LatheMenu(this);
|
|
|
|
|
_menu.OnClose += Close;
|
2019-04-26 15:51:05 +02:00
|
|
|
|
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
|
|
|
|
2024-02-01 05:49:48 -07:00
|
|
|
_menu.OpenCenteredRight();
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(disposing);
|
2022-09-16 19:49:05 -04:00
|
|
|
if (!disposing)
|
|
|
|
|
return;
|
2020-04-09 00:28:56 +02:00
|
|
|
_menu?.Dispose();
|
2019-04-26 15:51:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|