Files
crystall-punk-14/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml.cs
Ed 925738afc2 Workbench update (#760)
* fix workbench icons

* workbench search

* fix 1

* UI finalize

* fix material localization

* restore shard sprite

* Update sewing_table.yml
2025-01-15 00:34:08 +03:00

52 lines
1.4 KiB
C#

/*
* This file is sublicensed under MIT License
* https://github.com/space-wizards/space-station-14/blob/master/LICENSE.TXT
*/
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.Visible = false;
EntityView.SetPrototype(prototype);
}
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;
EntityView.Visible = false;
View.Texture = _sprite.Frame0(icon);
}
}