mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Vampire;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._Wega.Vampire.Ui;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class DissectSelectionMenu : RadialMenu
|
|
{
|
|
[Dependency] private IEntityManager _entityManager = default!;
|
|
[Dependency] private IPrototypeManager _prototype = default!;
|
|
|
|
public event Action<NetEntity>? OnOrganSelected;
|
|
|
|
public DissectSelectionMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
}
|
|
|
|
public void Populate(DissectSelectionEuiState state)
|
|
{
|
|
MainContainer.RemoveAllChildren();
|
|
foreach (var organNetEntity in state.AvailableOrgans)
|
|
{
|
|
var organEntity = _entityManager.GetEntity(organNetEntity);
|
|
if (!_entityManager.TryGetComponent<MetaDataComponent>(organEntity, out var metaData))
|
|
continue;
|
|
|
|
var prototypeId = metaData.EntityPrototype?.ID ?? string.Empty;
|
|
var button = new RadialMenuButton
|
|
{
|
|
ToolTip = metaData.EntityName,
|
|
SetSize = new Vector2(64, 64),
|
|
StyleClasses = { "RadialMenuButton" }
|
|
};
|
|
|
|
// Try to get icon for organ
|
|
if (!string.IsNullOrEmpty(prototypeId) && _prototype.TryIndex(prototypeId, out var prototype))
|
|
{
|
|
var entityView = new EntityPrototypeView
|
|
{
|
|
Scale = new Vector2(2, 2),
|
|
SetSize = new Vector2(64, 64),
|
|
Margin = new Thickness(4)
|
|
};
|
|
entityView.SetPrototype(prototype.ID);
|
|
button.AddChild(entityView);
|
|
}
|
|
else
|
|
{
|
|
// Fallback to text if no icon
|
|
var label = new Label
|
|
{
|
|
Text = metaData.EntityName,
|
|
Align = Label.AlignMode.Center,
|
|
HorizontalExpand = true,
|
|
VerticalExpand = true
|
|
};
|
|
button.AddChild(label);
|
|
}
|
|
|
|
var capturedOrgan = organNetEntity;
|
|
button.OnPressed += _ => OnOrganSelected?.Invoke(capturedOrgan);
|
|
MainContainer.AddChild(button);
|
|
}
|
|
}
|
|
}
|