Files
crystall-punk-14/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleWindow.xaml.cs

52 lines
1.7 KiB
C#
Raw Normal View History

using System.Numerics;
using Robust.Client.AutoGenerated;
2021-02-16 09:51:27 +01:00
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using static Robust.Client.UserInterface.Controls.BaseButton;
2022-09-11 20:42:12 -07:00
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
2021-02-16 09:51:27 +01:00
{
[GenerateTypedNameReferences]
public sealed partial class MakeGhostRoleWindow : DefaultWindow
2021-02-16 09:51:27 +01:00
{
2023-09-11 14:31:45 +10:00
public delegate void MakeRole(NetEntity uid, string name, string description, string rules, bool makeSentient);
2021-02-16 09:51:27 +01:00
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);
2021-02-16 09:51:27 +01:00
MakeButton.OnPressed += OnPressed;
}
2023-09-11 14:31:45 +10:00
private NetEntity? Entity { get; set; }
2021-02-16 09:51:27 +01:00
public event MakeRole? OnMake;
2023-09-11 14:31:45 +10:00
public void SetEntity(IEntityManager entManager, NetEntity entity)
2021-02-16 09:51:27 +01:00
{
2023-09-11 14:31:45 +10:00
Entity = entity;
RoleName.Text = entManager.GetComponent<MetaDataComponent>(entManager.GetEntity(entity)).EntityName;
RoleEntity.Text = $"{entity}";
2021-02-16 09:51:27 +01:00
}
private void OnPressed(ButtonEventArgs args)
{
2023-09-11 14:31:45 +10:00
if (Entity == null)
2021-02-16 09:51:27 +01:00
{
return;
}
2023-09-11 14:31:45 +10:00
OnMake?.Invoke(Entity.Value, RoleName.Text, RoleDescription.Text, RoleRules.Text, MakeSentientCheckbox.Pressed);
2021-02-16 09:51:27 +01:00
}
}
}