mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Veil.Cult.UI;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._Wega.VeilCult.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class EnchantWindow : RadialMenu
|
|
{
|
|
[Dependency] private IPrototypeManager _prototype = default!;
|
|
|
|
public event Action<EntProtoId>? OnEnchantSelected;
|
|
private List<EntProtoId> _enchants = new();
|
|
|
|
public EnchantWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
}
|
|
|
|
public void Populate(EnchantSelectionState state)
|
|
{
|
|
MainContainer.RemoveAllChildren();
|
|
_enchants = state.AvailableEnchants;
|
|
|
|
for (var i = 0; i < _enchants.Count; i++)
|
|
{
|
|
if (!_prototype.TryIndex(_enchants[i], out var enchant))
|
|
continue;
|
|
|
|
var button = CreateEntityButton(enchant);
|
|
MainContainer.AddChild(button);
|
|
}
|
|
}
|
|
|
|
private RadialMenuButtonWithSector CreateEntityButton(EntityPrototype enchant)
|
|
{
|
|
string suffix = enchant.EditorSuffix ?? "unknown";
|
|
var button = new RadialMenuButtonWithSector
|
|
{
|
|
ToolTip = Loc.GetString(suffix),
|
|
SetSize = new Vector2(72, 72),
|
|
};
|
|
|
|
button.StyleClasses.Add("RadialMenuButton");
|
|
|
|
var container = new BoxContainer
|
|
{
|
|
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
|
HorizontalAlignment = HAlignment.Center,
|
|
VerticalAlignment = VAlignment.Center
|
|
};
|
|
|
|
if (_prototype.TryIndex<EntityPrototype>(enchant.ID, out var item))
|
|
{
|
|
var entityView = new EntityPrototypeView
|
|
{
|
|
Scale = new Vector2(1.5f, 1.5f),
|
|
SetSize = new Vector2(48, 48),
|
|
Margin = new Thickness(2)
|
|
};
|
|
entityView.SetPrototype(item.ID);
|
|
container.AddChild(entityView);
|
|
}
|
|
|
|
button.AddChild(container);
|
|
button.OnPressed += _ => OnEnchantSelected?.Invoke(enchant.ID);
|
|
|
|
return button;
|
|
}
|
|
}
|