From 541ba64c80af8b1f5e7ef756fdecce72067d5a37 Mon Sep 17 00:00:00 2001 From: Swept Date: Fri, 14 Aug 2020 09:09:58 -0700 Subject: [PATCH] More sandbox buttons for fun and pleasure (#1599) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Aghost Button * Toggle Lights Button (Shitcode) * Suicide Button * Toggle Subfloor Button * Changed the X icon for windows to be slimmer * ToggleLights and ToggleSubfloor are no longer shitcode! * Refactors SandboxWindows.cs * Added Shows Spawns Button * Fix * Show Bounding Boxes Button * I guess this helps somewhat? * Nested SandboxWindow.cs inside of SandboxManager.cs for simplicity * Fixes * I forgot what I added * Removed CSI console... for now * Fix build Co-authored-by: Víctor Aguilera Puerto --- Content.Client/Sandbox/SandboxManager.cs | 129 +++++++++++++++++- Content.Client/Sandbox/SandboxWindow.cs | 51 ------- Content.Server/Sandbox/SandboxManager.cs | 27 ++++ .../Sandbox/SharedSandboxManager.cs | 40 +++++- Resources/Textures/Interface/Nano/cross.svg | 87 +----------- .../Textures/Interface/Nano/cross.svg.png | Bin 372 -> 288 bytes 6 files changed, 192 insertions(+), 142 deletions(-) delete mode 100644 Content.Client/Sandbox/SandboxWindow.cs diff --git a/Content.Client/Sandbox/SandboxManager.cs b/Content.Client/Sandbox/SandboxManager.cs index 5e5cda1aa0..fddcf313cf 100644 --- a/Content.Client/Sandbox/SandboxManager.cs +++ b/Content.Client/Sandbox/SandboxManager.cs @@ -1,8 +1,12 @@ using System; using Content.Client.UserInterface; +using Content.Client.GameObjects.EntitySystems; using Content.Shared.Input; using Content.Shared.Sandbox; +using Robust.Client.Console; +using Robust.Client.Interfaces.Console; using Robust.Client.Interfaces.Input; +using Robust.Client.Interfaces.Graphics.Lighting; using Robust.Client.Interfaces.Placement; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.UserInterface.Controls; @@ -16,9 +20,64 @@ using Robust.Shared.Prototypes; namespace Content.Client.Sandbox { - internal sealed class SandboxManager : SharedSandboxManager, ISandboxManager + // Layout for the SandboxWindow + public class SandboxWindow : SS14Window + { + public Button RespawnButton; + public Button SpawnEntitiesButton; + public Button SpawnTilesButton; + public Button GiveFullAccessButton; //A button that just puts a captain's ID in your hands. + public Button GiveAghostButton; + public Button ToggleLightButton; + public Button SuicideButton; + public Button ToggleSubfloorButton; + public Button ShowMarkersButton; //Shows spawn points + public Button ShowBbButton; //Shows bounding boxes + + public SandboxWindow(ILocalizationManager loc) + { + Resizable = false; + + Title = "Sandbox Panel"; + + var vBox = new VBoxContainer { SeparationOverride = 4 }; + Contents.AddChild(vBox); + + RespawnButton = new Button { Text = loc.GetString("Respawn") }; + vBox.AddChild(RespawnButton); + + SpawnEntitiesButton = new Button { Text = loc.GetString("Spawn Entities") }; + vBox.AddChild(SpawnEntitiesButton); + + SpawnTilesButton = new Button { Text = loc.GetString("Spawn Tiles") }; + vBox.AddChild(SpawnTilesButton); + + GiveFullAccessButton = new Button { Text = loc.GetString("Give AA Id") }; + vBox.AddChild(GiveFullAccessButton); + + GiveAghostButton = new Button { Text = loc.GetString("Ghost") }; + vBox.AddChild(GiveAghostButton); + + ToggleLightButton = new Button { Text = loc.GetString("Toggle Lights"), ToggleMode = true }; + vBox.AddChild(ToggleLightButton); + + ToggleSubfloorButton = new Button { Text = loc.GetString("Toggle Subfloor"), ToggleMode = true }; + vBox.AddChild(ToggleSubfloorButton); + + SuicideButton = new Button { Text = loc.GetString("Suicide") }; + vBox.AddChild(SuicideButton); + + ShowMarkersButton = new Button { Text = loc.GetString("Show Spawns"), ToggleMode = true }; + vBox.AddChild(ShowMarkersButton); + + ShowBbButton = new Button { Text = loc.GetString("Show Bb"), ToggleMode = true }; + vBox.AddChild(ShowBbButton); + } + } + internal class SandboxManager : SharedSandboxManager, ISandboxManager { #pragma warning disable 649 + [Dependency] private readonly IClientConsole _console; [Dependency] private readonly IGameHud _gameHud; [Dependency] private readonly IClientNetManager _netManager; [Dependency] private readonly ILocalizationManager _localization; @@ -37,6 +96,7 @@ namespace Content.Client.Sandbox private EntitySpawnWindow _spawnWindow; private TileSpawnWindow _tilesSpawnWindow; private bool _sandboxWindowToggled; + bool SpawnEntitiesButton { get; set; } public void Initialize() { @@ -47,6 +107,10 @@ namespace Content.Client.Sandbox _netManager.RegisterNetMessage(nameof(MsgSandboxRespawn)); + _netManager.RegisterNetMessage(nameof(MsgSandboxGiveAghost)); + + _netManager.RegisterNetMessage(nameof(MsgSandboxSuicide)); + _gameHud.SandboxButtonToggled = SandboxButtonPressed; _inputManager.SetInputCommand(ContentKeyFunctions.OpenEntitySpawnWindow, @@ -111,12 +175,16 @@ namespace Content.Client.Sandbox _window.SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked; _window.SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked; _window.GiveFullAccessButton.OnPressed += OnGiveAdminAccessButtonClicked; + _window.GiveAghostButton.OnPressed += OnGiveAghostButtonClicked; + _window.ToggleLightButton.OnToggled += OnToggleLightButtonClicked; + _window.SuicideButton.OnPressed += OnSuicideButtonClicked; + _window.ToggleSubfloorButton.OnPressed += OnToggleSubfloorButtonClicked; + _window.ShowMarkersButton.OnPressed += OnShowMarkersButtonClicked; + _window.ShowBbButton.OnPressed += OnShowBbButtonClicked; _window.OpenCentered(); } - - private void WindowOnOnClose() { _window = null; @@ -139,13 +207,44 @@ namespace Content.Client.Sandbox ToggleTilesWindow(); } + private void OnToggleLightButtonClicked(BaseButton.ButtonEventArgs args) + { + ToggleLight(); + } + + private void OnToggleSubfloorButtonClicked(BaseButton.ButtonEventArgs args) + { + ToggleSubfloor(); + } + + private void OnShowMarkersButtonClicked(BaseButton.ButtonEventArgs args) + { + ShowMarkers(); + } + + private void OnShowBbButtonClicked(BaseButton.ButtonEventArgs args) + { + ShowBb(); + } + private void OnGiveAdminAccessButtonClicked(BaseButton.ButtonEventArgs args) { _netManager.ClientSendMessage(_netManager.CreateNetMessage()); } + + private void OnGiveAghostButtonClicked(BaseButton.ButtonEventArgs args) + { + _netManager.ClientSendMessage(_netManager.CreateNetMessage()); + } + + private void OnSuicideButtonClicked(BaseButton.ButtonEventArgs args) + { + _netManager.ClientSendMessage(_netManager.CreateNetMessage()); + } + private void ToggleEntitySpawnWindow() { - if(_spawnWindow == null) + if (_spawnWindow == null) _spawnWindow = new EntitySpawnWindow(_placementManager, _prototypeManager, _resourceCache, _localization); if (_spawnWindow.IsOpen) @@ -161,7 +260,7 @@ namespace Content.Client.Sandbox private void ToggleTilesWindow() { - if(_tilesSpawnWindow == null) + if (_tilesSpawnWindow == null) _tilesSpawnWindow = new TileSpawnWindow(_tileDefinitionManager, _placementManager, _resourceCache); if (_tilesSpawnWindow.IsOpen) @@ -174,5 +273,25 @@ namespace Content.Client.Sandbox _tilesSpawnWindow.OpenToLeft(); } } + + private void ToggleLight() + { + _console.ProcessCommand("togglelight"); + } + + private void ToggleSubfloor() + { + _console.ProcessCommand("showsubfloor"); + } + + private void ShowMarkers() + { + _console.ProcessCommand("showmarkers"); + } + + private void ShowBb() + { + _console.ProcessCommand("showbb"); + } } } diff --git a/Content.Client/Sandbox/SandboxWindow.cs b/Content.Client/Sandbox/SandboxWindow.cs deleted file mode 100644 index b1db694d01..0000000000 --- a/Content.Client/Sandbox/SandboxWindow.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; -using Robust.Shared.Localization; - -namespace Content.Client.Sandbox -{ - public sealed class SandboxWindow : SS14Window - { - public Button RespawnButton { get; } - public Button SpawnEntitiesButton { get; } - public Button SpawnTilesButton { get; } - - public Button GiveFullAccessButton { get; } //A button that just puts a captain's ID in your hands. - - public SandboxWindow(ILocalizationManager loc) - { - Title = loc.GetString("Sandbox Panel"); - - RespawnButton = new Button - { - Text = loc.GetString("Respawn") - }; - - SpawnEntitiesButton = new Button - { - Text = loc.GetString("Spawn Entities") - }; - - SpawnTilesButton = new Button - { - Text = loc.GetString("Spawn Tiles") - }; - - GiveFullAccessButton = new Button - { - Text = loc.GetString("Give Full Access ID") - }; - - Contents.AddChild(new VBoxContainer - { - Children = - { - RespawnButton, - SpawnEntitiesButton, - SpawnTilesButton, - GiveFullAccessButton - } - }); - } - } -} diff --git a/Content.Server/Sandbox/SandboxManager.cs b/Content.Server/Sandbox/SandboxManager.cs index 3492db968c..0b63ac5644 100644 --- a/Content.Server/Sandbox/SandboxManager.cs +++ b/Content.Server/Sandbox/SandboxManager.cs @@ -1,8 +1,10 @@ +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components.GUI; using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameTicking; using Content.Server.Interfaces.GameTicking; using Content.Shared.Sandbox; +using Robust.Server.Interfaces.Console; using Robust.Server.Console; using Robust.Server.Interfaces.Placement; using Robust.Server.Interfaces.Player; @@ -24,6 +26,7 @@ namespace Content.Server.Sandbox [Dependency] private readonly IPlacementManager _placementManager; [Dependency] private readonly IConGroupController _conGroupController; [Dependency] private readonly IEntityManager _entityManager; + [Dependency] private readonly IConsoleShell _shell; #pragma warning restore 649 private bool _isSandboxEnabled; @@ -44,6 +47,8 @@ namespace Content.Server.Sandbox _netManager.RegisterNetMessage(nameof(MsgSandboxStatus)); _netManager.RegisterNetMessage(nameof(MsgSandboxRespawn), SandboxRespawnReceived); _netManager.RegisterNetMessage(nameof(MsgSandboxGiveAccess), SandboxGiveAccessReceived); + _netManager.RegisterNetMessage(nameof(MsgSandboxGiveAghost), SandboxGiveAghostReceived); + _netManager.RegisterNetMessage(nameof(MsgSandboxSuicide), SandboxSuicideReceived); _playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _gameTicker.OnRunLevelChanged += GameTickerOnOnRunLevelChanged; @@ -116,6 +121,28 @@ namespace Content.Server.Sandbox } } + private void SandboxGiveAghostReceived(MsgSandboxGiveAghost message) + { + if (!IsSandboxEnabled) + { + return; + } + + var player = _playerManager.GetSessionByChannel(message.MsgChannel); + _shell.ExecuteCommand(player, $"aghost"); + } + + private void SandboxSuicideReceived(MsgSandboxSuicide message) + { + if (!IsSandboxEnabled) + { + return; + } + + var player = _playerManager.GetSessionByChannel(message.MsgChannel); + _shell.ExecuteCommand(player, $"suicide"); + } + private void UpdateSandboxStatusForAll() { var msg = _netManager.CreateNetMessage(); diff --git a/Content.Shared/Sandbox/SharedSandboxManager.cs b/Content.Shared/Sandbox/SharedSandboxManager.cs index 774ad66443..5276cb911c 100644 --- a/Content.Shared/Sandbox/SharedSandboxManager.cs +++ b/Content.Shared/Sandbox/SharedSandboxManager.cs @@ -1,4 +1,4 @@ -using Lidgren.Network; +using Lidgren.Network; using Robust.Shared.Interfaces.Network; using Robust.Shared.Network; @@ -66,5 +66,43 @@ namespace Content.Shared.Sandbox } } + + protected sealed class MsgSandboxGiveAghost : NetMessage + { + #region REQUIRED + + public const MsgGroups GROUP = MsgGroups.Command; + public const string NAME = nameof(MsgSandboxGiveAghost); + public MsgSandboxGiveAghost(INetChannel channel) : base(NAME, GROUP) { } + + #endregion + public override void ReadFromBuffer(NetIncomingMessage buffer) + { + } + + public override void WriteToBuffer(NetOutgoingMessage buffer) + { + } + + } + + protected sealed class MsgSandboxSuicide : NetMessage + { + #region REQUIRED + + public const MsgGroups GROUP = MsgGroups.Command; + public const string NAME = nameof(MsgSandboxSuicide); + public MsgSandboxSuicide(INetChannel channel) : base(NAME, GROUP) { } + + #endregion + public override void ReadFromBuffer(NetIncomingMessage buffer) + { + } + + public override void WriteToBuffer(NetOutgoingMessage buffer) + { + } + + } } } diff --git a/Resources/Textures/Interface/Nano/cross.svg b/Resources/Textures/Interface/Nano/cross.svg index b91b944e56..a73977ddc9 100644 --- a/Resources/Textures/Interface/Nano/cross.svg +++ b/Resources/Textures/Interface/Nano/cross.svg @@ -1,86 +1,3 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - + + diff --git a/Resources/Textures/Interface/Nano/cross.svg.png b/Resources/Textures/Interface/Nano/cross.svg.png index db213ed45b2e16e8dddac99c6a9e120e2b608afd..539f5f23898ba8e1f0a1d91f435b93112f909bd1 100644 GIT binary patch delta 260 zcmV+f0sH>+0-yqrB!A~gL_t(Ijh)qN3W7ioz;WqwkDEkvhA4ult{EX6p@(&-9`KJX z2e!=}XB=2j#`(GKLkmFK3@D>(Zws{xsgdF_aOWFU2lQ0eK7fh9s|c02IM8!a8}N1f zv@|SuuC@xvVU2k49C`&t@r@o_Lw_dEgQsKqhc>|)z6W*|G<^qaxCzx@E8d8>xZ&6V zZN)=!Q-7SjXbyh@TST)v->)Fc1LH zgB7(K75x7am;*Bm@By@tZ~!tTLzzo{sUe{&%npg9{!#{KT7Cj>ZE#HOsRHiE9&F_2Xq`i z11;l8bYuKNk5ahYNG}~nI<+_R2pwlXUr0OlY@VPK@NMm(A4HRQbNHH`dJCyBHGJtW re*AkgH1=(2Yn2u%Z@b(EvxtZ