Files
tbd-station-14/Content.Client/Lathe/UI/LatheQueueMenu.xaml.cs
2023-01-01 15:56:03 -08:00

58 lines
1.9 KiB
C#

using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Lathe.UI
{
[GenerateTypedNameReferences]
public sealed partial class LatheQueueMenu : DefaultWindow
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly SpriteSystem _spriteSystem;
public LatheQueueMenu()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>();
SetInfo(null);
}
public void SetInfo(LatheRecipePrototype? recipe)
{
if (recipe != null)
{
Icon.Texture = recipe.Icon == null
? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
: _spriteSystem.Frame0(recipe.Icon);
NameLabel.Text = recipe.Name;
Description.Text = recipe.Description;
}
else
{
Icon.Texture = Texture.Transparent;
NameLabel.Text = string.Empty;
Description.Text = Loc.GetString("lathe-queue-menu-not-producing-text");
}
}
public void PopulateList(List<LatheRecipePrototype> queue)
{
QueueList.Clear();
var idx = 1;
foreach (var recipe in queue)
{
var icon =recipe.Icon == null
? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
: _spriteSystem.Frame0(recipe.Icon);
QueueList.AddItem($"{idx}. {recipe.Name}", icon);
idx++;
}
}
}
}