2021-02-16 09:51:27 +01:00
|
|
|
|
using Content.Client.Eui;
|
|
|
|
|
|
using Content.Shared.Eui;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Ghost.Roles;
|
2021-02-16 09:51:27 +01:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Client.Console;
|
|
|
|
|
|
using Robust.Client.Player;
|
|
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
2022-09-11 20:42:12 -07:00
|
|
|
|
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
2021-02-16 09:51:27 +01:00
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class MakeGhostRoleEui : BaseEui
|
2021-02-16 09:51:27 +01:00
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
|
|
|
|
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly MakeGhostRoleWindow _window;
|
|
|
|
|
|
|
|
|
|
|
|
public MakeGhostRoleEui()
|
|
|
|
|
|
{
|
|
|
|
|
|
_window = new MakeGhostRoleWindow();
|
|
|
|
|
|
|
2022-07-07 13:36:57 +10:00
|
|
|
|
|
2021-02-16 09:51:27 +01:00
|
|
|
|
_window.OnClose += OnClose;
|
|
|
|
|
|
_window.OnMake += OnMake;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void HandleState(EuiStateBase state)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (state is not MakeGhostRoleEuiState uiState)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_window.SetEntity(uiState.EntityUid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Opened()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Opened();
|
|
|
|
|
|
_window.OpenCentered();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-02 00:42:04 +00:00
|
|
|
|
private void OnMake(EntityUid uid, string name, string description, string rules, bool makeSentient)
|
2021-02-16 09:51:27 +01:00
|
|
|
|
{
|
|
|
|
|
|
var player = _playerManager.LocalPlayer;
|
|
|
|
|
|
if (player == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var makeGhostRoleCommand =
|
|
|
|
|
|
$"makeghostrole " +
|
|
|
|
|
|
$"\"{CommandParsing.Escape(uid.ToString())}\" " +
|
|
|
|
|
|
$"\"{CommandParsing.Escape(name)}\" " +
|
2021-11-02 00:42:04 +00:00
|
|
|
|
$"\"{CommandParsing.Escape(description)}\" " +
|
|
|
|
|
|
$"\"{CommandParsing.Escape(rules)}\"";
|
2021-02-16 09:51:27 +01:00
|
|
|
|
|
|
|
|
|
|
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);
|
|
|
|
|
|
|
|
|
|
|
|
if (makeSentient)
|
|
|
|
|
|
{
|
|
|
|
|
|
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(uid.ToString())}\"";
|
|
|
|
|
|
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_window.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Closed();
|
2023-04-29 15:16:24 +12:00
|
|
|
|
SendMessage(new CloseEuiMessage());
|
2021-02-16 09:51:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|