summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-21 20:36:23 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-21 20:37:02 +0300
commite465ecdf0c7f867a62236a5a0945a85f35eee039 (patch)
tree7bc97c683d542f11a1f5b069e77cf70f552d14fe /src/resources
parent862e8f821789014b6167f37976b80694d6d310e3 (diff)
downloadplus-e465ecdf0c7f867a62236a5a0945a85f35eee039.tar.gz
plus-e465ecdf0c7f867a62236a5a0945a85f35eee039.tar.bz2
plus-e465ecdf0c7f867a62236a5a0945a85f35eee039.tar.xz
plus-e465ecdf0c7f867a62236a5a0945a85f35eee039.zip
Show item options in item popups.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/db/itemdb.cpp8
-rw-r--r--src/resources/db/itemoptiondb.cpp9
-rw-r--r--src/resources/db/itemoptiondb.h2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 77ff5b269..94c9b14b8 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -46,6 +46,8 @@
#include "utils/dtor.h"
#include "utils/stringmap.h"
+#include "utils/translation/podict.h"
+
#include "debug.h"
namespace
@@ -127,6 +129,9 @@ static void readFields(std::string &effect,
XmlNodeConstPtr node,
const ItemFieldDb::FieldInfos &fields)
{
+ if (!translator)
+ return;
+
FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
{
const std::string fieldName = (*it).first;
@@ -141,7 +146,8 @@ static void readFields(std::string &effect,
effect.append(" / ");
if (field->sign && isDigit(value))
value = "+" + value;
- effect.append(strprintf(gettext(field->description.c_str()),
+ const std::string format = translator->getStr(field->description);
+ effect.append(strprintf(format.c_str(),
value.c_str()));
}
}
diff --git a/src/resources/db/itemoptiondb.cpp b/src/resources/db/itemoptiondb.cpp
index becdf7406..504199bfc 100644
--- a/src/resources/db/itemoptiondb.cpp
+++ b/src/resources/db/itemoptiondb.cpp
@@ -36,6 +36,7 @@
namespace
{
ItemOptionDb::OptionInfos mOptions;
+ const std::vector<ItemFieldType*> mEmptyOption;
bool mLoaded = false;
} // namespace
@@ -141,3 +142,11 @@ void ItemOptionDb::unload()
mOptions.clear();
mLoaded = false;
}
+
+const std::vector<ItemFieldType*> &ItemOptionDb::getFields(const int id)
+{
+ OptionInfos::const_iterator it = mOptions.find(id);
+ if (it == mOptions.end())
+ return mEmptyOption;
+ return (*it).second;
+}
diff --git a/src/resources/db/itemoptiondb.h b/src/resources/db/itemoptiondb.h
index 6c7fb898f..9e088c76f 100644
--- a/src/resources/db/itemoptiondb.h
+++ b/src/resources/db/itemoptiondb.h
@@ -40,6 +40,8 @@ namespace ItemOptionDb
void loadXmlFile(const std::string &fileName,
const SkipError skipError);
+ const std::vector<ItemFieldType*> &getFields(const int id);
+
typedef std::map<int, std::vector<ItemFieldType*> > OptionInfos;
} // namespace ItemOptionDb