Files
crystall-punk-14/Content.Client/_CP14/Workplace/CP14WorkplaceRecipeControl.xaml.cs
2025-05-22 15:29:48 +03:00

54 lines
1.4 KiB
C#

using Content.Shared._CP14.Workplace;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client._CP14.Workplace;
[GenerateTypedNameReferences]
public sealed partial class CP14WorkplaceRecipeControl : Control
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
public event Action<CP14WorkplaceRecipeEntry, EntityPrototype>? OnSelect;
private readonly EntityPrototype _recipePrototype;
private readonly bool _craftable;
public CP14WorkplaceRecipeControl(CP14WorkplaceRecipeEntry entry)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_recipePrototype = _prototype.Index(entry.Recipe);
_craftable = entry.Craftable;
Button.OnPressed += _ => OnSelect?.Invoke(entry, _recipePrototype);
UpdateColor();
//UpdateName();
UpdateView();
}
private void UpdateColor()
{
if (_craftable)
return;
Button.ModulateSelfOverride = Color.FromHex("#302622");
}
private void UpdateName()
{
//var result = _recipePrototype;
//var counter = _recipePrototype.ResultCount > 1 ? $" x{_recipePrototype.ResultCount}" : "";
//Name.Text = $"{Loc.GetString(result.Name)} {counter}" ;
}
private void UpdateView()
{
View.SetPrototype(_recipePrototype);
}
}