6
StarHorizon_Public/Content.Client/_NF/Lathe/UI/BlueprintRecipeControl.xaml.cs
2025-11-07 12:32:48 +03:00

43 lines
1.3 KiB
C#

using Content.Client.Lathe.UI;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
namespace Content.Client._NF.Lathe.UI;
[GenerateTypedNameReferences]
public sealed partial class BlueprintRecipeControl : Control
{
public Func<string> TooltipTextSupplier;
public Action<bool>? OnSelectedAction;
public bool Selected = false;
public int Index;
public BlueprintRecipeControl(BlueprintLatheSystem latheSystem, LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, Control displayControl, int index)
{
RobustXamlLoader.Load(this);
RecipeName.Text = latheSystem.GetRecipeName(recipe);
RecipeDisplayContainer.AddChild(displayControl);
Button.Disabled = !canProduce;
TooltipTextSupplier = tooltipTextSupplier;
Button.TooltipSupplier = SupplyTooltip;
Index = index;
Button.OnPressed += (_) => SetSelected(!Selected);
}
public void SetSelected(bool selected)
{
Selected = selected;
Button.Pressed = selected;
OnSelectedAction?.Invoke(selected);
}
private Control? SupplyTooltip(Control sender)
{
return new RecipeTooltip(TooltipTextSupplier());
}
}