From 76bc1a5c994b46d8a4486a1226f681f7a4982f1c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 3 Jan 2011 19:48:48 +0200 Subject: Impliment base items tags. And show this tags in inventory. --- src/resources/itemdb.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/resources/itemdb.cpp') 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 mTagNames; + std::map 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 &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; } -- cgit v1.2.3-70-g09d2