More sandbox buttons for fun and pleasure (#1599)
* 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 <zddm@outlook.es>
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
|
using Content.Client.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Sandbox;
|
using Content.Shared.Sandbox;
|
||||||
|
using Robust.Client.Console;
|
||||||
|
using Robust.Client.Interfaces.Console;
|
||||||
using Robust.Client.Interfaces.Input;
|
using Robust.Client.Interfaces.Input;
|
||||||
|
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||||
using Robust.Client.Interfaces.Placement;
|
using Robust.Client.Interfaces.Placement;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
@@ -16,9 +20,64 @@ using Robust.Shared.Prototypes;
|
|||||||
|
|
||||||
namespace Content.Client.Sandbox
|
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
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IClientConsole _console;
|
||||||
[Dependency] private readonly IGameHud _gameHud;
|
[Dependency] private readonly IGameHud _gameHud;
|
||||||
[Dependency] private readonly IClientNetManager _netManager;
|
[Dependency] private readonly IClientNetManager _netManager;
|
||||||
[Dependency] private readonly ILocalizationManager _localization;
|
[Dependency] private readonly ILocalizationManager _localization;
|
||||||
@@ -37,6 +96,7 @@ namespace Content.Client.Sandbox
|
|||||||
private EntitySpawnWindow _spawnWindow;
|
private EntitySpawnWindow _spawnWindow;
|
||||||
private TileSpawnWindow _tilesSpawnWindow;
|
private TileSpawnWindow _tilesSpawnWindow;
|
||||||
private bool _sandboxWindowToggled;
|
private bool _sandboxWindowToggled;
|
||||||
|
bool SpawnEntitiesButton { get; set; }
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
@@ -47,6 +107,10 @@ namespace Content.Client.Sandbox
|
|||||||
|
|
||||||
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn));
|
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn));
|
||||||
|
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxGiveAghost>(nameof(MsgSandboxGiveAghost));
|
||||||
|
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxSuicide>(nameof(MsgSandboxSuicide));
|
||||||
|
|
||||||
_gameHud.SandboxButtonToggled = SandboxButtonPressed;
|
_gameHud.SandboxButtonToggled = SandboxButtonPressed;
|
||||||
|
|
||||||
_inputManager.SetInputCommand(ContentKeyFunctions.OpenEntitySpawnWindow,
|
_inputManager.SetInputCommand(ContentKeyFunctions.OpenEntitySpawnWindow,
|
||||||
@@ -111,12 +175,16 @@ namespace Content.Client.Sandbox
|
|||||||
_window.SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked;
|
_window.SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked;
|
||||||
_window.SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked;
|
_window.SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked;
|
||||||
_window.GiveFullAccessButton.OnPressed += OnGiveAdminAccessButtonClicked;
|
_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();
|
_window.OpenCentered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void WindowOnOnClose()
|
private void WindowOnOnClose()
|
||||||
{
|
{
|
||||||
_window = null;
|
_window = null;
|
||||||
@@ -139,13 +207,44 @@ namespace Content.Client.Sandbox
|
|||||||
ToggleTilesWindow();
|
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)
|
private void OnGiveAdminAccessButtonClicked(BaseButton.ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgSandboxGiveAccess>());
|
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgSandboxGiveAccess>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGiveAghostButtonClicked(BaseButton.ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgSandboxGiveAghost>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSuicideButtonClicked(BaseButton.ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgSandboxSuicide>());
|
||||||
|
}
|
||||||
|
|
||||||
private void ToggleEntitySpawnWindow()
|
private void ToggleEntitySpawnWindow()
|
||||||
{
|
{
|
||||||
if(_spawnWindow == null)
|
if (_spawnWindow == null)
|
||||||
_spawnWindow = new EntitySpawnWindow(_placementManager, _prototypeManager, _resourceCache, _localization);
|
_spawnWindow = new EntitySpawnWindow(_placementManager, _prototypeManager, _resourceCache, _localization);
|
||||||
|
|
||||||
if (_spawnWindow.IsOpen)
|
if (_spawnWindow.IsOpen)
|
||||||
@@ -161,7 +260,7 @@ namespace Content.Client.Sandbox
|
|||||||
|
|
||||||
private void ToggleTilesWindow()
|
private void ToggleTilesWindow()
|
||||||
{
|
{
|
||||||
if(_tilesSpawnWindow == null)
|
if (_tilesSpawnWindow == null)
|
||||||
_tilesSpawnWindow = new TileSpawnWindow(_tileDefinitionManager, _placementManager, _resourceCache);
|
_tilesSpawnWindow = new TileSpawnWindow(_tileDefinitionManager, _placementManager, _resourceCache);
|
||||||
|
|
||||||
if (_tilesSpawnWindow.IsOpen)
|
if (_tilesSpawnWindow.IsOpen)
|
||||||
@@ -174,5 +273,25 @@ namespace Content.Client.Sandbox
|
|||||||
_tilesSpawnWindow.OpenToLeft();
|
_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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Shared.Sandbox;
|
using Content.Shared.Sandbox;
|
||||||
|
using Robust.Server.Interfaces.Console;
|
||||||
using Robust.Server.Console;
|
using Robust.Server.Console;
|
||||||
using Robust.Server.Interfaces.Placement;
|
using Robust.Server.Interfaces.Placement;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
@@ -24,6 +26,7 @@ namespace Content.Server.Sandbox
|
|||||||
[Dependency] private readonly IPlacementManager _placementManager;
|
[Dependency] private readonly IPlacementManager _placementManager;
|
||||||
[Dependency] private readonly IConGroupController _conGroupController;
|
[Dependency] private readonly IConGroupController _conGroupController;
|
||||||
[Dependency] private readonly IEntityManager _entityManager;
|
[Dependency] private readonly IEntityManager _entityManager;
|
||||||
|
[Dependency] private readonly IConsoleShell _shell;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private bool _isSandboxEnabled;
|
private bool _isSandboxEnabled;
|
||||||
@@ -44,6 +47,8 @@ namespace Content.Server.Sandbox
|
|||||||
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus));
|
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus));
|
||||||
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn), SandboxRespawnReceived);
|
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn), SandboxRespawnReceived);
|
||||||
_netManager.RegisterNetMessage<MsgSandboxGiveAccess>(nameof(MsgSandboxGiveAccess), SandboxGiveAccessReceived);
|
_netManager.RegisterNetMessage<MsgSandboxGiveAccess>(nameof(MsgSandboxGiveAccess), SandboxGiveAccessReceived);
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxGiveAghost>(nameof(MsgSandboxGiveAghost), SandboxGiveAghostReceived);
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxSuicide>(nameof(MsgSandboxSuicide), SandboxSuicideReceived);
|
||||||
|
|
||||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||||
_gameTicker.OnRunLevelChanged += GameTickerOnOnRunLevelChanged;
|
_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()
|
private void UpdateSandboxStatusForAll()
|
||||||
{
|
{
|
||||||
var msg = _netManager.CreateNetMessage<MsgSandboxStatus>();
|
var msg = _netManager.CreateNetMessage<MsgSandboxStatus>();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 57 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 288 B |
Reference in New Issue
Block a user