* init * init * PUSH!!! * // * Me when the when the me when the * review --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using Content.Shared.Research.Prototypes;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Lathe.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class RecipeControl : Control
|
|
{
|
|
public Action<string>? OnButtonPressed;
|
|
public Func<string> TooltipTextSupplier;
|
|
|
|
private ProtoId<LatheRecipePrototype> _recipeId;
|
|
private LatheSystem _latheSystem;
|
|
|
|
public RecipeControl(LatheSystem latheSystem, LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, Control displayControl)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
_latheSystem = latheSystem;
|
|
_recipeId = recipe.ID;
|
|
TooltipTextSupplier = tooltipTextSupplier;
|
|
SetRecipe(recipe);
|
|
SetCanProduce(canProduce);
|
|
SetDisplayControl(displayControl);
|
|
|
|
Button.OnPressed += (_) =>
|
|
{
|
|
OnButtonPressed?.Invoke(_recipeId);
|
|
};
|
|
Button.TooltipSupplier = SupplyTooltip;
|
|
}
|
|
|
|
public void SetRecipe(LatheRecipePrototype recipe)
|
|
{
|
|
RecipeName.Text = _latheSystem.GetRecipeName(recipe);
|
|
_recipeId = recipe.ID;
|
|
}
|
|
|
|
public void SetTooltipSupplier(Func<string> tooltipTextSupplier)
|
|
{
|
|
TooltipTextSupplier = tooltipTextSupplier;
|
|
}
|
|
|
|
public void SetCanProduce(bool canProduce)
|
|
{
|
|
Button.Disabled = !canProduce;
|
|
}
|
|
|
|
public void SetDisplayControl(Control displayControl)
|
|
{
|
|
RecipeDisplayContainer.Children.Clear();
|
|
RecipeDisplayContainer.AddChild(displayControl);
|
|
}
|
|
|
|
private Control? SupplyTooltip(Control sender)
|
|
{
|
|
return new RecipeTooltip(TooltipTextSupplier());
|
|
}
|
|
}
|