1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Alignment

This commit is contained in:
Laserlicht
2023-09-12 16:13:35 +02:00
parent dd4c95bd04
commit d948cb72a0
2 changed files with 12 additions and 1 deletions

View File

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

View File

@@ -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