summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-08 13:46:07 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-08 13:46:07 +0300
commit9e1c8b7ab5db33f544305c3b160ca65b6972370f (patch)
tree1bd1f627d3d58a874953149de001a770f7d9ea9e /src/resources/itemdb.cpp
parent857da1b7b4e0a2523947b6ec82746a559543f329 (diff)
downloadmanaverse-9e1c8b7ab5db33f544305c3b160ca65b6972370f.tar.gz
manaverse-9e1c8b7ab5db33f544305c3b160ca65b6972370f.tar.bz2
manaverse-9e1c8b7ab5db33f544305c3b160ca65b6972370f.tar.xz
manaverse-9e1c8b7ab5db33f544305c3b160ca65b6972370f.zip
add ability to show stats from items.xml like strings.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp27
1 files changed, 16 insertions, 11 deletions
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<ItemDB::Stat> 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<Stat>::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())