From d948cb72a0dbb5b4b148c18f2e898781d78377a9 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:13:35 +0200 Subject: [PATCH] Alignment --- client/widgets/TextControls.cpp | 3 ++- client/windows/CMessage.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index 24339b1b9..bfa75241d 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -208,7 +208,8 @@ void CTextContainer::blitLine(Canvas & to, Rect destRect, std::string what) std::string tmp = boost::algorithm::unhex(match[1].str()); std::copy(tmp.begin(), tmp.end(), rgb); - to.drawText(where, font, ColorRGBA(rgb[0], rgb[1], rgb[2]), ETextAlignment::TOPLEFT, toPrint.substr(7, toPrint.length() - 7)); + toPrint = toPrint.substr(7, toPrint.length() - 6); + to.drawText(where, font, ColorRGBA(rgb[0], rgb[1], rgb[2]), ETextAlignment::TOPLEFT, toPrint); } else to.drawText(where, font, Colors::YELLOW, ETextAlignment::TOPLEFT, toPrint); diff --git a/client/windows/CMessage.cpp b/client/windows/CMessage.cpp index d1c2bce2c..94917a8bc 100644 --- a/client/windows/CMessage.cpp +++ b/client/windows/CMessage.cpp @@ -147,7 +147,17 @@ std::vector CMessage::breakText( std::string text, size_t maxLineWi /* We don't count braces in string length. */ if (text[currPos] == '{') + { opened=true; + + std::smatch match; + std::regex expr("^\\{#([0-9a-fA-F]{6})$"); + std::string tmp = text.substr(currPos, 8); + if(std::regex_search(tmp, match, expr)) + { + currPos += 7; + } + } else if (text[currPos]=='}') opened=false; else