Add make ghost role verb (#3204)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Content.Shared.GameObjects.Components.Observer.GhostRoles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
namespace Content.Client.GameObjects.Components.Observer.GhostRoles
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesEntry : VBoxContainer
|
||||
@@ -1,9 +1,10 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Content.Shared.GameObjects.Components.Observer.GhostRoles;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
namespace Content.Client.GameObjects.Components.Observer.GhostRoles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class GhostRolesEui : BaseEui
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Content.Shared.GameObjects.Components.Observer.GhostRoles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
namespace Content.Client.GameObjects.Components.Observer.GhostRoles
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesWindow : SS14Window
|
||||
@@ -0,0 +1,76 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.GameObjects.Components.Observer.GhostRoles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer.GhostRoles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MakeGhostRoleEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
|
||||
private readonly MakeGhostRoleWindow _window;
|
||||
|
||||
public MakeGhostRoleEui()
|
||||
{
|
||||
_window = new MakeGhostRoleWindow();
|
||||
|
||||
_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();
|
||||
}
|
||||
|
||||
private void OnMake(EntityUid uid, string name, string description, bool makeSentient)
|
||||
{
|
||||
var player = _playerManager.LocalPlayer;
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var makeGhostRoleCommand =
|
||||
$"makeghostrole " +
|
||||
$"\"{CommandParsing.Escape(uid.ToString())}\" " +
|
||||
$"\"{CommandParsing.Escape(name)}\" " +
|
||||
$"\"{CommandParsing.Escape(description)}\"";
|
||||
|
||||
_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();
|
||||
SendMessage(new MakeGhostRoleWindowClosedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<cc:SS14Window Title="Make Ghost Role"
|
||||
xmlns:cc="clr-namespace:Robust.Client.UserInterface.CustomControls;assembly=Robust.Client"
|
||||
xmlns:c="clr-namespace:Robust.Client.UserInterface.Controls;assembly=Robust.Client">
|
||||
|
||||
<c:VBoxContainer>
|
||||
<c:HBoxContainer>
|
||||
<c:Label Name="RoleEntityLabel" Text="Entity" />
|
||||
<c:Label Name="RoleEntity" Text="" />
|
||||
</c:HBoxContainer>
|
||||
<c:HBoxContainer>
|
||||
<c:Label Name="RoleNameLabel" Text="Role Name" />
|
||||
<c:LineEdit Name="RoleName" SizeFlagsHorizontal="FillExpand"/>
|
||||
</c:HBoxContainer>
|
||||
<c:HBoxContainer>
|
||||
<c:Label Name="RoleDescriptionLabel" Text="Role Description" />
|
||||
<c:LineEdit Name="RoleDescription" SizeFlagsHorizontal="FillExpand"/>
|
||||
</c:HBoxContainer>
|
||||
<c:HBoxContainer>
|
||||
<c:Label Name="MakeSentientLabel" Text="Make Sentient" />
|
||||
<c:CheckBox Name="MakeSentientCheckbox" />
|
||||
</c:HBoxContainer>
|
||||
<c:HBoxContainer>
|
||||
<c:Button Name="MakeButton" Text="Make" />
|
||||
</c:HBoxContainer>
|
||||
</c:VBoxContainer>
|
||||
|
||||
</cc:SS14Window>
|
||||
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer.GhostRoles
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class MakeGhostRoleWindow : SS14Window
|
||||
{
|
||||
public delegate void MakeRole(EntityUid uid, string name, string description, bool makeSentient);
|
||||
|
||||
public MakeGhostRoleWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
MakeSentientLabel.CustomMinimumSize = (150, 0);
|
||||
RoleEntityLabel.CustomMinimumSize = (150, 0);
|
||||
RoleNameLabel.CustomMinimumSize = (150, 0);
|
||||
RoleName.CustomMinimumSize = (300, 0);
|
||||
RoleDescriptionLabel.CustomMinimumSize = (150, 0);
|
||||
RoleDescription.CustomMinimumSize = (300, 0);
|
||||
|
||||
MakeButton.OnPressed += OnPressed;
|
||||
}
|
||||
|
||||
private EntityUid? EntityUid { get; set; }
|
||||
|
||||
public event MakeRole? OnMake;
|
||||
|
||||
public void SetEntity(EntityUid uid)
|
||||
{
|
||||
EntityUid = uid;
|
||||
RoleEntity.Text = $"{uid}";
|
||||
}
|
||||
|
||||
private void OnPressed(ButtonEventArgs args)
|
||||
{
|
||||
if (EntityUid == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OnMake?.Invoke(EntityUid.Value, RoleName.Text, RoleDescription.Text, MakeSentientCheckbox.Pressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user