diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/itemdb.cpp | 8 | ||||
-rw-r--r-- | src/resources/db/itemoptiondb.cpp | 9 | ||||
-rw-r--r-- | src/resources/db/itemoptiondb.h | 2 |
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 |