Files
tbd-station-14/Content.Client/Lathe/UI/RecipeControl.xaml.cs
Plykiya 9cd08b84d9 Fix some lathe recipe textures showing up blank (#28683)
* Update lathes to use entity prototype

* ScrollContainer my hero

* gets rid of excess newlines

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
2024-06-19 13:18:45 +10:00

39 lines
1.1 KiB
C#

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