summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-01-03 19:48:48 +0200
committerAndrei Karas <akaras@inbox.ru>2011-01-03 20:00:51 +0200
commit76bc1a5c994b46d8a4486a1226f681f7a4982f1c (patch)
treea2326dcfe0aa2208c03d7432168bca9ae35b5da4 /src/resources/itemdb.cpp
parent3436558bfd7bbbe0c63a0a89330b099b7c9da7ed (diff)
downloadplus-76bc1a5c994b46d8a4486a1226f681f7a4982f1c.tar.gz
plus-76bc1a5c994b46d8a4486a1226f681f7a4982f1c.tar.bz2
plus-76bc1a5c994b46d8a4486a1226f681f7a4982f1c.tar.xz
plus-76bc1a5c994b46d8a4486a1226f681f7a4982f1c.zip
Impliment base items tags. And show this tags in inventory.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index cc70e33b7..385f32ee6 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -42,6 +42,8 @@ namespace
ItemDB::NamedItemInfos mNamedItemInfos;
ItemInfo *mUnknown;
bool mLoaded = false;
+ std::vector<std::string> mTagNames;
+ std::map<std::string, int> mTags;
}
// Forward declarations
@@ -149,6 +151,7 @@ void ItemDB::load()
if (mLoaded)
unload();
+ int tagNum = 0;
logger->log1("Initializing item database...");
mUnknown = new ItemInfo;
@@ -168,6 +171,17 @@ void ItemDB::load()
return;
}
+ mTags.clear();
+ mTagNames.clear();
+ mTagNames.push_back("All");
+ mTagNames.push_back("Usable");
+ mTagNames.push_back("Unusable");
+ mTagNames.push_back("Equipment");
+ mTags["All"] = tagNum ++;
+ mTags["Usable"] = tagNum ++;
+ mTags["Unusable"] = tagNum ++;
+ mTags["Equipment"] = tagNum ++;
+
for_each_xml_child_node(node, rootNode)
{
if (!xmlStrEqual(node->name, BAD_CAST "item"))
@@ -210,6 +224,20 @@ void ItemDB::load()
itemInfo->setName(name.empty() ? _("unnamed") : name);
itemInfo->setDescription(description);
itemInfo->setType(itemTypeFromString(typeStr));
+ itemInfo->addTag(mTags["All"]);
+ switch (itemInfo->getType())
+ {
+ case ITEM_USABLE:
+ itemInfo->addTag(mTags["Usable"]);
+ break;
+ case ITEM_UNUSABLE:
+ itemInfo->addTag(mTags["Unusable"]);
+ break;
+ default:
+ itemInfo->addTag(mTags["Equipment"]);
+ break;
+ }
+
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setAttackAction(attackAction);
@@ -315,6 +343,11 @@ void ItemDB::load()
mLoaded = true;
}
+std::vector<std::string> &ItemDB::getTags()
+{
+ return mTagNames;
+}
+
void ItemDB::unload()
{
logger->log1("Unloading item database...");
@@ -325,6 +358,8 @@ void ItemDB::unload()
delete_all(mItemInfos);
mItemInfos.clear();
mNamedItemInfos.clear();
+ mTags.clear();
+ mTagNames.clear();
mLoaded = false;
}