Admin Menu (#1648)

* First Prototype

* Command Window

* Dropdown

* Is this better?

* That's kinda better?

* Added divider

* Shit

* Check if Admin Menu & Commands are allowed

* -Funcy Shit
-Now gets properly the playerlist
-Fixed kick reason

* Dropdown Improvement with some more func

* -Added DirectCommand for commands that don't need a ui
-Added RestartRound

* Better way to make DirectCommandButtons

* -Some new Tabs
-Player list

* -Split Buttons
-Regions
-Fixed Test Command

* Some server buttons

* Playerlist alignment

* Fucky SpawnEntites & SpawnTiles in AdminBus

* -Debug Buttons
-Few more commands

* -Make dem controls thicc
-SpinBox

* Escape Kick Reason

* Only create the window when you press the button

* Adds StationEvents

* Nullable "fixes"

* This thing wasn't made for buttons

* Call other constructor for empty CommandButton

* Request method in the interface

* -Pushed most Controls to be fields
-No more dict passing
-Removed test cmd
-Regions to better navigate

* -Bound to key
-Removed from escape menu
-Remember cmd windows
-Close all cmd windows on toggle

* -Moved dependency

* Merge fixes

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Exp
2020-08-25 17:18:32 +02:00
committed by GitHub
parent c665e66318
commit 292ef4ef16
10 changed files with 790 additions and 2 deletions

View File

@@ -0,0 +1,103 @@
using Content.Shared.Input;
using Robust.Client.Console;
using Robust.Client.Interfaces.Input;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using System.Collections.Generic;
namespace Content.Client.UserInterface.AdminMenu
{
internal class AdminMenuManager : IAdminMenuManager
{
[Dependency] private INetManager _netManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IClientConGroupController _clientConGroupController = default!;
private SS14Window _window;
private List<SS14Window> _commandWindows;
public void Initialize()
{
_commandWindows = new List<SS14Window>();
// Reset the AdminMenu Window on disconnect
_netManager.Disconnect += (sender, channel) => ResetWindow();
_inputManager.SetInputCommand(ContentKeyFunctions.OpenAdminMenu,
InputCmdHandler.FromDelegate(session => Toggle()));
}
public void ResetWindow()
{
_window?.Close();
_window = null;
foreach (var window in _commandWindows)
window?.Dispose();
_commandWindows.Clear();
}
public void OpenCommand(SS14Window window)
{
_commandWindows.Add(window);
window.OpenCentered();
}
public void Open()
{
if (_window == null)
_window = new AdminMenuWindow();
_window.OpenCentered();
}
public void Close()
{
_window?.Close();
foreach (var window in _commandWindows)
window?.Dispose();
_commandWindows.Clear();
}
/// <summary>
/// Checks if the player can open the window
/// </summary>
/// <returns>True if the player is allowed</returns>
public bool CanOpen()
{
return _clientConGroupController.CanAdminMenu();
}
/// <summary>
/// Checks if the player can open the window and tries to open it
/// </summary>
public void TryOpen()
{
if (CanOpen())
Open();
}
public void Toggle()
{
if (_window != null && _window.IsOpen)
{
Close();
}
else
{
TryOpen();
}
}
}
internal interface IAdminMenuManager
{
void Initialize();
void Open();
void OpenCommand(SS14Window window);
bool CanOpen();
void TryOpen();
void Toggle();
}
}