RecipeControl.xaml.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Content.Shared.Research.Prototypes;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.UserInterface;
  4. using Robust.Client.UserInterface.XAML;
  5. namespace Content.Client.Lathe.UI;
  6. [GenerateTypedNameReferences]
  7. public sealed partial class RecipeControl : Control
  8. {
  9. public Action<string>? OnButtonPressed;
  10. public Func<string> TooltipTextSupplier;
  11. public RecipeControl(LatheSystem latheSystem, LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, Control displayControl)
  12. {
  13. RobustXamlLoader.Load(this);
  14. RecipeName.Text = latheSystem.GetRecipeName(recipe);
  15. RecipeDisplayContainer.AddChild(displayControl);
  16. Button.Disabled = !canProduce;
  17. TooltipTextSupplier = tooltipTextSupplier;
  18. Button.TooltipSupplier = SupplyTooltip;
  19. Button.OnPressed += (_) =>
  20. {
  21. OnButtonPressed?.Invoke(recipe.ID);
  22. };
  23. }
  24. private Control? SupplyTooltip(Control sender)
  25. {
  26. return new RecipeTooltip(TooltipTextSupplier());
  27. }
  28. }