Files
tbd-station-14/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
Hannah Giovanna Dawson f850047341 Migrate Lathe Material Ejection Code to MaterialStorage (#23199)
* SS14-23184 Migrate Lathe Material Ejection Code to MaterialStorage

The lathe material ejection code acts as a do-nothing
man-in-the-middle system that does work that would be
reasonable for any MaterialStorage-using machine to
use. This has been fixed by migrating the ejection
code to MaterialStorage, allowing anything that uses
the system to eject mats it is storing.

* Fix some YAML references. Science!!
2023-12-30 20:08:33 -05:00

71 lines
1.9 KiB
C#

using Content.Shared.Lathe;
using Content.Shared.Materials;
using Content.Shared.Research.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
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.OnEjectPressed += (material, sheetsToExtract) =>
{
SendMessage(new EjectMaterialMessage(material, sheetsToExtract));
};
_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(Owner);
_menu?.PopulateMaterials(Owner);
_menu?.PopulateQueueList(msg.Queue);
_menu?.SetQueueInfo(msg.CurrentlyProducing);
break;
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
//thom _materialsEjectionMenu?.Dispose();
}
}
}