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
This commit is contained in:
SlamBamActionman
2024-02-11 07:38:55 +01:00
committed by GitHub
parent fabcc2b0d1
commit 247be5b5c7
9 changed files with 81 additions and 49 deletions

View File

@@ -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);
}
}