From 247be5b5c770261544f4e468ea09422efb0f7028 Mon Sep 17 00:00:00 2001 From: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Date: Sun, 11 Feb 2024 07:38:55 +0100 Subject: [PATCH] Add option for character name colors in chat & move coloration to clientside (#24625) * Adds option to disable character names in chat/speechbubbles * Moved the coloring of names to clientside * Move string functions to SharedChatSystem to avoid duplicate code in SpeechBubble.cs * Changed to be put under Accessibility section * Cache CVar --- Content.Client/Chat/UI/SpeechBubble.cs | 13 +------ Content.Client/Options/UI/Tabs/MiscTab.xaml | 1 + .../Options/UI/Tabs/MiscTab.xaml.cs | 5 +++ .../Systems/Chat/ChatUIController.cs | 39 +++++++++++++++++++ Content.Server/Chat/Systems/ChatSystem.cs | 35 +---------------- Content.Shared/CCVar/CCVars.cs | 3 ++ Content.Shared/Chat/SharedChatSystem.cs | 27 +++++++++++++ .../en-US/chat/managers/chat-manager.ftl | 6 +-- .../en-US/escape-menu/ui/options-menu.ftl | 1 + 9 files changed, 81 insertions(+), 49 deletions(-) diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index 91e8e5a90f..82eccbcec8 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -182,20 +182,9 @@ namespace Content.Client.Chat.UI return msg; } - protected string ExtractSpeechSubstring(ChatMessage message, string tag) - { - var rawmsg = message.WrappedMessage; - var tagStart = rawmsg.IndexOf($"[{tag}]"); - var tagEnd = rawmsg.IndexOf($"[/{tag}]"); - if (tagStart < 0 || tagEnd < 0) //the above return -1 if the tag's not found, which in turn will cause the below to throw an exception. a blank speech bubble is far more noticeably broken than the bubble not appearing at all -bhijn - return ""; - tagStart += tag.Length + 2; - return rawmsg.Substring(tagStart, tagEnd - tagStart); - } - protected FormattedMessage ExtractAndFormatSpeechSubstring(ChatMessage message, string tag, Color? fontColor = null) { - return FormatSpeech(ExtractSpeechSubstring(message, tag), fontColor); + return FormatSpeech(SharedChatSystem.GetStringInsideTag(message, tag), fontColor); } } diff --git a/Content.Client/Options/UI/Tabs/MiscTab.xaml b/Content.Client/Options/UI/Tabs/MiscTab.xaml index db176db456..fc94ab7b0a 100644 --- a/Content.Client/Options/UI/Tabs/MiscTab.xaml +++ b/Content.Client/Options/UI/Tabs/MiscTab.xaml @@ -22,6 +22,7 @@ FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}" StyleClasses="LabelKeyText"/> +