From: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Date: Sun, 11 Feb 2024 06:38:55 +0000 (+0100) Subject: Add option for character name colors in chat & move coloration to clientside (#24625) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=247be5b5c770261544f4e468ea09422efb0f7028;p=space-station-14.git 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 --- 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"/> +