summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-31 23:06:04 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-31 23:06:04 +0300
commit28165cbeca05b74cf66f121757f21f4cb7cd381e (patch)
treec1c32225b4d94f75df8a20a5baacf009be88b0b0
parent35d4ce0ed75b2575067007a85d5c211d292ebada (diff)
downloadmanaverse-28165cbeca05b74cf66f121757f21f4cb7cd381e.tar.gz
manaverse-28165cbeca05b74cf66f121757f21f4cb7cd381e.tar.bz2
manaverse-28165cbeca05b74cf66f121757f21f4cb7cd381e.tar.xz
manaverse-28165cbeca05b74cf66f121757f21f4cb7cd381e.zip
Add support for sound effects in any notification messages.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client.cpp3
-rw-r--r--src/notifications.h213
-rw-r--r--src/notifymanager.cpp16
-rw-r--r--src/notifymanager.h1
-rw-r--r--src/resources/sounddb.cpp79
-rw-r--r--src/resources/sounddb.h38
8 files changed, 283 insertions, 71 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8c99c7b94..5367c8720 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -458,6 +458,8 @@ SET(SRCS
resources/sdlimagehelper.h
resources/sdlmusic.cpp
resources/sdlmusic.h
+ resources/sounddb.cpp
+ resources/sounddb.h
resources/soundeffect.h
resources/soundeffect.cpp
resources/spritedef.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 1ba390bb1..f0c95af86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -459,6 +459,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/sdlimagehelper.h \
resources/sdlmusic.cpp \
resources/sdlmusic.h \
+ resources/sounddb.cpp \
+ resources/sounddb.h \
resources/soundeffect.cpp \
resources/soundeffect.h \
resources/spritedef.cpp \
diff --git a/src/client.cpp b/src/client.cpp
index f79baf7df..10a6c6f96 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -83,6 +83,7 @@
#include "resources/imagehelper.h"
#include "resources/openglimagehelper.h"
#include "resources/sdlimagehelper.h"
+#include "resources/sounddb.h"
#include "resources/itemdb.h"
#include "resources/mapdb.h"
#include "resources/monsterdb.h"
@@ -734,6 +735,7 @@ void Client::gameClear()
// Unload XML databases
CharDB::unload();
ColorDB::unload();
+ SoundDB::unload();
EmoteDB::unload();
ItemDB::unload();
MonsterDB::unload();
@@ -1369,6 +1371,7 @@ int Client::gameExec()
// Load XML databases
CharDB::load();
ColorDB::load();
+ SoundDB::load();
MapDB::load();
ItemDB::load();
Being::load();
diff --git a/src/notifications.h b/src/notifications.h
index 5906eea74..981b6ecc6 100644
--- a/src/notifications.h
+++ b/src/notifications.h
@@ -41,6 +41,7 @@ namespace NotifyManager
struct NotificationInfo final
{
+ const char *sound;
const char *text;
const NotifyFlags flags;
};
@@ -123,78 +124,148 @@ namespace NotifyManager
static const NotificationInfo notifications[] =
{
- {"", EMPTY},
- {N_("Thanks for buying."), EMPTY},
- {N_("Unable to buy."), EMPTY},
- {N_("Nothing to sell."), EMPTY},
- {N_("Thanks for selling."), EMPTY},
- {N_("Unable to sell."), EMPTY},
- {N_("Unable to sell while trading."), EMPTY},
- {N_("Unable to sell unsellable item."), EMPTY},
- {N_("Online users: %d"), INT},
- {N_("Guild created."), EMPTY},
- {N_("You are already in guild."), EMPTY},
- {N_("Emperium check failed."), EMPTY},
- {N_("Unknown server response."), EMPTY},
- {N_("You have left the guild."), EMPTY},
- {N_("Could not invite user to guild."), GUILD},
- {N_("User rejected guild invite."), GUILD},
- {N_("User is now part of your guild."), GUILD},
- {N_("Your guild is full."), GUILD},
- {N_("Unknown guild invite response."), GUILD},
- {N_("%s has left your guild."), GUILD_STRING},
- {N_("You were kicked from guild."), EMPTY},
- {N_("%s has kicked from your guild."), GUILD_STRING},
- {N_("Failed to use item."), EMPTY},
- {N_("Unable to equip."), EMPTY},
- {N_("Could not create party."), EMPTY},
- {N_("Party successfully created."), EMPTY},
- {N_("You have left the party."), EMPTY},
- {N_("%s has joined your party."), PARTY_STRING},
- {N_("%s is already a member of a party."), PARTY_STRING},
- {N_("%s refused your invitation."), PARTY_STRING},
- {N_("%s is now a member of your party."), PARTY_STRING},
- {N_("%s can't join your party because party is full."), PARTY_STRING},
- {N_("QQQ Unknown invite response for %s."), PARTY_STRING},
- {N_("Experience sharing enabled."), PARTY},
- {N_("Experience sharing disabled."), PARTY},
- {N_("Experience sharing not possible."), PARTY},
- {N_("Item sharing enabled."), PARTY},
- {N_("Item sharing disabled."), PARTY},
- {N_("Item sharing not possible."), PARTY},
- {N_("%s has left your party."), PARTY_STRING},
- {N_("An unknown member tried to say: %s"), PARTY_STRING},
- {N_("%s is not in your party!"), PARTY_STRING},
- {N_("You picked up %s."), STRING},
- {N_("You spent %s."), STRING},
- {N_("Cannot raise skill!"), EMPTY},
- {N_("Equip arrows first."), EMPTY},
- {N_("Trading with %s isn't possible. Trade partner is too far away."),
+ {"",
+ "", EMPTY},
+ {"buy done",
+ N_("Thanks for buying."), EMPTY},
+ {"buy fail",
+ N_("Unable to buy."), EMPTY},
+ {"sell empty",
+ N_("Nothing to sell."), EMPTY},
+ {"sell done",
+ N_("Thanks for selling."), EMPTY},
+ {"sell fail",
+ N_("Unable to sell."), EMPTY},
+ {"sell trade fail",
+ N_("Unable to sell while trading."), EMPTY},
+ {"sell unsellable fail",
+ N_("Unable to sell unsellable item."), EMPTY},
+ {"online users",
+ N_("Online users: %d"), INT},
+ {"guild created",
+ N_("Guild created."), EMPTY},
+ {"guild already",
+ N_("You are already in guild."), EMPTY},
+ {"guild create fail",
+ N_("Emperium check failed."), EMPTY},
+ {"guild error",
+ N_("Unknown server response."), EMPTY},
+ {"guild left",
+ N_("You have left the guild."), EMPTY},
+ {"guild invite fail",
+ N_("Could not invite user to guild."), GUILD},
+ {"guild invite rejected",
+ N_("User rejected guild invite."), GUILD},
+ {"guild invite joined",
+ N_("User is now part of your guild."), GUILD},
+ {"guild invite full",
+ N_("Your guild is full."), GUILD},
+ {"guild invite error",
+ N_("Unknown guild invite response."), GUILD},
+ {"guild user left",
+ N_("%s has left your guild."), GUILD_STRING},
+ {"guild kicked",
+ N_("You were kicked from guild."), EMPTY},
+ {"guild user kicked",
+ N_("%s has kicked from your guild."), GUILD_STRING},
+ {"use failed",
+ N_("Failed to use item."), EMPTY},
+ {"equip failed",
+ N_("Unable to equip."), EMPTY},
+ {"party create failed",
+ N_("Could not create party."), EMPTY},
+ {"party created",
+ N_("Party successfully created."), EMPTY},
+ {"party left",
+ N_("You have left the party."), EMPTY},
+ {"party user joined",
+ N_("%s has joined your party."), PARTY_STRING},
+ {"party invite already member",
+ N_("%s is already a member of a party."), PARTY_STRING},
+ {"party invite refused",
+ N_("%s refused your invitation."), PARTY_STRING},
+ {"party invite done",
+ N_("%s is now a member of your party."), PARTY_STRING},
+ {"party invite full",
+ N_("%s can't join your party because party is full."), PARTY_STRING},
+ {"party invite error",
+ N_("QQQ Unknown invite response for %s."), PARTY_STRING},
+ {"party exp sharing on",
+ N_("Experience sharing enabled."), PARTY},
+ {"party exp sharing off",
+ N_("Experience sharing disabled."), PARTY},
+ {"party exp sharing error",
+ N_("Experience sharing not possible."), PARTY},
+ {"party item sharing on",
+ N_("Item sharing enabled."), PARTY},
+ {"party item sharing off",
+ N_("Item sharing disabled."), PARTY},
+ {"party item sharing error",
+ N_("Item sharing not possible."), PARTY},
+ {"party user left",
+ N_("%s has left your party."), PARTY_STRING},
+ {"party unknown user msg",
+ N_("An unknown member tried to say: %s"), PARTY_STRING},
+ {"party user not in party",
+ N_("%s is not in your party!"), PARTY_STRING},
+ {"money get",
+ N_("You picked up %s."), STRING},
+ {"money spend",
+ N_("You spent %s."), STRING},
+ {"skill raise error",
+ N_("Cannot raise skill!"), EMPTY},
+ {"arrow equip needed",
+ N_("Equip arrows first."), EMPTY},
+ {"trade fail far away",
+ N_("Trading with %s isn't possible. Trade partner is "
+ "too far away."), STRING},
+ {"trade fail chat not exists",
+ N_("Trading with %s isn't possible. Character doesn't exist."),
STRING},
- {N_("Trading with %s isn't possible. Character doesn't exist."),
- STRING},
- {N_("Trade cancelled due to an unknown reason."), EMPTY},
- {N_("Trade with %s cancelled."), STRING},
- {N_("Unhandled trade cancel packet with %s"), STRING},
- {N_("Failed adding item. Trade partner is over weighted."), EMPTY},
- {N_("Failed adding item. Trade partner has no free slot."), EMPTY},
- {N_("Failed adding item. You can't trade this item."), EMPTY},
- {N_("Failed adding item for unknown reason."), EMPTY},
- {N_("Trade canceled."), EMPTY},
- {N_("Trade completed."), EMPTY},
- {N_("Kick failed!"), EMPTY},
- {N_("Kick succeeded!"), EMPTY},
- {N_("MVP player: %s"), STRING},
- {N_("All whispers ignored."), EMPTY},
- {N_("All whispers ignore failed."), EMPTY},
- {N_("All whispers unignored."), EMPTY},
- {N_("All whispers unignore failed."), EMPTY},
- {"%s", STRING},
- {N_("pvp off, gvg off"), SPEECH},
- {N_("pvp on"), SPEECH},
- {N_("gvg on"), SPEECH},
- {N_("pvp on, gvg on"), SPEECH},
- {N_("unknown pvp"), SPEECH},
+ {"trade cancelled error",
+ N_("Trade cancelled due to an unknown reason."), EMPTY},
+ {"trade cancelled user",
+ N_("Trade with %s cancelled."), STRING},
+ {"trade error unknown",
+ N_("Unhandled trade cancel packet with %s"), STRING},
+ {"trade add partner over weighted",
+ N_("Failed adding item. Trade partner is over weighted."), EMPTY},
+ {"trade add partned has no free slots",
+ N_("Failed adding item. Trade partner has no free slot."), EMPTY},
+ {"trade add untradable item",
+ N_("Failed adding item. You can't trade this item."), EMPTY},
+ {"trade add error",
+ N_("Failed adding item for unknown reason."), EMPTY},
+ {"trade cancelled",
+ N_("Trade canceled."), EMPTY},
+ {"trade complete",
+ N_("Trade completed."), EMPTY},
+ {"kick fail",
+ N_("Kick failed!"), EMPTY},
+ {"kick succeed",
+ N_("Kick succeeded!"), EMPTY},
+ {"mvp player",
+ N_("MVP player: %s"), STRING},
+ {"whispers ignored",
+ N_("All whispers ignored."), EMPTY},
+ {"whispers ignore failed",
+ N_("All whispers ignore failed."), EMPTY},
+ {"whispers unignored",
+ N_("All whispers unignored."), EMPTY},
+ {"whispers unignore failed",
+ N_("All whispers unignore failed."), EMPTY},
+ {"skill fail message",
+ "%s", STRING},
+ {"pvp off gvg off",
+ N_("pvp off, gvg off"), SPEECH},
+ {"pvp on",
+ N_("pvp on"), SPEECH},
+ {"gvg on",
+ N_("gvg on"), SPEECH},
+ {"pvp on gvg on",
+ N_("pvp on, gvg on"), SPEECH},
+ {"unknown pvp",
+ N_("unknown pvp"), SPEECH},
};
}
#endif
diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp
index 8f702c286..b889c66f3 100644
--- a/src/notifymanager.cpp
+++ b/src/notifymanager.cpp
@@ -22,6 +22,7 @@
#include "guildmanager.h"
#include "localplayer.h"
+#include "soundmanager.h"
#include "gui/widgets/chattab.h"
@@ -29,6 +30,8 @@
#include "net/net.h"
#include "net/partyhandler.h"
+#include "resources/sounddb.h"
+
namespace NotifyManager
{
static ChatTab *getGuildTab()
@@ -93,6 +96,7 @@ namespace NotifyManager
default:
break;
}
+ soundManager.playSfx(SoundDB::getSound(message));
}
void notify(const unsigned int message, const int num)
@@ -105,6 +109,7 @@ namespace NotifyManager
localChatTab->chatLog(strprintf(gettext(info.text),
num), BY_SERVER);
}
+ soundManager.playSfx(SoundDB::getSound(message));
}
void notify(const unsigned int message, const std::string &str)
@@ -140,5 +145,16 @@ namespace NotifyManager
default:
break;
}
+ soundManager.playSfx(SoundDB::getSound(message));
+ }
+
+ int getIndexBySound(const std::string &sound)
+ {
+ for (int f = 0; f < TYPE_END; f ++)
+ {
+ if (notifications[f].sound == sound)
+ return f;
+ }
+ return 0;
}
}
diff --git a/src/notifymanager.h b/src/notifymanager.h
index 59f3251c7..d7c5607e6 100644
--- a/src/notifymanager.h
+++ b/src/notifymanager.h
@@ -30,5 +30,6 @@ namespace NotifyManager
void notify(const unsigned int message);
void notify(const unsigned int message, const int num);
void notify(const unsigned int message, const std::string &str);
+ int getIndexBySound(const std::string &sound);
}
#endif
diff --git a/src/resources/sounddb.cpp b/src/resources/sounddb.cpp
new file mode 100644
index 000000000..28ab3509c
--- /dev/null
+++ b/src/resources/sounddb.cpp
@@ -0,0 +1,79 @@
+/*
+ * Color database
+ * Copyright (C) 2013 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/>.
+ */
+
+#include "resources/sounddb.h"
+
+#include "client.h"
+#include "logger.h"
+#include "notifymanager.h"
+
+#include "utils/xml.h"
+
+#include "debug.h"
+
+namespace
+{
+ std::string mDefault;
+ std::vector<std::string> mSounds;
+}
+
+void SoundDB::load()
+{
+ unload();
+
+ XML::Document *doc = new XML::Document("sounds.xml");
+ XmlNodePtr root = doc->rootNode();
+
+ if (!root || !xmlNameEqual(root, "sounds"))
+ {
+ delete doc;
+ return;
+ }
+
+ for_each_xml_child_node(node, root)
+ {
+ if (xmlNameEqual(node, "sound"))
+ {
+ const std::string name = XML::getProperty(node, "name", "");
+ const int id = NotifyManager::getIndexBySound(name);
+ if (id)
+ {
+ const std::string value = XML::getProperty(node, "value", "");
+ mSounds[id] = value;
+ }
+ }
+ }
+
+ delete doc;
+}
+
+void SoundDB::unload()
+{
+ mSounds.resize(NotifyManager::TYPE_END);
+ for (int f = 0; f < NotifyManager::TYPE_END; f ++)
+ mSounds[f] = "";
+}
+
+std::string &SoundDB::getSound(const int id)
+{
+ if (id < 0 || id >= NotifyManager::TYPE_END)
+ return mDefault;
+ return mSounds[id];
+}
diff --git a/src/resources/sounddb.h b/src/resources/sounddb.h
new file mode 100644
index 000000000..fc1a71229
--- /dev/null
+++ b/src/resources/sounddb.h
@@ -0,0 +1,38 @@
+/*
+ * Color database
+ * Copyright (C) 2013 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 SOUNDDB_H
+#define SOUNDDB_H
+
+#include <map>
+#include <string>
+
+#include "localconsts.h"
+
+namespace SoundDB
+{
+ void load();
+
+ void unload();
+
+ std::string &getSound(const int id);
+}
+
+#endif