Modify admin chat (#13050)
* split admin chat into new channel * add ability to play audio when a chat message is received and add audio to admin chat * give client control of AdminChat sound and volume + suppress sound for senders
This commit is contained in:
@@ -420,6 +420,7 @@ public sealed class ChatUIController : UIController
|
|||||||
if (_admin.HasFlag(AdminFlags.Admin))
|
if (_admin.HasFlag(AdminFlags.Admin))
|
||||||
{
|
{
|
||||||
FilterableChannels |= ChatChannel.Admin;
|
FilterableChannels |= ChatChannel.Admin;
|
||||||
|
FilterableChannels |= ChatChannel.AdminChat;
|
||||||
CanSendChannels |= ChatSelectChannel.Admin;
|
CanSendChannels |= ChatSelectChannel.Admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public sealed partial class ChannelFilterPopup : Popup
|
|||||||
ChatChannel.OOC,
|
ChatChannel.OOC,
|
||||||
ChatChannel.Dead,
|
ChatChannel.Dead,
|
||||||
ChatChannel.Admin,
|
ChatChannel.Admin,
|
||||||
|
ChatChannel.AdminChat,
|
||||||
ChatChannel.Server
|
ChatChannel.Server
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public sealed class ChannelSelectorButton : Button
|
|||||||
ChatSelectChannel.LOOC => Color.MediumTurquoise,
|
ChatSelectChannel.LOOC => Color.MediumTurquoise,
|
||||||
ChatSelectChannel.OOC => Color.LightSkyBlue,
|
ChatSelectChannel.OOC => Color.LightSkyBlue,
|
||||||
ChatSelectChannel.Dead => Color.MediumPurple,
|
ChatSelectChannel.Dead => Color.MediumPurple,
|
||||||
ChatSelectChannel.Admin => Color.Red,
|
ChatSelectChannel.Admin => Color.HotPink,
|
||||||
_ => Color.DarkGray
|
_ => Color.DarkGray
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ using Robust.Client.AutoGenerated;
|
|||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using static Robust.Client.UserInterface.Controls.LineEdit;
|
using static Robust.Client.UserInterface.Controls.LineEdit;
|
||||||
|
|
||||||
@@ -52,6 +54,9 @@ public partial class ChatBox : UIWidget
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg is { Read: false, AudioPath: { } })
|
||||||
|
SoundSystem.Play(msg.AudioPath, Filter.Local(), new AudioParams().WithVolume(msg.AudioVolume));
|
||||||
|
|
||||||
msg.Read = true;
|
msg.Read = true;
|
||||||
|
|
||||||
var color = msg.MessageColorOverride != null
|
var color = msg.MessageColorOverride != null
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
|
[Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum length a player-sent message can be sent
|
/// The maximum length a player-sent message can be sent
|
||||||
@@ -191,7 +192,18 @@ namespace Content.Server.Chat.Managers
|
|||||||
var wrappedMessage = Loc.GetString("chat-manager-send-admin-chat-wrap-message",
|
var wrappedMessage = Loc.GetString("chat-manager-send-admin-chat-wrap-message",
|
||||||
("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")),
|
("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")),
|
||||||
("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
|
("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
|
||||||
ChatMessageToMany(ChatChannel.Admin, message, wrappedMessage, default, false, true, clients.ToList());
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
var isSource = client != player.ConnectedClient;
|
||||||
|
ChatMessageToOne(ChatChannel.AdminChat,
|
||||||
|
message,
|
||||||
|
wrappedMessage,
|
||||||
|
default,
|
||||||
|
false,
|
||||||
|
client,
|
||||||
|
audioPath: isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundPath) : default,
|
||||||
|
audioVolume: isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundVolume) : default);
|
||||||
|
}
|
||||||
|
|
||||||
_adminLogger.Add(LogType.Chat, $"Admin chat from {player:Player}: {message}");
|
_adminLogger.Add(LogType.Chat, $"Admin chat from {player:Player}: {message}");
|
||||||
}
|
}
|
||||||
@@ -200,21 +212,21 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
#region Utility
|
#region Utility
|
||||||
|
|
||||||
public void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, INetChannel client, Color? colorOverride = null, bool recordReplay = false)
|
public void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0)
|
||||||
{
|
{
|
||||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride);
|
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||||
_netManager.ServerSendMessage(new MsgChatMessage() { Message = msg }, client);
|
_netManager.ServerSendMessage(new MsgChatMessage() { Message = msg }, client);
|
||||||
|
|
||||||
if (recordReplay)
|
if (recordReplay)
|
||||||
_replay.QueueReplayMessage(msg);
|
_replay.QueueReplayMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, IEnumerable<INetChannel> clients, Color? colorOverride = null)
|
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, IEnumerable<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||||
=> ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients.ToList(), colorOverride);
|
=> ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients.ToList(), colorOverride, audioPath, audioVolume);
|
||||||
|
|
||||||
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, List<INetChannel> clients, Color? colorOverride = null)
|
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, List<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||||
{
|
{
|
||||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride);
|
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||||
_netManager.ServerSendToMany(new MsgChatMessage() { Message = msg }, clients);
|
_netManager.ServerSendToMany(new MsgChatMessage() { Message = msg }, clients);
|
||||||
|
|
||||||
if (recordReplay)
|
if (recordReplay)
|
||||||
@@ -222,7 +234,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string wrappedMessage, EntityUid source,
|
public void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string wrappedMessage, EntityUid source,
|
||||||
bool hideChat, bool recordReplay, Color? colorOverride = null)
|
bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||||
{
|
{
|
||||||
if (!recordReplay && !filter.Recipients.Any())
|
if (!recordReplay && !filter.Recipients.Any())
|
||||||
return;
|
return;
|
||||||
@@ -233,12 +245,12 @@ namespace Content.Server.Chat.Managers
|
|||||||
clients.Add(recipient.ConnectedClient);
|
clients.Add(recipient.ConnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients, colorOverride);
|
ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients, colorOverride, audioPath, audioVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null)
|
public void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||||
{
|
{
|
||||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride);
|
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||||
_netManager.ServerSendToAll(new MsgChatMessage() { Message = msg });
|
_netManager.ServerSendToAll(new MsgChatMessage() { Message = msg });
|
||||||
|
|
||||||
if (recordReplay)
|
if (recordReplay)
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ namespace Content.Server.Chat.Managers
|
|||||||
void SendAdminAnnouncement(string message);
|
void SendAdminAnnouncement(string message);
|
||||||
|
|
||||||
void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
|
void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
|
||||||
INetChannel client, Color? colorOverride = null, bool recordReplay = false);
|
INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0);
|
||||||
|
|
||||||
void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay,
|
void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay,
|
||||||
IEnumerable<INetChannel> clients, Color? colorOverride = null);
|
IEnumerable<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0);
|
||||||
|
|
||||||
void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride);
|
void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride, string? audioPath = null, float audioVolume = 0);
|
||||||
|
|
||||||
void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null);
|
void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0);
|
||||||
|
|
||||||
bool MessageCharacterLimit(IPlayerSession player, string message);
|
bool MessageCharacterLimit(IPlayerSession player, string message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -511,6 +511,10 @@ namespace Content.Shared.CCVar
|
|||||||
|
|
||||||
public static readonly CVarDef<bool> AdminSoundsEnabled =
|
public static readonly CVarDef<bool> AdminSoundsEnabled =
|
||||||
CVarDef.Create("audio.admin_sounds_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
CVarDef.Create("audio.admin_sounds_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
||||||
|
public static readonly CVarDef<string> AdminChatSoundPath =
|
||||||
|
CVarDef.Create("audio.admin_chat_sound_path", "/Audio/Items/pop.ogg", CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED);
|
||||||
|
public static readonly CVarDef<float> AdminChatSoundVolume =
|
||||||
|
CVarDef.Create("audio.admin_chat_sound_volume", -5f, CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HUD
|
* HUD
|
||||||
|
|||||||
@@ -60,14 +60,19 @@ namespace Content.Shared.Chat
|
|||||||
Dead = 1 << 9,
|
Dead = 1 << 9,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Admin chat
|
/// Misc admin messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Admin = 1 << 10,
|
Admin = 1 << 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Admin chat
|
||||||
|
/// </summary>
|
||||||
|
AdminChat = 1 << 11,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unspecified.
|
/// Unspecified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Unspecified = 1 << 11,
|
Unspecified = 1 << 12,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Channels considered to be IC.
|
/// Channels considered to be IC.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public static class ChatChannelExtensions
|
|||||||
ChatChannel.OOC => Color.LightSkyBlue,
|
ChatChannel.OOC => Color.LightSkyBlue,
|
||||||
ChatChannel.Dead => Color.MediumPurple,
|
ChatChannel.Dead => Color.MediumPurple,
|
||||||
ChatChannel.Admin => Color.Red,
|
ChatChannel.Admin => Color.Red,
|
||||||
|
ChatChannel.AdminChat => Color.HotPink,
|
||||||
ChatChannel.Whisper => Color.DarkGray,
|
ChatChannel.Whisper => Color.DarkGray,
|
||||||
_ => Color.LightGray
|
_ => Color.LightGray
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Admin chat
|
/// Admin chat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Admin = ChatChannel.Admin,
|
Admin = ChatChannel.AdminChat,
|
||||||
|
|
||||||
Console = ChatChannel.Unspecified
|
Console = ChatChannel.Unspecified
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ namespace Content.Shared.Chat
|
|||||||
public EntityUid SenderEntity;
|
public EntityUid SenderEntity;
|
||||||
public bool HideChat;
|
public bool HideChat;
|
||||||
public Color? MessageColorOverride;
|
public Color? MessageColorOverride;
|
||||||
|
public string? AudioPath;
|
||||||
|
public float AudioVolume;
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public bool Read;
|
public bool Read;
|
||||||
|
|
||||||
public ChatMessage(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat = false, Color? colorOverride = null)
|
public ChatMessage(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat = false, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||||
{
|
{
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
Message = message;
|
Message = message;
|
||||||
@@ -28,6 +30,8 @@ namespace Content.Shared.Chat
|
|||||||
SenderEntity = source;
|
SenderEntity = source;
|
||||||
HideChat = hideChat;
|
HideChat = hideChat;
|
||||||
MessageColorOverride = colorOverride;
|
MessageColorOverride = colorOverride;
|
||||||
|
AudioPath = audioPath;
|
||||||
|
AudioVolume = audioVolume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ hud-chatbox-select-channel-Damage = Damage
|
|||||||
hud-chatbox-select-channel-Visual = Actions
|
hud-chatbox-select-channel-Visual = Actions
|
||||||
hud-chatbox-select-channel-Radio = Radio
|
hud-chatbox-select-channel-Radio = Radio
|
||||||
|
|
||||||
hud-chatbox-channel-Admin = Admin
|
hud-chatbox-channel-Admin = Admin Misc
|
||||||
|
hud-chatbox-channel-AdminChat = Admin Chat
|
||||||
hud-chatbox-channel-Dead = Dead
|
hud-chatbox-channel-Dead = Dead
|
||||||
hud-chatbox-channel-Emotes = Emotes
|
hud-chatbox-channel-Emotes = Emotes
|
||||||
hud-chatbox-channel-Local = Local
|
hud-chatbox-channel-Local = Local
|
||||||
|
|||||||
Reference in New Issue
Block a user