Files
tbd-station-14/Content.Client/Lathe/UI/RecipeControl.xaml.cs
Crotalus a178754980 Show missing materials in lathes tooltip (#26795)
* Lathes: Show missing materials amount in tooltip

* Use AppendLine and remove the last newline at the end
2024-04-07 23:16:11 -04:00

37 lines
1.0 KiB
C#

using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Graphics;
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, Texture? texture = null)
{
RobustXamlLoader.Load(this);
RecipeName.Text = recipe.Name;
RecipeTexture.Texture = texture;
Button.Disabled = !canProduce;
TooltipTextSupplier = tooltipTextSupplier;
Button.TooltipSupplier = SupplyTooltip;
Button.OnPressed += (_) =>
{
OnButtonPressed?.Invoke(recipe.ID);
};
}
private Control? SupplyTooltip(Control sender)
{
return new RecipeTooltip(TooltipTextSupplier());
}
}