Files
tbd-station-14/Content.Client/Lathe/UI/RecipeControl.xaml.cs
Nemanja 2c26be606f Add support for printing reagents in lathes (#30476)
* Add support for reagents in lathes

* missing locale
2024-08-01 14:15:05 +10:00

35 lines
1.0 KiB
C#

using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Lathe.UI;
[GenerateTypedNameReferences]
public sealed partial class RecipeControl : Control
{
public Action<string>? OnButtonPressed;
public Func<string> TooltipTextSupplier;
public RecipeControl(LatheSystem latheSystem, LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, Control displayControl)
{
RobustXamlLoader.Load(this);
RecipeName.Text = latheSystem.GetRecipeName(recipe);
RecipeDisplayContainer.AddChild(displayControl);
Button.Disabled = !canProduce;
TooltipTextSupplier = tooltipTextSupplier;
Button.TooltipSupplier = SupplyTooltip;
Button.OnPressed += (_) =>
{
OnButtonPressed?.Invoke(recipe.ID);
};
}
private Control? SupplyTooltip(Control sender)
{
return new RecipeTooltip(TooltipTextSupplier());
}
}