From 9e1c8b7ab5db33f544305c3b160ca65b6972370f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 8 Jul 2013 13:46:07 +0300 Subject: add ability to show stats from items.xml like strings. --- src/resources/itemdb.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/resources') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 379b79e58..ff417d36e 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -59,15 +59,15 @@ static int parseDirectionName(const std::string &name); static const char *const fields[][2] = { // TRANSLATORS: item info label - { "attack", N_("Attack %+d") }, + { "attack", N_("Attack %s") }, // TRANSLATORS: item info label - { "defense", N_("Defense %+d") }, + { "defense", N_("Defense %s") }, // TRANSLATORS: item info label - { "hp", N_("HP %+d") }, + { "hp", N_("HP %s") }, // TRANSLATORS: item info label - { "mp", N_("MP %+d") }, + { "mp", N_("MP %s") }, // TRANSLATORS: item info label - { "level", N_("Level %+d") } + { "level", N_("Level %s") } }; static std::vector extraStats; @@ -344,21 +344,26 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) std::string effect; for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++ i) { - const int value = XML::getProperty(node, fields[i][0], 0); - if (!value) + std::string value = XML::getProperty(node, fields[i][0], ""); + if (value.empty()) continue; if (!effect.empty()) effect.append(" / "); - effect.append(strprintf(gettext(fields[i][1]), value)); + if (isDigit(value)) + value = "+" + value; + effect.append(strprintf(gettext(fields[i][1]), value.c_str())); } FOR_EACH (std::vector::const_iterator, it, extraStats) { - const int value = XML::getProperty(node, it->tag.c_str(), 0); - if (!value) + std::string value = XML::getProperty( + node, it->tag.c_str(), ""); + if (value.empty()) continue; if (!effect.empty()) effect.append(" / "); - effect.append(strprintf(it->format.c_str(), value)); + if (isDigit(value)) + value = "+" + value; + effect.append(strprintf(it->format.c_str(), value.c_str())); } std::string temp = XML::langProperty(node, "effect", ""); if (!effect.empty() && !temp.empty()) -- cgit v1.2.3-70-g09d2