From feebc5aa2270a889f2a314ec1b858fcfb7ded287 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Thu, 13 Jan 2022 03:35:15 +0700 Subject: [PATCH] Fix black text in chat --- sources/Chat/ChatAPI.uc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sources/Chat/ChatAPI.uc b/sources/Chat/ChatAPI.uc index ef56f0d..6910e26 100644 --- a/sources/Chat/ChatAPI.uc +++ b/sources/Chat/ChatAPI.uc @@ -117,6 +117,15 @@ private function bool HandleText( messageAsText = __().text.FromColoredStringM(message); result = onMessageSignal.Emit(senderPlayer, messageAsText, teamMessage); message = messageAsText.ToColoredString(); + // To correctly display chat messages we want to drop default color tag + // at the beginning (the one `ToColoredString()` adds if first character + // has no defined color). + // This is a compatibility consideration with vanilla UI that expects + // uncolored text. Not removing initial color tag will make chat text + // appear black. + if (!messageAsText.GetFormatting(0).isColored) { + message = Mid(message, 4); + } _.memory.Free(messageAsText); _.memory.Free(senderPlayer); return result;