mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Blood.Cult.Components;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client._Wega.BloodCult.Ui;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class SummoningRuneMenu : FancyWindow
|
|
{
|
|
[Dependency] private IEntityManager _entityManager = default!;
|
|
|
|
public event Action<NetEntity>? OnCultistSelected;
|
|
|
|
public SummoningRuneMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.Instance!.InjectDependencies(this);
|
|
InitializeButtons();
|
|
}
|
|
|
|
private void InitializeButtons()
|
|
{
|
|
var cultistQuery = _entityManager.EntityQueryEnumerator<BloodCultistComponent, MetaDataComponent>();
|
|
while (cultistQuery.MoveNext(out var uid, out _, out var metaData))
|
|
{
|
|
var entityName = metaData.EntityName;
|
|
AddCultistButton(entityName, uid);
|
|
}
|
|
}
|
|
|
|
private void AddCultistButton(string cultistName, EntityUid cultistUid)
|
|
{
|
|
var button = new Button
|
|
{
|
|
Text = cultistName,
|
|
HorizontalAlignment = HAlignment.Center,
|
|
VerticalAlignment = VAlignment.Center,
|
|
MinSize = new Vector2(300, 32),
|
|
MaxSize = new Vector2(300, 32)
|
|
};
|
|
|
|
button.OnPressed += _ => HandleCultistSelection(cultistUid);
|
|
|
|
CultistsContainer.AddChild(button);
|
|
}
|
|
|
|
private void HandleCultistSelection(EntityUid cultistUid)
|
|
{
|
|
var netCultist = _entityManager.GetNetEntity(cultistUid);
|
|
OnCultistSelected?.Invoke(netCultist);
|
|
Close();
|
|
}
|
|
}
|