From bc94e3dbe141ca257363850077d3faf48338fb87 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 Jun 2016 22:03:20 +0300 Subject: Fix asserts about not found translated item names. --- src/resources/db/itemdb.cpp | 11 +++++++++++ src/resources/iteminfo.cpp | 6 ++++++ src/resources/iteminfo.h | 10 ++++++++++ 3 files changed, 27 insertions(+) (limited to 'src/resources') diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index d79f75933..be196f615 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -301,6 +301,7 @@ void ItemDB::loadXmlFile(const std::string &fileName, const int inherit = XML::getProperty(node, "inherit", -1); std::string name = XML::langProperty(node, "name", ""); + std::string nameEn = XML::getProperty(node, "name", ""); std::string image = XML::getProperty(node, "image", ""); std::string floor = XML::getProperty(node, "floor", ""); std::string description = XML::langProperty(node, "description", ""); @@ -383,6 +384,11 @@ void ItemDB::loadXmlFile(const std::string &fileName, name = inheritItemInfo->getName(); // TRANSLATORS: item info name itemInfo->setName(name.empty() ? _("unnamed") : name); + if (nameEn.empty()) + itemInfo->setNameEn(name.empty() ? _("unnamed") : name); + else + itemInfo->setNameEn(nameEn); + if (description.empty() && inheritItemInfo) description = inheritItemInfo->getDescription(); itemInfo->setDescription(description); @@ -606,6 +612,11 @@ void ItemDB::loadXmlFile(const std::string &fileName, temp = normalize(name); mNamedItemInfos[temp] = itemInfo; } + if (!nameEn.empty()) + { + temp = normalize(nameEn); + mNamedItemInfos[temp] = itemInfo; + } if (!attackAction.empty()) { diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 1de4d9579..b23065f60 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -41,6 +41,7 @@ ItemInfo::ItemInfo() : mMissileParticleFile(), mDisplay(), mName(), + mNameEn(), mDescription(), mEffect(), mUseButton(), @@ -256,6 +257,11 @@ const std::string ItemInfo::getName(const ItemColor color) const return replaceColors(mName, color); } +const std::string ItemInfo::getNameEn(const ItemColor color) const +{ + return replaceColors(mNameEn, color); +} + const std::string ItemInfo::replaceColors(std::string str, const ItemColor color) const { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index ad9a2d6ab..3eb19dc80 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -77,6 +77,15 @@ class ItemInfo final const std::string getName(const ItemColor color) const A_WARN_UNUSED; + void setNameEn(const std::string &name) + { mNameEn = name; } + + const std::string &getNameEn() const A_WARN_UNUSED + { return mNameEn; } + + const std::string getNameEn(const ItemColor color) + const A_WARN_UNUSED; + const std::string getLink() const A_WARN_UNUSED; void setDisplay(const SpriteDisplay &display) @@ -325,6 +334,7 @@ class ItemInfo final SpriteDisplay mDisplay; /**< Display info (like icon) */ std::string mName; + std::string mNameEn; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ std::string mUseButton; -- cgit v1.2.3-70-g09d2