Files
OldThink/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
ThereDrD 1b07a035ce Upstream fixes (#664)
* fix weird name saving

* fix item status

* Fix single-user BUIs erroneously closing (#28375)

(cherry picked from commit 08952b467d9b2b2db85cb9ebb4e8b628c0145716)

* fix meatyore shop

* possible playtime fix

* fixes

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-08-25 01:37:24 +03:00

64 lines
1.7 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 += _ =>
{
SendPredictedMessage(new ConsoleServerSelectionMessage());
};
_menu.RecipeQueueAction += (recipe, amount) =>
{
SendPredictedMessage(new LatheQueueRecipeMessage(recipe, amount));
};
_menu.OpenCenteredRight();
}
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();
}
}
}