* Update lathes to use entity prototype * ScrollContainer my hero * gets rid of excess newlines --------- Co-authored-by: plykiya <plykiya@protonmail.com>
39 lines
1.1 KiB
C#
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());
|
|
}
|
|
}
|