mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Item.Selector.UI;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._Wega.Item.Selector.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class ObjectSelectorWindow : RadialMenu
|
|
{
|
|
[Dependency] private IPrototypeManager _prototypeManager = default!;
|
|
|
|
public event Action<EntProtoId>? OnObjectSelected;
|
|
|
|
public ObjectSelectorWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
}
|
|
|
|
public void Populate(ObjectSelectorUserMessage message)
|
|
{
|
|
MainContainer.RemoveAllChildren();
|
|
|
|
foreach (var prototypeId in message.Objects)
|
|
{
|
|
if (!_prototypeManager.TryIndex<EntityPrototype>(prototypeId, out var prototype))
|
|
continue;
|
|
|
|
var button = new RadialMenuContextualCentralTextureButton
|
|
{
|
|
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 += _ =>
|
|
{
|
|
OnObjectSelected?.Invoke(prototype.ID);
|
|
};
|
|
|
|
MainContainer.AddChild(button);
|
|
}
|
|
}
|
|
}
|