From 992c2920f7e1940aa293e27cf4ea7ec23668a673 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 12 Feb 2011 17:02:17 +0200 Subject: Add items attribute what allow hide other sprites only by id. --- src/resources/itemdb.cpp | 3 +++ src/resources/iteminfo.cpp | 13 +++++++++++++ src/resources/iteminfo.h | 7 +++++++ 3 files changed, 23 insertions(+) (limited to 'src/resources') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 075104516..97a6ba1f4 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -205,6 +205,8 @@ void ItemDB::load() std::string drawBefore = XML::getProperty(node, "drawBefore", ""); std::string drawAfter = XML::getProperty(node, "drawAfter", ""); std::string removeSprite = XML::getProperty(node, "removeSprite", ""); + std::string removeSpriteIds = XML::getProperty(node, "removeSpriteIds", ""); + std::set rSprites = splitToIntSet(removeSpriteIds, ','); std::string tags[3]; tags[0] = XML::getProperty(node, "tag", @@ -265,6 +267,7 @@ void ItemDB::load() itemInfo->setDrawAfter(parseSpriteName(drawAfter)); itemInfo->setDrawPriority(drawPriority); itemInfo->setRemoveSprite(parseSpriteName(removeSprite)); + itemInfo->setRemoveSpriteIds(rSprites); std::string effect; for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i) diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 300c6bd26..f65e0396a 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -24,6 +24,8 @@ #include "resources/itemdb.h" #include "configuration.h" +#include + const std::string &ItemInfo::getSprite(Gender gender) const { if (mView) @@ -64,3 +66,14 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const return i == mSounds.end() ? empty : i->second[rand() % i->second.size()]; } + +bool ItemInfo::isRemoveSpriteId(int id) const +{ + if (!mRemoveSpriteIds.size() + || mRemoveSpriteIds.find(id) != mRemoveSpriteIds.end()) + { + return true; + } + + return false; +} \ No newline at end of file diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 8dbef87b7..ba7866518 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -29,6 +29,7 @@ #include #include #include +#include enum EquipmentSoundEvent { @@ -220,6 +221,11 @@ class ItemInfo void addTag(int tag) { mTags[tag] = 1; } + void setRemoveSpriteIds(std::set ids) + { mRemoveSpriteIds = ids; } + + bool isRemoveSpriteId(int id) const; + protected: SpriteDisplay mDisplay; /**< Display info (like icon) */ std::string mName; @@ -234,6 +240,7 @@ class ItemInfo int mDrawAfter; int mDrawPriority; int mRemoveSprite; + std::set mRemoveSpriteIds; // Equipment related members. /** Attack type, in case of weapon. -- cgit v1.2.3-70-g09d2