From 3a31a33075688b0298feb11921d05c48bb0d53d6 Mon Sep 17 00:00:00 2001 From: Chris V Date: Tue, 1 Mar 2022 05:21:28 -0800 Subject: [PATCH] Add a Color parameter to dispatching announcements, change the color of certain common messages (#6840) --- Content.Server/Chat/Managers/ChatManager.cs | 14 +++++++++----- Content.Server/Chat/Managers/IChatManager.cs | 7 +++++-- .../CommunicationsConsoleComponent.cs | 2 +- Content.Server/Nuke/NukeSystem.cs | 2 +- Content.Server/RoundEnd/RoundEndSystem.cs | 2 +- Content.Server/Salvage/SalvageSystem.cs | 4 ++-- .../StationEvents/Events/StationEvent.cs | 4 ++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index f29211c860..b715facfd7 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -109,19 +109,19 @@ namespace Content.Server.Chat.Managers DispatchServerAnnouncement(Loc.GetString(val ? "chat-manager-admin-ooc-chat-enabled-message" : "chat-manager-admin-ooc-chat-disabled-message")); } - public void DispatchServerAnnouncement(string message) + public void DispatchServerAnnouncement(string message, Color? colorOverride = null) { var messageWrap = Loc.GetString("chat-manager-server-wrap-message"); - NetMessageToAll(ChatChannel.Server, message, messageWrap); + NetMessageToAll(ChatChannel.Server, message, messageWrap, colorOverride); Logger.InfoS("SERVER", message); _logs.Add(LogType.Chat, LogImpact.Low, $"Server announcement: {message}"); } - public void DispatchStationAnnouncement(string message, string sender = "Central Command", bool playDefaultSound = true) + public void DispatchStationAnnouncement(string message, string sender = "Central Command", bool playDefaultSound = true, Color? colorOverride = null) { var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender)); - NetMessageToAll(ChatChannel.Radio, message, messageWrap); + NetMessageToAll(ChatChannel.Radio, message, messageWrap, colorOverride); if (playDefaultSound) { SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f)); @@ -596,12 +596,16 @@ namespace Content.Server.Chat.Managers _netManager.ServerSendMessage(msg, client); } - public void NetMessageToAll(ChatChannel channel, string message, string messageWrap) + public void NetMessageToAll(ChatChannel channel, string message, string messageWrap, Color? colorOverride = null) { var msg = _netManager.CreateNetMessage(); msg.Channel = channel; msg.Message = message; msg.MessageWrap = messageWrap; + if (colorOverride != null) + { + msg.MessageColorOverride = colorOverride.Value; + } _netManager.ServerSendToAll(msg); } diff --git a/Content.Server/Chat/Managers/IChatManager.cs b/Content.Server/Chat/Managers/IChatManager.cs index d14e7dd253..3ad8fdef7c 100644 --- a/Content.Server/Chat/Managers/IChatManager.cs +++ b/Content.Server/Chat/Managers/IChatManager.cs @@ -12,7 +12,9 @@ namespace Content.Server.Chat.Managers /// /// Dispatch a server announcement to every connected player. /// - void DispatchServerAnnouncement(string message); + /// + /// Override the color of the message being sent. + void DispatchServerAnnouncement(string message, Color? colorOverride = null); /// /// Station announcement to every player @@ -20,7 +22,8 @@ namespace Content.Server.Chat.Managers /// /// /// If the default 'PA' sound should be played. - void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true); + /// Override the color of the message being sent. + void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true, Color? colorOverride = null); void DispatchServerMessage(IPlayerSession player, string message); diff --git a/Content.Server/Communications/CommunicationsConsoleComponent.cs b/Content.Server/Communications/CommunicationsConsoleComponent.cs index c445a3bd59..578da0dca4 100644 --- a/Content.Server/Communications/CommunicationsConsoleComponent.cs +++ b/Content.Server/Communications/CommunicationsConsoleComponent.cs @@ -109,7 +109,7 @@ namespace Content.Server.Communications } message += $"\nSent by {author}"; - _chatManager.DispatchStationAnnouncement(message, "Communications Console"); + _chatManager.DispatchStationAnnouncement(message, "Communications Console", colorOverride: Color.Gold); break; } } diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 73bb1be55f..aec9537853 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -335,7 +335,7 @@ namespace Content.Server.Nuke var announcement = Loc.GetString("nuke-component-announcement-armed", ("time", (int) component.RemainingTime)); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chat.DispatchStationAnnouncement(announcement, sender, false); + _chat.DispatchStationAnnouncement(announcement, sender, false, Color.Red); // todo: move it to announcements system SoundSystem.Play(Filter.Broadcast(), component.ArmSound.GetSound()); diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index a9d899b547..e66c1b793a 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -84,7 +84,7 @@ namespace Content.Server.RoundEnd _adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called"); } - _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"), false); + _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"), false, Color.Gold); SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg"); diff --git a/Content.Server/Salvage/SalvageSystem.cs b/Content.Server/Salvage/SalvageSystem.cs index 999752e731..f085c09f49 100644 --- a/Content.Server/Salvage/SalvageSystem.cs +++ b/Content.Server/Salvage/SalvageSystem.cs @@ -294,9 +294,9 @@ namespace Content.Server.Salvage return true; } private void Report(string messageKey) => - _chatManager.DispatchStationAnnouncement(Loc.GetString(messageKey), Loc.GetString("salvage-system-announcement-source")); + _chatManager.DispatchStationAnnouncement(Loc.GetString(messageKey), Loc.GetString("salvage-system-announcement-source"), colorOverride: Color.Orange); private void Report(string messageKey, params (string, object)[] args) => - _chatManager.DispatchStationAnnouncement(Loc.GetString(messageKey, args), Loc.GetString("salvage-system-announcement-source")); + _chatManager.DispatchStationAnnouncement(Loc.GetString(messageKey, args), Loc.GetString("salvage-system-announcement-source"), colorOverride: Color.Orange); private void Transition(SalvageMagnetComponent magnet, TimeSpan currentTime) { diff --git a/Content.Server/StationEvents/Events/StationEvent.cs b/Content.Server/StationEvents/Events/StationEvent.cs index 7732695e35..7c14e9c727 100644 --- a/Content.Server/StationEvents/Events/StationEvent.cs +++ b/Content.Server/StationEvents/Events/StationEvent.cs @@ -132,7 +132,7 @@ namespace Content.Server.StationEvents.Events if (StartAnnouncement != null) { var chatManager = IoCManager.Resolve(); - chatManager.DispatchStationAnnouncement(StartAnnouncement, playDefaultSound: false); + chatManager.DispatchStationAnnouncement(StartAnnouncement, playDefaultSound: false, colorOverride: Color.Gold); } if (StartAudio != null) @@ -155,7 +155,7 @@ namespace Content.Server.StationEvents.Events if (EndAnnouncement != null) { var chatManager = IoCManager.Resolve(); - chatManager.DispatchStationAnnouncement(EndAnnouncement, playDefaultSound: false); + chatManager.DispatchStationAnnouncement(EndAnnouncement, playDefaultSound: false, colorOverride: Color.Gold); } if (EndAudio != null)