Files
tbd-station-14/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleWindow.xaml.cs
2023-09-11 14:31:45 +10:00

52 lines
1.7 KiB
C#

using System.Numerics;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
[GenerateTypedNameReferences]
public sealed partial class MakeGhostRoleWindow : DefaultWindow
{
public delegate void MakeRole(NetEntity uid, string name, string description, string rules, bool makeSentient);
public MakeGhostRoleWindow()
{
RobustXamlLoader.Load(this);
MakeSentientLabel.MinSize = new Vector2(150, 0);
RoleEntityLabel.MinSize = new Vector2(150, 0);
RoleNameLabel.MinSize = new Vector2(150, 0);
RoleName.MinSize = new Vector2(300, 0);
RoleDescriptionLabel.MinSize = new Vector2(150, 0);
RoleDescription.MinSize = new Vector2(300, 0);
RoleRulesLabel.MinSize = new Vector2(150, 0);
RoleRules.MinSize = new Vector2(300, 0);
MakeButton.OnPressed += OnPressed;
}
private NetEntity? Entity { get; set; }
public event MakeRole? OnMake;
public void SetEntity(IEntityManager entManager, NetEntity entity)
{
Entity = entity;
RoleName.Text = entManager.GetComponent<MetaDataComponent>(entManager.GetEntity(entity)).EntityName;
RoleEntity.Text = $"{entity}";
}
private void OnPressed(ButtonEventArgs args)
{
if (Entity == null)
{
return;
}
OnMake?.Invoke(Entity.Value, RoleName.Text, RoleDescription.Text, RoleRules.Text, MakeSentientCheckbox.Pressed);
}
}
}