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 TooltipTextSupplier; public Action? OnSelectedAction; public bool Selected = false; public int Index; public BlueprintRecipeControl(BlueprintLatheSystem latheSystem, LatheRecipePrototype recipe, Func 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()); } }