LatheBoundUserInterface.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Shared.Lathe;
  2. using Content.Shared.Research.Components;
  3. using JetBrains.Annotations;
  4. using Robust.Client.UserInterface;
  5. namespace Content.Client.Lathe.UI
  6. {
  7. [UsedImplicitly]
  8. public sealed class LatheBoundUserInterface : BoundUserInterface
  9. {
  10. [ViewVariables]
  11. private LatheMenu? _menu;
  12. public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  13. {
  14. }
  15. protected override void Open()
  16. {
  17. base.Open();
  18. _menu = this.CreateWindowCenteredRight<LatheMenu>();
  19. _menu.SetEntity(Owner);
  20. _menu.OnServerListButtonPressed += _ =>
  21. {
  22. SendMessage(new ConsoleServerSelectionMessage());
  23. };
  24. _menu.RecipeQueueAction += (recipe, amount) =>
  25. {
  26. SendMessage(new LatheQueueRecipeMessage(recipe, amount));
  27. };
  28. }
  29. protected override void UpdateState(BoundUserInterfaceState state)
  30. {
  31. base.UpdateState(state);
  32. switch (state)
  33. {
  34. case LatheUpdateState msg:
  35. if (_menu != null)
  36. _menu.Recipes = msg.Recipes;
  37. _menu?.PopulateRecipes();
  38. _menu?.UpdateCategories();
  39. _menu?.PopulateQueueList(msg.Queue);
  40. _menu?.SetQueueInfo(msg.CurrentlyProducing);
  41. break;
  42. }
  43. }
  44. }
  45. }