summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-19 01:11:52 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-19 01:11:52 +0300
commit0d6ca48b79a596bec11fc7351fadbf3b1fc1f67b (patch)
tree4d03ab1e6b655bccafbad06e5cc3386a4f6480d7 /src/resources
parent29a93440367af32463f285ae5f0bd2aa23aadc92 (diff)
downloadManaVerse-0d6ca48b79a596bec11fc7351fadbf3b1fc1f67b.tar.gz
ManaVerse-0d6ca48b79a596bec11fc7351fadbf3b1fc1f67b.tar.bz2
ManaVerse-0d6ca48b79a596bec11fc7351fadbf3b1fc1f67b.tar.xz
ManaVerse-0d6ca48b79a596bec11fc7351fadbf3b1fc1f67b.zip
Move itemsoundevent into separate file.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h5
-rw-r--r--src/resources/db/itemdb.cpp24
-rw-r--r--src/resources/db/monsterdb.cpp24
-rw-r--r--src/resources/iteminfo.cpp6
-rw-r--r--src/resources/iteminfo.h6
-rw-r--r--src/resources/itemsoundevent.h46
-rw-r--r--src/resources/soundinfo.h24
8 files changed, 88 insertions, 51 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index a12961315..a20e55d86 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -126,7 +126,7 @@ void BeingInfo::setTargetCursorSize(const std::string &size)
}
}
-void BeingInfo::addSound(const ItemSoundEvent event,
+void BeingInfo::addSound(const ItemSoundEvent::Type event,
const std::string &filename,
const int delay)
{
@@ -137,7 +137,7 @@ void BeingInfo::addSound(const ItemSoundEvent event,
mSounds[event]->push_back(SoundInfo("sfx/" + filename, delay));
}
-const SoundInfo &BeingInfo::getSound(const ItemSoundEvent event) const
+const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
{
static SoundInfo emptySound("", 0);
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 27d36e2a3..851295e5a 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -88,10 +88,11 @@ class BeingInfo final
TargetCursorSize::Size getTargetCursorSize() const A_WARN_UNUSED
{ return mTargetCursorSize; }
- void addSound(const ItemSoundEvent event, const std::string &filename,
+ void addSound(const ItemSoundEvent::Type event,
+ const std::string &filename,
const int delay);
- const SoundInfo &getSound(const ItemSoundEvent event)
+ const SoundInfo &getSound(const ItemSoundEvent::Type event)
const A_WARN_UNUSED;
void addAttack(const int id,
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 234225fb0..c077f58fe 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -45,7 +45,7 @@ namespace
bool mConstructed = false;
StringVect mTagNames;
std::map<std::string, int> mTags;
- std::map<std::string, ItemSoundEvent> mSoundNames;
+ std::map<std::string, ItemSoundEvent::Type> mSoundNames;
} // namespace
extern int serverVersion;
@@ -184,16 +184,16 @@ static ItemType::Type itemTypeFromString(const std::string &name)
static void initStatic()
{
mConstructed = true;
- mSoundNames["hit"] = SOUND_EVENT_HIT;
- mSoundNames["strike"] = SOUND_EVENT_MISS;
- mSoundNames["miss"] = SOUND_EVENT_MISS;
- mSoundNames["use"] = SOUND_EVENT_USE;
- mSoundNames["equip"] = SOUND_EVENT_EQUIP;
- 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;
+ mSoundNames["hit"] = ItemSoundEvent::HIT;
+ mSoundNames["strike"] = ItemSoundEvent::MISS;
+ mSoundNames["miss"] = ItemSoundEvent::MISS;
+ mSoundNames["use"] = ItemSoundEvent::USE;
+ mSoundNames["equip"] = ItemSoundEvent::EQUIP;
+ mSoundNames["unequip"] = ItemSoundEvent::UNEQUIP;
+ mSoundNames["drop"] = ItemSoundEvent::DROP;
+ mSoundNames["pickup"] = ItemSoundEvent::PICKUP;
+ mSoundNames["take"] = ItemSoundEvent::TAKE;
+ mSoundNames["put"] = ItemSoundEvent::PUT;
}
void ItemDB::load()
@@ -763,7 +763,7 @@ void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node)
node->xmlChildrenNode->content);
const int delay = XML::getProperty(node, "delay", 0);
- const std::map<std::string, ItemSoundEvent>::const_iterator
+ const std::map<std::string, ItemSoundEvent::Type>::const_iterator
it = mSoundNames.find(event);
if (it != mSoundNames.end())
{
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index ec68e5731..d29cac7e9 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -164,35 +164,43 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
if (event == "hit")
{
- currentInfo->addSound(SOUND_EVENT_HIT, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::HIT,
+ filename, delay);
}
else if (event == "miss")
{
- currentInfo->addSound(SOUND_EVENT_MISS, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::MISS,
+ filename, delay);
}
else if (event == "hurt")
{
- currentInfo->addSound(SOUND_EVENT_HURT, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::HURT,
+ filename, delay);
}
else if (event == "die")
{
- currentInfo->addSound(SOUND_EVENT_DIE, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::DIE,
+ filename, delay);
}
else if (event == "move")
{
- currentInfo->addSound(SOUND_EVENT_MOVE, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::MOVE,
+ filename, delay);
}
else if (event == "sit")
{
- currentInfo->addSound(SOUND_EVENT_SIT, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::SIT,
+ filename, delay);
}
else if (event == "sittop")
{
- currentInfo->addSound(SOUND_EVENT_SITTOP, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::SITTOP,
+ filename, delay);
}
else if (event == "spawn")
{
- currentInfo->addSound(SOUND_EVENT_SPAWN, filename, delay);
+ currentInfo->addSound(ItemSoundEvent::SPAWN,
+ filename, delay);
}
else
{
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index c4af7d30a..acf355b87 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -131,17 +131,17 @@ void ItemInfo::setWaterAttackAction(const std::string &attackAction)
mWaterAttackAction = attackAction;
}
-void ItemInfo::addSound(const ItemSoundEvent event,
+void ItemInfo::addSound(const ItemSoundEvent::Type event,
const std::string &filename, const int delay)
{
mSounds[event].push_back(SoundInfo(
paths.getStringValue("sfx").append(filename), delay));
}
-const SoundInfo &ItemInfo::getSound(const ItemSoundEvent event) const
+const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const
{
static const SoundInfo empty("", 0);
- std::map<ItemSoundEvent, SoundInfoVect>::const_iterator i;
+ std::map<ItemSoundEvent::Type, SoundInfoVect>::const_iterator i;
i = mSounds.find(event);
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 8d25ff8f2..ce318ca61 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -164,11 +164,11 @@ class ItemInfo final
void setAttackRange(const int r)
{ mAttackRange = r; }
- void addSound(const ItemSoundEvent event,
+ void addSound(const ItemSoundEvent::Type event,
const std::string &filename,
const int delay);
- const SoundInfo &getSound(const ItemSoundEvent event)
+ const SoundInfo &getSound(const ItemSoundEvent::Type event)
const A_WARN_UNUSED;
int getDrawBefore(const int direction) const A_WARN_UNUSED;
@@ -294,7 +294,7 @@ class ItemInfo final
std::map <int, std::string> mAnimationFiles;
/** Stores the names of sounds to be played at certain event. */
- std::map <ItemSoundEvent, SoundInfoVect> mSounds;
+ std::map <ItemSoundEvent::Type, SoundInfoVect> mSounds;
std::map <int, int> mTags;
const std::map <int, ColorDB::ItemColor> *mColors;
std::string mColorList;
diff --git a/src/resources/itemsoundevent.h b/src/resources/itemsoundevent.h
new file mode 100644
index 000000000..a33caa076
--- /dev/null
+++ b/src/resources/itemsoundevent.h
@@ -0,0 +1,46 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2013-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_ITEMSOUNDEVENT_H
+#define RESOURCES_ITEMSOUNDEVENT_H
+
+namespace ItemSoundEvent
+{
+ enum Type
+ {
+ HIT = 0,
+ MISS,
+ HURT,
+ DIE,
+ MOVE,
+ SIT,
+ SITTOP,
+ SPAWN,
+ DROP,
+ PICKUP,
+ TAKE, // take from container
+ PUT, // put into container
+ EQUIP,
+ UNEQUIP,
+ USE
+ };
+}
+
+#endif // RESOURCES_ITEMSOUNDEVENT_H
diff --git a/src/resources/soundinfo.h b/src/resources/soundinfo.h
index bae53ae35..2e0bf46cc 100644
--- a/src/resources/soundinfo.h
+++ b/src/resources/soundinfo.h
@@ -21,6 +21,8 @@
#ifndef RESOURCES_SOUNDINFO_H
#define RESOURCES_SOUNDINFO_H
+#include "resources/itemsoundevent.h"
+
#include <map>
#include <string>
#include <vector>
@@ -40,26 +42,6 @@ struct SoundInfo final
};
typedef std::vector<SoundInfo> 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,
- SOUND_EVENT_USE
-};
-
-typedef std::map<ItemSoundEvent, SoundInfoVect*> ItemSoundEvents;
+typedef std::map<ItemSoundEvent::Type, SoundInfoVect*> ItemSoundEvents;
#endif // RESOURCES_SOUNDINFO_H