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

Changed configurable UI to match text refactoring:

- help.txt strings are now loaded as (hover, help) pairs
- renamed string pairs from translate.json to use (hover, help) form
- interface builder will always load label texts via unified ID
- interface builder way of loading buttons text has been changed:
- - field has been renamed "zelp" -> "help" for consistency
- - "help" field now only accepts string or object json type
This commit is contained in:
Ivan Savenko
2022-12-28 23:23:11 +02:00
parent 84493e1bff
commit 01d0cd4f7a
5 changed files with 75 additions and 89 deletions

View File

@@ -84,16 +84,7 @@ std::string InterfaceObjectConfigurable::readText(const JsonNode & config) const
if(config.isNull())
return "";
if(config.isNumber())
{
logGlobal->debug("Reading text from generaltext handler id:%d", config.Integer());
return CGI->generaltexth->allTexts[config.Integer()];
}
const std::string delimiter = "/";
std::string s = config.String();
boost::replace_all(s, "/", "." );
logGlobal->debug("Reading text from translations by key: %s", s);
return CGI->generaltexth->translate(s);
}
@@ -180,12 +171,6 @@ std::pair<std::string, std::string> InterfaceObjectConfigurable::readHintText(co
std::pair<std::string, std::string> result;
if(!config.isNull())
{
if(config.isNumber())
{
logGlobal->debug("Reading hint text (zelp) from generaltext handler id:%d", config.Integer());
return CGI->generaltexth->zelp[config.Integer()];
}
if(config.getType() == JsonNode::JsonType::DATA_STRUCT)
{
result.first = readText(config["hover"]);
@@ -194,8 +179,9 @@ std::pair<std::string, std::string> InterfaceObjectConfigurable::readHintText(co
}
if(config.getType() == JsonNode::JsonType::DATA_STRING)
{
logGlobal->debug("Reading non-translated hint: %s", config.String());
result.first = result.second = config.String();
logGlobal->debug("Reading hint text (help) from generaltext handler:%sd", config.String());
result.first = CGI->generaltexth->translate( config.String() + ".hover");
result.second = CGI->generaltexth->translate( config.String() + ".help");
}
}
return result;
@@ -251,8 +237,8 @@ std::shared_ptr<CToggleButton> InterfaceObjectConfigurable::buildToggleButton(co
logGlobal->debug("Building widget CToggleButton");
auto position = readPosition(config["position"]);
auto image = config["image"].String();
auto zelp = readHintText(config["zelp"]);
auto button = std::make_shared<CToggleButton>(position, image, zelp);
auto help = readHintText(config["help"]);
auto button = std::make_shared<CToggleButton>(position, image, help);
if(!config["selected"].isNull())
button->setSelected(config["selected"].Bool());
if(!config["imageOrder"].isNull())
@@ -271,8 +257,8 @@ std::shared_ptr<CButton> InterfaceObjectConfigurable::buildButton(const JsonNode
logGlobal->debug("Building widget CButton");
auto position = readPosition(config["position"]);
auto image = config["image"].String();
auto zelp = readHintText(config["zelp"]);
auto button = std::make_shared<CButton>(position, image, zelp);
auto help = readHintText(config["help"]);
auto button = std::make_shared<CButton>(position, image, help);
if(!config["items"].isNull())
{
for(const auto & item : config["items"].Vector())