Skip to content

Commit c2458d3

Browse files
committedSep 29, 2019
label[]: Fix broken colors since 2c9edef
1 parent 3799ffd commit c2458d3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎src/gui/guiFormSpecMenu.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,10 @@ void GUIFormSpecMenu::parseLabel(parserData* data, const std::string &element)
14051405
std::vector<std::string> lines = split(text, '\n');
14061406

14071407
for (unsigned int i = 0; i != lines.size(); i++) {
1408-
std::wstring wlabel = unescape_translate(unescape_string(
1409-
utf8_to_wide(lines[i])));
1408+
std::wstring wlabel_colors = translate_string(
1409+
utf8_to_wide(unescape_string(lines[i])));
1410+
// Without color escapes to get the font dimensions
1411+
std::wstring wlabel_plain = unescape_enriched(wlabel_colors);
14101412

14111413
core::rect<s32> rect;
14121414

@@ -1423,7 +1425,7 @@ void GUIFormSpecMenu::parseLabel(parserData* data, const std::string &element)
14231425

14241426
rect = core::rect<s32>(
14251427
pos.X, pos.Y,
1426-
pos.X + m_font->getDimension(wlabel.c_str()).Width,
1428+
pos.X + m_font->getDimension(wlabel_plain.c_str()).Width,
14271429
pos.Y + imgsize.Y);
14281430

14291431
} else {
@@ -1445,13 +1447,13 @@ void GUIFormSpecMenu::parseLabel(parserData* data, const std::string &element)
14451447

14461448
rect = core::rect<s32>(
14471449
pos.X, pos.Y - m_btn_height,
1448-
pos.X + m_font->getDimension(wlabel.c_str()).Width,
1450+
pos.X + m_font->getDimension(wlabel_plain.c_str()).Width,
14491451
pos.Y + m_btn_height);
14501452
}
14511453

14521454
FieldSpec spec(
14531455
"",
1454-
wlabel,
1456+
wlabel_colors,
14551457
L"",
14561458
258+m_fields.size()
14571459
);

0 commit comments

Comments
 (0)
Please sign in to comment.