Show missing materials in lathes tooltip (#26795)

* Lathes: Show missing materials amount in tooltip

* Use AppendLine and remove the last newline at the end
This commit is contained in:
Crotalus
2024-04-08 05:16:11 +02:00
committed by GitHub
parent 356c2799cf
commit a178754980
3 changed files with 55 additions and 37 deletions

View File

@@ -11,17 +11,16 @@ namespace Content.Client.Lathe.UI;
public sealed partial class RecipeControl : Control
{
public Action<string>? OnButtonPressed;
public Func<string> TooltipTextSupplier;
public string TooltipText;
public RecipeControl(LatheRecipePrototype recipe, string tooltip, bool canProduce, Texture? texture = null)
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;
TooltipText = tooltip;
TooltipTextSupplier = tooltipTextSupplier;
Button.TooltipSupplier = SupplyTooltip;
Button.OnPressed += (_) =>
@@ -32,6 +31,6 @@ public sealed partial class RecipeControl : Control
private Control? SupplyTooltip(Control sender)
{
return new RecipeTooltip(TooltipText);
return new RecipeTooltip(TooltipTextSupplier());
}
}