mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Replace boost::format with MetaString
Looks like some of H3 localizations don't have string replacements for building / war machine name, resulting in exceptions on formatting attempt. MetaString handles this case silently.
This commit is contained in:
parent
9d7f46f985
commit
ad2bd897d0
@ -1451,7 +1451,11 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
auto statusbarBackground = std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26);
|
||||
statusbar = CGStatusBar::create(statusbarBackground);
|
||||
|
||||
name = std::make_shared<CLabel>(197, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->hcommands[7]) % building->getNameTranslated()));
|
||||
MetaString nameString;
|
||||
nameString.appendTextID("core.hallinfo.7");
|
||||
nameString.replaceTextID(building->getNameTextID());
|
||||
|
||||
name = std::make_shared<CLabel>(197, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, nameString.toString());
|
||||
description = std::make_shared<CTextBox>(building->getDescriptionTranslated(), Rect(33, 135, 329, 67), 0, FONT_MEDIUM, ETextAlignment::CENTER);
|
||||
stateText = std::make_shared<CTextBox>(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, ETextAlignment::CENTER);
|
||||
|
||||
@ -1468,14 +1472,20 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
|
||||
if(!rightClick)
|
||||
{ //normal window
|
||||
std::string tooltipYes = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->getNameTranslated());
|
||||
std::string tooltipNo = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->getNameTranslated());
|
||||
|
||||
buy = std::make_shared<CButton>(Point(45, 446), "IBUY30", CButton::tooltip(tooltipYes), [&](){ buyFunc(); }, EShortcut::GLOBAL_ACCEPT);
|
||||
MetaString tooltipYes;
|
||||
tooltipYes.appendTextID("core.genrltxt.595");
|
||||
tooltipYes.replaceTextID(building->getNameTextID());
|
||||
|
||||
MetaString tooltipNo;
|
||||
tooltipNo.appendTextID("core.genrltxt.596");
|
||||
tooltipNo.replaceTextID(building->getNameTextID());
|
||||
|
||||
buy = std::make_shared<CButton>(Point(45, 446), "IBUY30", CButton::tooltip(tooltipYes.toString()), [&](){ buyFunc(); }, EShortcut::GLOBAL_ACCEPT);
|
||||
buy->setBorderColor(Colors::METALLIC_GOLD);
|
||||
buy->block(state!=7 || LOCPLINT->playerID != town->tempOwner);
|
||||
|
||||
cancel = std::make_shared<CButton>(Point(290, 445), "ICANCEL", CButton::tooltip(tooltipNo), [&](){ close();}, EShortcut::GLOBAL_CANCEL);
|
||||
cancel = std::make_shared<CButton>(Point(290, 445), "ICANCEL", CButton::tooltip(tooltipNo.toString()), [&](){ close();}, EShortcut::GLOBAL_CANCEL);
|
||||
cancel->setBorderColor(Colors::METALLIC_GOLD);
|
||||
}
|
||||
}
|
||||
@ -1841,17 +1851,25 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, Art
|
||||
anim = std::make_shared<CCreatureAnim>(64, 50, creature->animDefName);
|
||||
anim->clipRect(113,125,200,150);
|
||||
|
||||
title = std::make_shared<CLabel>(165, 28, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW,
|
||||
boost::str(boost::format(CGI->generaltexth->allTexts[274]) % creature->getNameSingularTranslated()));
|
||||
MetaString titleString;
|
||||
titleString.appendTextID("core.genrltxt.274");
|
||||
titleString.replaceTextID(creature->getNameSingularTextID());
|
||||
|
||||
MetaString buyText;
|
||||
buyText.appendTextID("core.genrltxt.595");
|
||||
buyText.replaceTextID(creature->getNameSingularTextID());
|
||||
|
||||
MetaString cancelText;
|
||||
cancelText.appendTextID("core.genrltxt.596");
|
||||
cancelText.replaceTextID(creature->getNameSingularTextID());
|
||||
|
||||
std::string costString = std::to_string(aid.toArtifact(CGI->artifacts())->getPrice());
|
||||
|
||||
title = std::make_shared<CLabel>(165, 28, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, titleString.toString());
|
||||
costText = std::make_shared<CLabel>(165, 218, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->jktexts[43]);
|
||||
costValue = std::make_shared<CLabel>(165, 292, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE,
|
||||
std::to_string(aid.toArtifact(CGI->artifacts())->getPrice()));
|
||||
|
||||
std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->getNameSingularTranslated());
|
||||
buy = std::make_shared<CButton>(Point(42, 312), "IBUY30.DEF", CButton::tooltip(text), [&](){ close(); }, EShortcut::GLOBAL_ACCEPT);
|
||||
|
||||
text = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % creature->getNameSingularTranslated());
|
||||
cancel = std::make_shared<CButton>(Point(224, 312), "ICANCEL.DEF", CButton::tooltip(text), [&](){ close(); }, EShortcut::GLOBAL_CANCEL);
|
||||
costValue = std::make_shared<CLabel>(165, 292, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, costString);
|
||||
buy = std::make_shared<CButton>(Point(42, 312), "IBUY30.DEF", CButton::tooltip(buyText.toString()), [&](){ close(); }, EShortcut::GLOBAL_ACCEPT);
|
||||
cancel = std::make_shared<CButton>(Point(224, 312), "ICANCEL.DEF", CButton::tooltip(cancelText.toString()), [&](){ close(); }, EShortcut::GLOBAL_CANCEL);
|
||||
|
||||
if(possible)
|
||||
buy->addCallback([=](){ LOCPLINT->cb->buyArtifact(LOCPLINT->cb->getHero(hid),aid); });
|
||||
|
Loading…
Reference in New Issue
Block a user