diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-08 18:30:40 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-08 18:30:40 +0300 |
commit | 9a0da2510f9eed57e4bc974084bf54832ee4c33c (patch) | |
tree | 28dab1528da81c40a3ca648902b91d70f854a096 | |
parent | b930f7f858b0ad91206939ed1b6d5695bc10f9cc (diff) | |
download | manaplus-9a0da2510f9eed57e4bc974084bf54832ee4c33c.tar.gz manaplus-9a0da2510f9eed57e4bc974084bf54832ee4c33c.tar.bz2 manaplus-9a0da2510f9eed57e4bc974084bf54832ee4c33c.tar.xz manaplus-9a0da2510f9eed57e4bc974084bf54832ee4c33c.zip |
add support for sounds take and put.
"take" played if take item from container like inventory
"put" played if put item into container.
-rw-r--r-- | src/dragdrop.h | 4 | ||||
-rw-r--r-- | src/itemsoundmanager.cpp | 8 | ||||
-rw-r--r-- | src/itemsoundmanager.h | 3 | ||||
-rw-r--r-- | src/resources/db/itemdb.cpp | 2 |
4 files changed, 16 insertions, 1 deletions
diff --git a/src/dragdrop.h b/src/dragdrop.h index d282d82e3..72c39a766 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -22,6 +22,7 @@ #define DRAGDROP_H #include "item.h" +#include "itemsoundmanager.h" #include "textcommand.h" #include "gui/widgets/skilldata.h" @@ -103,6 +104,7 @@ class DragDrop final mItemImage->incRef(); mSource = source; mTag = tag; + ItemSoundManager::playSfx(item, SOUND_EVENT_TAKE); } else { @@ -180,6 +182,8 @@ class DragDrop final { if (mItemImage) mItemImage->decRef(); + if (mItem) + ItemSoundManager::playSfx(mItem, SOUND_EVENT_PUT); mItem = 0; mItemColor = 1; mItemImage = nullptr; diff --git a/src/itemsoundmanager.cpp b/src/itemsoundmanager.cpp index 9107a4048..5fdd09ccb 100644 --- a/src/itemsoundmanager.cpp +++ b/src/itemsoundmanager.cpp @@ -35,7 +35,13 @@ void ItemSoundManager::playSfx(const Item *const item, { if (!item) return; - const ItemInfo &info = ItemDB::get(item->getId()); + playSfx(item->getId(), sound); +} + +void ItemSoundManager::playSfx(const int itemId, + const ItemSoundEvent sound) +{ + const ItemInfo &info = ItemDB::get(itemId); std::string sfx = info.getSound(sound).sound; if (sfx.empty()) { diff --git a/src/itemsoundmanager.h b/src/itemsoundmanager.h index 77ef221c7..3341178ca 100644 --- a/src/itemsoundmanager.h +++ b/src/itemsoundmanager.h @@ -33,6 +33,9 @@ class ItemSoundManager final public: A_DELETE_COPY(ItemSoundManager) + static void playSfx(const int item, + const ItemSoundEvent sound); + static void playSfx(const Item *const item, const ItemSoundEvent sound); diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 8066eb40d..067ccc25c 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -172,6 +172,8 @@ static void initStatic() mSoundNames["unequip"] = SOUND_EVENT_UNEQUIP; mSoundNames["drop"] = SOUND_EVENT_DROP; mSoundNames["pickup"] = SOUND_EVENT_PICKUP; + mSoundNames["take"] = SOUND_EVENT_TAKE; + mSoundNames["put"] = SOUND_EVENT_PUT; } void ItemDB::load() |