Allows admins to see deadchat and adds a toggle for deadchat for admins and ghosts (#2904)
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Content.Client.Chat
|
||||
public Button LocalButton { get; }
|
||||
public Button OOCButton { get; }
|
||||
public Button AdminButton { get; }
|
||||
public Button DeadButton { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Default formatting string for the ClientChatConsole.
|
||||
@@ -103,13 +104,23 @@ namespace Content.Client.Chat
|
||||
Visible = false
|
||||
};
|
||||
|
||||
DeadButton = new Button
|
||||
{
|
||||
Text = Loc.GetString("Dead"),
|
||||
Name = "Dead",
|
||||
ToggleMode = true,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
AllButton.OnToggled += OnFilterToggled;
|
||||
LocalButton.OnToggled += OnFilterToggled;
|
||||
OOCButton.OnToggled += OnFilterToggled;
|
||||
AdminButton.OnToggled += OnFilterToggled;
|
||||
DeadButton.OnToggled += OnFilterToggled;
|
||||
|
||||
hBox.AddChild(AllButton);
|
||||
hBox.AddChild(LocalButton);
|
||||
hBox.AddChild(DeadButton);
|
||||
hBox.AddChild(OOCButton);
|
||||
hBox.AddChild(AdminButton);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Administration;
|
||||
using Content.Client.Interfaces.Chat;
|
||||
using Content.Shared.Administration;
|
||||
@@ -61,13 +61,14 @@ namespace Content.Client.Chat
|
||||
private const char MeAlias = '@';
|
||||
private const char AdminChatAlias = ']';
|
||||
|
||||
private readonly List<StoredChatMessage> filteredHistory = new();
|
||||
private readonly List<StoredChatMessage> _filteredHistory = new();
|
||||
|
||||
// Filter Button States
|
||||
private bool _allState;
|
||||
private bool _localState;
|
||||
private bool _oocState;
|
||||
private bool _adminState;
|
||||
private bool _deadState;
|
||||
|
||||
// Flag Enums for holding filtered channels
|
||||
private ChatChannel _filteredChannels;
|
||||
@@ -98,8 +99,8 @@ namespace Content.Client.Chat
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME, _onChatMessage);
|
||||
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(ChatMaxMsgLengthMessage.NAME, _onMaxLengthReceived);
|
||||
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME, OnChatMessage);
|
||||
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(ChatMaxMsgLengthMessage.NAME, OnMaxLengthReceived);
|
||||
|
||||
_speechBubbleRoot = new LayoutContainer();
|
||||
LayoutContainer.SetAnchorPreset(_speechBubbleRoot, LayoutContainer.LayoutPreset.Wide);
|
||||
@@ -152,24 +153,25 @@ namespace Content.Client.Chat
|
||||
{
|
||||
if (_currentChatBox != null)
|
||||
{
|
||||
_currentChatBox.TextSubmitted -= _onChatBoxTextSubmitted;
|
||||
_currentChatBox.FilterToggled -= _onFilterButtonToggled;
|
||||
_currentChatBox.TextSubmitted -= OnChatBoxTextSubmitted;
|
||||
_currentChatBox.FilterToggled -= OnFilterButtonToggled;
|
||||
}
|
||||
|
||||
_currentChatBox = chatBox;
|
||||
if (_currentChatBox != null)
|
||||
{
|
||||
_currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
|
||||
_currentChatBox.FilterToggled += _onFilterButtonToggled;
|
||||
_currentChatBox.TextSubmitted += OnChatBoxTextSubmitted;
|
||||
_currentChatBox.FilterToggled += OnFilterButtonToggled;
|
||||
|
||||
_currentChatBox.AllButton.Pressed = !_allState;
|
||||
_currentChatBox.LocalButton.Pressed = !_localState;
|
||||
_currentChatBox.OOCButton.Pressed = !_oocState;
|
||||
_currentChatBox.AdminButton.Pressed = !_adminState;
|
||||
_currentChatBox.DeadButton.Pressed = !_deadState;
|
||||
AdminStatusUpdated();
|
||||
}
|
||||
|
||||
RepopulateChat(filteredHistory);
|
||||
RepopulateChat(_filteredHistory);
|
||||
}
|
||||
|
||||
public void RemoveSpeechBubble(EntityUid entityUid, SpeechBubble bubble)
|
||||
@@ -224,7 +226,7 @@ namespace Content.Client.Chat
|
||||
_currentChatBox?.AddLine(messageText, message.Channel, color);
|
||||
}
|
||||
|
||||
private void _onChatBoxTextSubmitted(ChatBox chatBox, string text)
|
||||
private void OnChatBoxTextSubmitted(ChatBox chatBox, string text)
|
||||
{
|
||||
DebugTools.Assert(chatBox == _currentChatBox);
|
||||
|
||||
@@ -295,7 +297,7 @@ namespace Content.Client.Chat
|
||||
}
|
||||
}
|
||||
|
||||
private void _onFilterButtonToggled(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e)
|
||||
private void OnFilterButtonToggled(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e)
|
||||
{
|
||||
switch (e.Button.Name)
|
||||
{
|
||||
@@ -336,6 +338,13 @@ namespace Content.Client.Chat
|
||||
_filteredChannels &= ~ChatChannel.AdminChat;
|
||||
break;
|
||||
}
|
||||
case "Dead":
|
||||
_deadState = !_deadState;
|
||||
if (_deadState)
|
||||
_filteredChannels |= ChatChannel.Dead;
|
||||
else
|
||||
_filteredChannels &= ~ChatChannel.Dead;
|
||||
break;
|
||||
|
||||
case "ALL":
|
||||
chatBox.LocalButton.Pressed ^= true;
|
||||
@@ -346,7 +355,7 @@ namespace Content.Client.Chat
|
||||
break;
|
||||
}
|
||||
|
||||
RepopulateChat(filteredHistory);
|
||||
RepopulateChat(_filteredHistory);
|
||||
}
|
||||
|
||||
private void RepopulateChat(IEnumerable<StoredChatMessage> filteredMessages)
|
||||
@@ -364,11 +373,11 @@ namespace Content.Client.Chat
|
||||
}
|
||||
}
|
||||
|
||||
private void _onChatMessage(MsgChatMessage msg)
|
||||
private void OnChatMessage(MsgChatMessage msg)
|
||||
{
|
||||
// Log all incoming chat to repopulate when filter is un-toggled
|
||||
var storedMessage = new StoredChatMessage(msg);
|
||||
filteredHistory.Add(storedMessage);
|
||||
_filteredHistory.Add(storedMessage);
|
||||
WriteChatMessage(storedMessage);
|
||||
|
||||
// Local messages that have an entity attached get a speech bubble.
|
||||
@@ -388,7 +397,7 @@ namespace Content.Client.Chat
|
||||
}
|
||||
}
|
||||
|
||||
private void _onMaxLengthReceived(ChatMaxMsgLengthMessage msg)
|
||||
private void OnMaxLengthReceived(ChatMaxMsgLengthMessage msg)
|
||||
{
|
||||
_maxMessageLength = msg.MaxMessageLength;
|
||||
}
|
||||
@@ -522,6 +531,18 @@ namespace Content.Client.Chat
|
||||
if (_currentChatBox != null)
|
||||
{
|
||||
_currentChatBox.AdminButton.Visible = _adminMgr.HasFlag(AdminFlags.Admin);
|
||||
_currentChatBox.DeadButton.Visible = _adminMgr.HasFlag(AdminFlags.Admin);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleDeadChatButtonVisibility(bool visibility)
|
||||
{
|
||||
if (_currentChatBox != null)
|
||||
{
|
||||
// If the user is an admin and returned to body, don't set the flag as null
|
||||
if (!visibility && _adminMgr.HasFlag(AdminFlags.Admin))
|
||||
return;
|
||||
_currentChatBox.DeadButton.Visible = visibility;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Interfaces.Chat;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -19,6 +20,7 @@ namespace Content.Client.GameObjects.Components.Observer
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IComponentManager _componentManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
public List<string> WarpNames = new();
|
||||
public Dictionary<EntityUid,string> PlayerNames = new();
|
||||
|
||||
@@ -83,6 +85,7 @@ namespace Content.Client.GameObjects.Components.Observer
|
||||
_gameHud.HandsContainer.AddChild(_gui);
|
||||
SetGhostVisibility(true);
|
||||
_isAttached = true;
|
||||
_chatManager.ToggleDeadChatButtonVisibility(true);
|
||||
|
||||
break;
|
||||
|
||||
@@ -90,6 +93,7 @@ namespace Content.Client.GameObjects.Components.Observer
|
||||
_gui!.Parent?.RemoveChild(_gui);
|
||||
SetGhostVisibility(false);
|
||||
_isAttached = false;
|
||||
_chatManager.ToggleDeadChatButtonVisibility(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace Content.Client.Interfaces.Chat
|
||||
void SetChatBox(ChatBox chatBox);
|
||||
|
||||
void RemoveSpeechBubble(EntityUid entityUid, SpeechBubble bubble);
|
||||
|
||||
void ToggleDeadChatButtonVisibility(bool visibility);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.Server.Chat
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME);
|
||||
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(ChatMaxMsgLengthMessage.NAME, _onMaxLengthRequest);
|
||||
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(ChatMaxMsgLengthMessage.NAME, OnMaxLengthRequest);
|
||||
|
||||
// Tell all the connected players the chat's character limit
|
||||
var msg = _netManager.CreateNetMessage<ChatMaxMsgLengthMessage>();
|
||||
@@ -244,7 +244,8 @@ namespace Content.Server.Chat
|
||||
{
|
||||
return _playerManager
|
||||
.GetPlayersBy(x => x.AttachedEntity != null && x.AttachedEntity.HasComponent<GhostComponent>())
|
||||
.Select(p => p.ConnectedClient);
|
||||
.Select(p => p.ConnectedClient)
|
||||
.Union(_adminManager.ActiveAdmins.Select(p => p.ConnectedClient));
|
||||
}
|
||||
|
||||
public void SendAdminChat(IPlayerSession player, string message)
|
||||
@@ -288,7 +289,7 @@ namespace Content.Server.Chat
|
||||
_netManager.ServerSendToAll(msg);
|
||||
}
|
||||
|
||||
private void _onMaxLengthRequest(ChatMaxMsgLengthMessage msg)
|
||||
private void OnMaxLengthRequest(ChatMaxMsgLengthMessage msg)
|
||||
{
|
||||
var response = _netManager.CreateNetMessage<ChatMaxMsgLengthMessage>();
|
||||
response.MaxMessageLength = MaxMessageLength;
|
||||
|
||||
Reference in New Issue
Block a user