From 343809fe458a08bf96fe4f537db2d81d7523632e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 4 Oct 2013 02:03:12 +0300 Subject: Add new item sound events constants. --- src/resources/beinginfo.cpp | 7 ++++--- src/resources/beinginfo.h | 20 +++----------------- src/resources/db/itemdb.cpp | 4 ++-- src/resources/iteminfo.cpp | 6 +++--- src/resources/iteminfo.h | 6 +++--- src/resources/soundinfo.h | 21 +++++++++++++++++++++ 6 files changed, 36 insertions(+), 28 deletions(-) (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 84d32f623..92169314a 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -104,7 +104,8 @@ void BeingInfo::setTargetCursorSize(const std::string &size) } } -void BeingInfo::addSound(const SoundEvent event, const std::string &filename, +void BeingInfo::addSound(const ItemSoundEvent event, + const std::string &filename, const int delay) { if (mSounds.find(event) == mSounds.end()) @@ -114,11 +115,11 @@ void BeingInfo::addSound(const SoundEvent event, const std::string &filename, mSounds[event]->push_back(SoundInfo("sfx/" + filename, delay)); } -const SoundInfo &BeingInfo::getSound(const SoundEvent event) const +const SoundInfo &BeingInfo::getSound(const ItemSoundEvent event) const { static SoundInfo emptySound("", 0); - const SoundEvents::const_iterator i = mSounds.find(event); + const ItemSoundEvents::const_iterator i = mSounds.find(event); if (i == mSounds.end()) return emptySound; diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 3d00471da..008af8590 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -63,20 +63,6 @@ struct Attack final typedef std::map Attacks; -enum SoundEvent -{ - SOUND_EVENT_HIT = 0, - SOUND_EVENT_MISS, - SOUND_EVENT_HURT, - SOUND_EVENT_DIE, - SOUND_EVENT_MOVE, - SOUND_EVENT_SIT, - SOUND_EVENT_SITTOP, - SOUND_EVENT_SPAWN -}; - -typedef std::map SoundEvents; - /** * Holds information about a certain type of monster. This includes the name * of the monster, the sprite to display and the sounds the monster makes. @@ -125,10 +111,10 @@ class BeingInfo final ActorSprite::TargetCursorSize getTargetCursorSize() const A_WARN_UNUSED { return mTargetCursorSize; } - void addSound(const SoundEvent event, const std::string &filename, + void addSound(const ItemSoundEvent event, const std::string &filename, const int delay); - const SoundInfo &getSound(const SoundEvent event) + const SoundInfo &getSound(const ItemSoundEvent event) const A_WARN_UNUSED; void addAttack(const int id, std::string action, std::string skyAttack, @@ -251,7 +237,7 @@ class BeingInfo final std::string mName; ActorSprite::TargetCursorSize mTargetCursorSize; Cursor::Cursor mHoverCursor; - SoundEvents mSounds; + ItemSoundEvents mSounds; Attacks mAttacks; unsigned char mWalkMask; Map::BlockType mBlockType; diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 6f015b64e..867c01e2d 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -42,7 +42,7 @@ namespace bool mConstructed = false; StringVect mTagNames; std::map mTags; - std::map mSoundNames; + std::map mSoundNames; } // namespace // Forward declarations @@ -732,7 +732,7 @@ void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) node->xmlChildrenNode->content); const int delay = XML::getProperty(node, "delay", 0); - const std::map::const_iterator + const std::map::const_iterator it = mSoundNames.find(event); if (it != mSoundNames.end()) { diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index fa8ca2b61..cc7cc41c7 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -129,17 +129,17 @@ void ItemInfo::setWaterAttackAction(const std::string &attackAction) mWaterAttackAction = attackAction; } -void ItemInfo::addSound(const SoundEvent event, +void ItemInfo::addSound(const ItemSoundEvent event, const std::string &filename, const int delay) { mSounds[event].push_back(SoundInfo( paths.getStringValue("sfx").append(filename), delay)); } -const SoundInfo &ItemInfo::getSound(const SoundEvent event) const +const SoundInfo &ItemInfo::getSound(const ItemSoundEvent event) const { static const SoundInfo empty("", 0); - std::map::const_iterator i; + std::map::const_iterator i; i = mSounds.find(event); diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index b386e51f7..cf2c64e27 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -216,11 +216,11 @@ class ItemInfo final void setAttackRange(const int r) { mAttackRange = r; } - void addSound(const SoundEvent event, + void addSound(const ItemSoundEvent event, const std::string &filename, const int delay); - const SoundInfo &getSound(const SoundEvent event) + const SoundInfo &getSound(const ItemSoundEvent event) const A_WARN_UNUSED; int getDrawBefore(const int direction) const A_WARN_UNUSED; @@ -345,7 +345,7 @@ class ItemInfo final std::map mAnimationFiles; /** Stores the names of sounds to be played at certain event. */ - std::map mSounds; + std::map mSounds; std::map mTags; const std::map *mColors; std::string mColorList; diff --git a/src/resources/soundinfo.h b/src/resources/soundinfo.h index 30fe8675d..01671d43b 100644 --- a/src/resources/soundinfo.h +++ b/src/resources/soundinfo.h @@ -21,6 +21,7 @@ #ifndef RESOURCES_SOUNDINFO_H #define RESOURCES_SOUNDINFO_H +#include #include #include @@ -40,4 +41,24 @@ struct SoundInfo final typedef std::vector SoundInfoVect; +enum ItemSoundEvent +{ + SOUND_EVENT_HIT = 0, + SOUND_EVENT_MISS, + SOUND_EVENT_HURT, + SOUND_EVENT_DIE, + SOUND_EVENT_MOVE, + SOUND_EVENT_SIT, + SOUND_EVENT_SITTOP, + SOUND_EVENT_SPAWN, + SOUND_EVENT_DROP, + SOUND_EVENT_PICKUP, + SOUND_EVENT_TAKE, // take from container + SOUND_EVENT_PUT, // put into container + SOUND_EVENT_EQUIP, + SOUND_EVENT_UNEQUIP +}; + +typedef std::map ItemSoundEvents; + #endif // RESOURCES_SOUNDINFO_H -- cgit v1.2.3-60-g2f50