2022-09-16 19:49:05 -04:00
|
|
|
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;
|
2024-04-08 05:16:11 +02:00
|
|
|
public Func<string> TooltipTextSupplier;
|
2022-09-16 19:49:05 -04:00
|
|
|
|
2024-08-01 00:15:05 -04:00
|
|
|
public RecipeControl(LatheSystem latheSystem, LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, Control displayControl)
|
2022-09-16 19:49:05 -04:00
|
|
|
{
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
2024-08-01 00:15:05 -04:00
|
|
|
RecipeName.Text = latheSystem.GetRecipeName(recipe);
|
|
|
|
|
RecipeDisplayContainer.AddChild(displayControl);
|
2022-09-16 19:49:05 -04:00
|
|
|
Button.Disabled = !canProduce;
|
2024-04-08 05:16:11 +02:00
|
|
|
TooltipTextSupplier = tooltipTextSupplier;
|
2023-12-16 18:06:38 -08:00
|
|
|
Button.TooltipSupplier = SupplyTooltip;
|
2022-09-16 19:49:05 -04:00
|
|
|
|
|
|
|
|
Button.OnPressed += (_) =>
|
|
|
|
|
{
|
|
|
|
|
OnButtonPressed?.Invoke(recipe.ID);
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-12-16 18:06:38 -08:00
|
|
|
|
|
|
|
|
private Control? SupplyTooltip(Control sender)
|
|
|
|
|
{
|
2024-04-08 05:16:11 +02:00
|
|
|
return new RecipeTooltip(TooltipTextSupplier());
|
2023-12-16 18:06:38 -08:00
|
|
|
}
|
2022-09-16 19:49:05 -04:00
|
|
|
}
|