1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Refactoring of GeneralTextHandler to reduce boilerplate code in callers

This commit is contained in:
Ivan Savenko
2022-12-30 19:09:19 +02:00
parent 01d0cd4f7a
commit 9a620a9091
5 changed files with 73 additions and 59 deletions

View File

@@ -289,8 +289,8 @@ std::pair<std::string, std::string> CButton::tooltip()
std::pair<std::string, std::string> CButton::tooltipLocalized(const std::string & key)
{
return std::make_pair(
CGI->generaltexth->translate(key + ".hover"),
CGI->generaltexth->translate(key + ".help")
CGI->generaltexth->translate(key, "hover"),
CGI->generaltexth->translate(key, "help")
);
}
@@ -523,7 +523,7 @@ void CVolumeSlider::clickRight(tribool down, bool previousState)
int index = static_cast<int>(px / static_cast<double>(pos.w) * animImage->size());
size_t helpIndex = index + (mode == MUSIC ? 326 : 336);
std::string helpBox = CGI->generaltexth->translate("core.help." + std::to_string(helpIndex) + ".help" );
std::string helpBox = CGI->generaltexth->translate("core.help", helpIndex, "help" );
if(!helpBox.empty())
CRClickPopup::createAndPush(helpBox);