Re-organize all projects (#4166)
This commit is contained in:
12
Content.Client/Ghost/Roles/UI/GhostRoleWindow.cs
Normal file
12
Content.Client/Ghost/Roles/UI/GhostRoleWindow.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
|
||||
namespace Content.Client.Ghost.Roles.UI
|
||||
{
|
||||
public class GhostRoleWindow : SS14Window
|
||||
{
|
||||
protected override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Content.Client/Ghost/Roles/UI/GhostRolesEntry.xaml
Normal file
9
Content.Client/Ghost/Roles/UI/GhostRolesEntry.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<VBoxContainer
|
||||
xmlns="https://spacestation14.io">
|
||||
|
||||
<RichTextLabel Name="Title" />
|
||||
<HBoxContainer SeparationOverride="10">
|
||||
<RichTextLabel Name="Description" HorizontalExpand="True" />
|
||||
<Button Name="RequestButton" Text="Request" TextAlign="Center" SizeFlagsHorizontal="ShrinkEnd" />
|
||||
</HBoxContainer>
|
||||
</VBoxContainer>
|
||||
21
Content.Client/Ghost/Roles/UI/GhostRolesEntry.xaml.cs
Normal file
21
Content.Client/Ghost/Roles/UI/GhostRolesEntry.xaml.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Ghost.Roles.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesEntry : VBoxContainer
|
||||
{
|
||||
public GhostRolesEntry(GhostRoleInfo info, Action<BaseButton.ButtonEventArgs> requestAction)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
Title.SetMessage(info.Name);
|
||||
Description.SetMessage(info.Description);
|
||||
RequestButton.OnPressed += requestAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
54
Content.Client/Ghost/Roles/UI/GhostRolesEui.cs
Normal file
54
Content.Client/Ghost/Roles/UI/GhostRolesEui.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Client.Ghost.Roles.UI
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class GhostRolesEui : BaseEui
|
||||
{
|
||||
private readonly GhostRolesWindow _window;
|
||||
|
||||
public GhostRolesEui()
|
||||
{
|
||||
_window = new GhostRolesWindow();
|
||||
|
||||
_window.RoleRequested += id =>
|
||||
{
|
||||
SendMessage(new GhostRoleTakeoverRequestMessage(id));
|
||||
};
|
||||
|
||||
_window.OnClose += () =>
|
||||
{
|
||||
SendMessage(new GhostRoleWindowCloseMessage());
|
||||
};
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
public override void Closed()
|
||||
{
|
||||
base.Closed();
|
||||
_window.Close();
|
||||
}
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
base.HandleState(state);
|
||||
|
||||
if (state is not GhostRolesEuiState ghostState) return;
|
||||
|
||||
_window.ClearEntries();
|
||||
|
||||
foreach (var info in ghostState.GhostRoles)
|
||||
{
|
||||
_window.AddEntry(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Content.Client/Ghost/Roles/UI/GhostRolesWindow.xaml
Normal file
10
Content.Client/Ghost/Roles/UI/GhostRolesWindow.xaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<SS14Window Title="Ghost Roles"
|
||||
xmlns="https://spacestation14.io" MinSize="350 275">
|
||||
<CenterContainer Name="NoRolesMessage" VerticalExpand="True" HorizontalExpand="True">
|
||||
<Label Text="There are currently no available ghost roles." />
|
||||
</CenterContainer>
|
||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
<VBoxContainer Name="EntryContainer" HorizontalExpand="True" VerticalExpand="True" />
|
||||
</ScrollContainer>
|
||||
|
||||
</SS14Window>
|
||||
25
Content.Client/Ghost/Roles/UI/GhostRolesWindow.xaml.cs
Normal file
25
Content.Client/Ghost/Roles/UI/GhostRolesWindow.xaml.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
|
||||
namespace Content.Client.Ghost.Roles.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesWindow : SS14Window
|
||||
{
|
||||
public event Action<uint>? RoleRequested;
|
||||
|
||||
public void ClearEntries()
|
||||
{
|
||||
EntryContainer.DisposeAllChildren();
|
||||
NoRolesMessage.Visible = true;
|
||||
}
|
||||
|
||||
public void AddEntry(GhostRoleInfo info)
|
||||
{
|
||||
NoRolesMessage.Visible = false;
|
||||
EntryContainer.AddChild(new GhostRolesEntry(info, _ => RoleRequested?.Invoke(info.Identifier)));
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Content.Client/Ghost/Roles/UI/MakeGhostRoleEui.cs
Normal file
76
Content.Client/Ghost/Roles/UI/MakeGhostRoleEui.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
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.Ghost.Roles.UI
|
||||
{
|
||||
[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());
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Content.Client/Ghost/Roles/UI/MakeGhostRoleWindow.xaml
Normal file
26
Content.Client/Ghost/Roles/UI/MakeGhostRoleWindow.xaml
Normal file
@@ -0,0 +1,26 @@
|
||||
<SS14Window Title="Make Ghost Role"
|
||||
xmlns="https://spacestation14.io">
|
||||
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Name="RoleEntityLabel" Text="Entity" />
|
||||
<Label Name="RoleEntity" Text="" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Name="RoleNameLabel" Text="Role Name" />
|
||||
<LineEdit Name="RoleName" HorizontalExpand="True" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Name="RoleDescriptionLabel" Text="Role Description" />
|
||||
<LineEdit Name="RoleDescription" HorizontalExpand="True" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Name="MakeSentientLabel" Text="Make Sentient" />
|
||||
<CheckBox Name="MakeSentientCheckbox" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Button Name="MakeButton" Text="Make" />
|
||||
</HBoxContainer>
|
||||
</VBoxContainer>
|
||||
|
||||
</SS14Window>
|
||||
49
Content.Client/Ghost/Roles/UI/MakeGhostRoleWindow.xaml.cs
Normal file
49
Content.Client/Ghost/Roles/UI/MakeGhostRoleWindow.xaml.cs
Normal file
@@ -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.Ghost.Roles.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class MakeGhostRoleWindow : SS14Window
|
||||
{
|
||||
public delegate void MakeRole(EntityUid uid, string name, string description, bool makeSentient);
|
||||
|
||||
public MakeGhostRoleWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
MakeSentientLabel.MinSize = (150, 0);
|
||||
RoleEntityLabel.MinSize = (150, 0);
|
||||
RoleNameLabel.MinSize = (150, 0);
|
||||
RoleName.MinSize = (300, 0);
|
||||
RoleDescriptionLabel.MinSize = (150, 0);
|
||||
RoleDescription.MinSize = (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