mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Blood.Cult;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._Wega.BloodCult.Ui;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class BloodStructureMenu : RadialMenu
|
|
{
|
|
[Dependency] private IPrototypeManager _proto = default!;
|
|
|
|
public event Action<string>? OnSelectItem;
|
|
|
|
public BloodStructureMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.Instance!.InjectDependencies(this);
|
|
}
|
|
|
|
public void InitializeButtons(BloodStructureBoundUserInterfaceState state)
|
|
{
|
|
Main.RemoveAllChildren();
|
|
|
|
foreach (var prototypeId in state.Items)
|
|
{
|
|
if (!_proto.TryIndex(prototypeId, out var prototype))
|
|
continue;
|
|
|
|
var button = new RadialMenuButton
|
|
{
|
|
ToolTip = prototype.Name,
|
|
SetSize = new Vector2(64, 64),
|
|
};
|
|
|
|
button.StyleClasses.Add("RadialMenuButton");
|
|
|
|
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);
|
|
|
|
button.OnPressed += _ =>
|
|
{
|
|
HandleItemSelection(prototype.ID);
|
|
};
|
|
|
|
Main.AddChild(button);
|
|
}
|
|
}
|
|
|
|
private void HandleItemSelection(string name)
|
|
{
|
|
OnSelectItem?.Invoke(name);
|
|
Close();
|
|
}
|
|
}
|