Laserlicht 2 лет назад
Родитель
Сommit
d948cb72a0
2 измененных файлов с 12 добавлено и 1 удалено
  1. 2 1
      client/widgets/TextControls.cpp
  2. 10 0
      client/windows/CMessage.cpp

+ 2 - 1
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);

+ 10 - 0
client/windows/CMessage.cpp

@@ -147,7 +147,17 @@ std::vector<std::string> 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