44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Content.Shared.Stacks;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._CP14.Workbench;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class CP14WorkbenchRecipeControl : Control
|
|
{
|
|
[Dependency] private readonly IEntityManager _entity = default!;
|
|
|
|
private readonly SpriteSystem _sprite;
|
|
|
|
public CP14WorkbenchRecipeControl()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_sprite = _entity.System<SpriteSystem>();
|
|
}
|
|
|
|
public CP14WorkbenchRecipeControl(EntityPrototype prototype, int count) : this()
|
|
{
|
|
var entityName = prototype.Name;
|
|
Name.Text = count <= 1 ? entityName : $"{entityName} x{count}";
|
|
View.Texture = _sprite.GetPrototypeIcon(prototype).Default;
|
|
}
|
|
|
|
public CP14WorkbenchRecipeControl(StackPrototype prototype, int count) : this()
|
|
{
|
|
var entityName = Loc.GetString(prototype.Name);
|
|
Name.Text = $"{entityName} x{count}";
|
|
|
|
var icon = prototype.Icon;
|
|
if (icon is null)
|
|
return;
|
|
|
|
View.Texture = _sprite.Frame0(icon);
|
|
}
|
|
}
|