Admin chat (#1287)

* Admin chat

* Change it to show username, not character name

* moves the thing

* Removes SenderEntity
This commit is contained in:
ike709
2020-07-08 05:18:16 -05:00
committed by GitHub
parent df395b9435
commit 2d2385032a
13 changed files with 124 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Content.Shared.Chat;
using Robust.Client.Console;
using Robust.Client.Graphics.Drawing;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -26,6 +27,7 @@ namespace Content.Client.Chat
public Button AllButton { get; }
public Button LocalButton { get; }
public Button OOCButton { get; }
public Button AdminButton { get; }
/// <summary>
/// Default formatting string for the ClientChatConsole.
@@ -59,6 +61,7 @@ namespace Content.Client.Chat
outerVBox.AddChild(panelContainer);
outerVBox.AddChild(hBox);
var contentMargin = new MarginContainer
{
MarginLeftOverride = 4, MarginRightOverride = 4,
@@ -95,6 +98,17 @@ namespace Content.Client.Chat
ToggleMode = true,
};
var groupController = IoCManager.Resolve<IClientConGroupController>();
if(groupController.CanCommand("asay"))
{
AdminButton = new Button
{
Text = _localize.GetString("Admin"),
Name = "Admin",
ToggleMode = true,
};
}
AllButton.OnToggled += OnFilterToggled;
LocalButton.OnToggled += OnFilterToggled;
OOCButton.OnToggled += OnFilterToggled;
@@ -102,6 +116,11 @@ namespace Content.Client.Chat
hBox.AddChild(AllButton);
hBox.AddChild(LocalButton);
hBox.AddChild(OOCButton);
if(AdminButton != null)
{
AdminButton.OnToggled += OnFilterToggled;
hBox.AddChild(AdminButton);
}
AddChild(outerVBox);
}

View File

@@ -48,6 +48,7 @@ namespace Content.Client.Chat
private const char ConCmdSlash = '/';
private const char OOCAlias = '[';
private const char MeAlias = '@';
private const char AdminChatAlias = ']';
private readonly List<StoredChatMessage> filteredHistory = new List<StoredChatMessage>();
@@ -55,6 +56,7 @@ namespace Content.Client.Chat
private bool _allState;
private bool _localState;
private bool _oocState;
private bool _adminState;
// Flag Enums for holding filtered channels
private ChatChannel _filteredChannels;
@@ -65,6 +67,7 @@ namespace Content.Client.Chat
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IClientConGroupController _groupController = default!;
#pragma warning restore 649
private ChatBox _currentChatBox;
@@ -150,6 +153,8 @@ namespace Content.Client.Chat
_currentChatBox.AllButton.Pressed = !_allState;
_currentChatBox.LocalButton.Pressed = !_localState;
_currentChatBox.OOCButton.Pressed = !_oocState;
if(chatBox.AdminButton != null)
_currentChatBox.AdminButton.Pressed = !_adminState;
}
public void RemoveSpeechBubble(EntityUid entityUid, SpeechBubble bubble)
@@ -193,6 +198,9 @@ namespace Content.Client.Chat
case ChatChannel.Dead:
color = Color.MediumPurple;
break;
case ChatChannel.AdminChat:
color = Color.Red;
break;
}
_currentChatBox?.AddLine(messageText, message.Channel, color);
@@ -220,6 +228,18 @@ namespace Content.Client.Chat
_console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
break;
}
case AdminChatAlias:
{
var conInput = text.Substring(1);
if(_groupController.CanCommand("asay")){
_console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\"");
}
else
{
_console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
}
break;
}
case MeAlias:
{
var conInput = text.Substring(1);
@@ -266,10 +286,23 @@ namespace Content.Client.Chat
_filteredChannels &= ~ChatChannel.OOC;
break;
}
case "Admin":
_adminState = !_adminState;
if (_adminState)
{
_filteredChannels |= ChatChannel.AdminChat;
break;
}
else
{
_filteredChannels &= ~ChatChannel.AdminChat;
break;
}
case "ALL":
chatBox.LocalButton.Pressed ^= true;
chatBox.OOCButton.Pressed ^= true;
chatBox.AdminButton.Pressed ^= true;
_allState = !_allState;
break;
}

View File

@@ -14,6 +14,7 @@ namespace Content.Client.Input
var common = contexts.GetContext("common");
common.AddFunction(ContentKeyFunctions.FocusChat);
common.AddFunction(ContentKeyFunctions.FocusOOC);
common.AddFunction(ContentKeyFunctions.FocusAdminChat);
common.AddFunction(ContentKeyFunctions.ExamineEntity);
common.AddFunction(ContentKeyFunctions.OpenTutorial);
common.AddFunction(ContentKeyFunctions.TakeScreenshot);

View File

@@ -4,6 +4,7 @@ using Content.Client.Chat;
using Content.Client.Interfaces.Chat;
using Content.Client.UserInterface;
using Content.Shared.Input;
using Robust.Client.Console;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.State;
using Robust.Client.Interfaces.UserInterface;
@@ -25,6 +26,7 @@ namespace Content.Client.State
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IChatManager _chatManager;
[Dependency] private readonly IClientConGroupController _groupController = default!;
#pragma warning restore 649
[ViewVariables] private ChatBox _gameChat;
@@ -34,6 +36,7 @@ namespace Content.Client.State
base.Startup();
_gameChat = new ChatBox();
_userInterfaceManager.StateRoot.AddChild(_gameChat);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
@@ -50,6 +53,9 @@ namespace Content.Client.State
_inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
InputCmdHandler.FromDelegate(s => FocusOOC(_gameChat)));
_inputManager.SetInputCommand(ContentKeyFunctions.FocusAdminChat,
InputCmdHandler.FromDelegate(s => FocusAdminChat(_gameChat)));
}
public override void Shutdown()
@@ -81,5 +87,17 @@ namespace Content.Client.State
chat.Input.GrabKeyboardFocus();
chat.Input.InsertAtCursor("[");
}
internal static void FocusAdminChat(ChatBox chat)
{
if (chat == null || chat.UserInterfaceManager.KeyboardFocused != null)
{
return;
}
chat.Input.IgnoreNext = true;
chat.Input.GrabKeyboardFocus();
chat.Input.InsertAtCursor("]");
}
}
}

View File

@@ -76,6 +76,7 @@ Open character window: [color=#a4885c]{8}[/color]
Open crafting window: [color=#a4885c]{9}[/color]
Focus chat: [color=#a4885c]{10}[/color]
Focus OOC: [color=#a4885c]{26}[/color]
Focus Admin Chat: [color=#a4885c]{27}[/color]
Use hand/object in hand: [color=#a4885c]{22}[/color]
Do wide attack: [color=#a4885c]{23}[/color]
Use targeted entity: [color=#a4885c]{11}[/color]
@@ -112,7 +113,8 @@ Toggle sandbox window: [color=#a4885c]{21}[/color]",
Key(WideAttack),
Key(SmartEquipBackpack),
Key(SmartEquipBelt),
Key(FocusOOC)));
Key(FocusOOC),
Key(FocusAdminChat)));
//Gameplay
VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" });