1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

move function; optional; json static

This commit is contained in:
Laserlicht
2023-09-13 16:02:54 +02:00
parent 922a775108
commit 063c7f3ca0
5 changed files with 34 additions and 35 deletions

View File

@@ -159,7 +159,7 @@ void CTextContainer::blitLine(Canvas & to, Rect destRect, std::string what)
while(std::regex_search(searchStart, what.cend(), match, expr))
{
std::string colorText = match[1].str();
if(CMessage::parseColor(colorText).a != Colors::TRANSPARENCY.ALPHA_TRANSPARENT)
if(auto c = Colors::parseColor(colorText))
delimitersCount += f->getStringWidth(colorText + "|");
searchStart = match.suffix().first;
}
@@ -207,12 +207,11 @@ void CTextContainer::blitLine(Canvas & to, Rect destRect, std::string what)
if(std::regex_search(toPrint, match, expr))
{
std::string colorText = match[1].str();
ColorRGBA color = CMessage::parseColor(colorText);
if(color.a != Colors::TRANSPARENCY.ALPHA_TRANSPARENT)
if(auto color = Colors::parseColor(colorText))
{
toPrint = toPrint.substr(colorText.length() + 1, toPrint.length() - colorText.length());
to.drawText(where, font, color, ETextAlignment::TOPLEFT, toPrint);
to.drawText(where, font, *color, ETextAlignment::TOPLEFT, toPrint);
}
else
to.drawText(where, font, Colors::YELLOW, ETextAlignment::TOPLEFT, toPrint);