diff options
Diffstat (limited to 'src/resources/iteminfo.cpp')
-rw-r--r-- | src/resources/iteminfo.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 9e7fd6b7..b3208777 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -24,21 +24,22 @@ #include "resources/itemdb.h" #include "configuration.h" -const std::string &ItemInfo::getSprite(Gender gender) const +const std::string &ItemInfo::getSprite(Gender gender, int race) const { if (mView) { // Forward the request to the item defining how to view this item - return itemDb->get(mView).getSprite(gender); + return itemDb->get(mView).getSprite(gender, race); } - else - { - static const std::string empty; - auto i = - mAnimationFiles.find(gender); - return (i != mAnimationFiles.end()) ? i->second : empty; - } + auto i = mAnimationFiles.find(static_cast<int>(gender) + race * 4); + + // Fall back to ignoring race + if (race != 0 && i == mAnimationFiles.end()) + i = mAnimationFiles.find(static_cast<int>(gender)); + + static const std::string empty; + return i != mAnimationFiles.end() ? i->second : empty; } void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename) @@ -49,8 +50,11 @@ void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename) const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const { static const std::string empty; - std::map< EquipmentSoundEvent, std::vector<std::string> >::const_iterator i; - i = mSounds.find(event); - + auto i = mSounds.find(event); return i == mSounds.end() ? empty : i->second[rand() % i->second.size()]; } + +void ItemInfo::setSprite(const std::string &animationFile, Gender gender, int race) +{ + mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile; +} |