63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Changeling.Components;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Changeling.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class ChangelingTransformMenu : RadialMenu
|
|
{
|
|
[Dependency] private readonly IEntityManager _entity = default!;
|
|
public event Action<NetEntity>? OnIdentitySelect;
|
|
|
|
public ChangelingTransformMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
}
|
|
|
|
public void Update(EntityUid uid)
|
|
{
|
|
Main.DisposeAllChildren();
|
|
|
|
if (!_entity.TryGetComponent<ChangelingIdentityComponent>(uid, out var identityComp))
|
|
return;
|
|
|
|
foreach (var identityUid in identityComp.ConsumedIdentities)
|
|
{
|
|
if (!_entity.TryGetComponent<MetaDataComponent>(identityUid, out var metadata))
|
|
continue;
|
|
|
|
var identityName = metadata.EntityName;
|
|
|
|
var button = new ChangelingTransformMenuButton()
|
|
{
|
|
StyleClasses = { "RadialMenuButton" },
|
|
SetSize = new Vector2(64, 64),
|
|
ToolTip = identityName,
|
|
};
|
|
|
|
var entView = new SpriteView()
|
|
{
|
|
SetSize = new Vector2(48, 48),
|
|
VerticalAlignment = VAlignment.Center,
|
|
HorizontalAlignment = HAlignment.Center,
|
|
Stretch = SpriteView.StretchMode.Fill,
|
|
};
|
|
entView.SetEntity(identityUid);
|
|
button.OnButtonUp += _ =>
|
|
{
|
|
OnIdentitySelect?.Invoke(_entity.GetNetEntity(identityUid));
|
|
Close();
|
|
};
|
|
button.AddChild(entView);
|
|
Main.AddChild(button);
|
|
}
|
|
}
|
|
}
|
|
|
|
public sealed class ChangelingTransformMenuButton : RadialMenuTextureButtonWithSector;
|