summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-08 01:39:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-08 01:41:16 +0300
commit1319e54e6a7dab30ce2f95b0301964c53afe9e58 (patch)
tree2fa6ed8e3c5ba0f4255d9d89beb2a4941dcfea5d /src
parentd27fa21ab9363eb22f5077e085c54332da05899f (diff)
downloadmanaverse-1319e54e6a7dab30ce2f95b0301964c53afe9e58.tar.gz
manaverse-1319e54e6a7dab30ce2f95b0301964c53afe9e58.tar.bz2
manaverse-1319e54e6a7dab30ce2f95b0301964c53afe9e58.tar.xz
manaverse-1319e54e6a7dab30ce2f95b0301964c53afe9e58.zip
Play sound on getting new quest and complete quest.
New items for paths.xml: newQuestSfx and completeQuestSfx.
Diffstat (limited to 'src')
-rw-r--r--src/gui/questswindow.cpp25
-rw-r--r--src/gui/questswindow.h2
-rw-r--r--src/net/tmwa/questhandler.cpp4
-rw-r--r--src/sound.cpp3
4 files changed, 29 insertions, 5 deletions
diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp
index ebbb7f615..07abd3659 100644
--- a/src/gui/questswindow.cpp
+++ b/src/gui/questswindow.cpp
@@ -20,7 +20,9 @@
#include "gui/questswindow.h"
+#include "configuration.h"
#include "logger.h"
+#include "sound.h"
#include "gui/gui.h"
#include "gui/sdlfont.h"
@@ -247,7 +249,7 @@ void QuestsWindow::updateQuest(int var, int val)
mVars[var] = val;
}
-void QuestsWindow::rebuild()
+void QuestsWindow::rebuild(bool playSound)
{
mQuestsModel->clear();
mQuestLinks.clear();
@@ -256,6 +258,7 @@ void QuestsWindow::rebuild()
std::vector<QuestItem*> complete;
std::vector<QuestItem*> incomplete;
int updatedQuest = -1;
+ int newCompleteStatus = -1;
for (std::map<int, int>::const_iterator it = mVars.begin(),
it_end = mVars.end(); it != it_end; ++ it)
@@ -285,7 +288,10 @@ void QuestsWindow::rebuild()
{
QuestItem *quest = *it;
if (quest->completeFlag == 0)
+ {
updatedQuest = k;
+ newCompleteStatus = 1;
+ }
quest->completeFlag = 1;
mQuestLinks.push_back(quest);
names.push_back(quest->name);
@@ -305,7 +311,10 @@ void QuestsWindow::rebuild()
{
QuestItem *quest = *it;
if (quest->completeFlag == -1)
+ {
updatedQuest = k;
+ newCompleteStatus = 0;
+ }
quest->completeFlag = 0;
mQuestLinks.push_back(quest);
names.push_back(quest->name);
@@ -328,6 +337,20 @@ void QuestsWindow::rebuild()
{
mQuestsListBox->setSelected(updatedQuest);
showQuest(mQuestLinks[updatedQuest]);
+ if (playSound)
+ {
+ switch (newCompleteStatus)
+ {
+ case 0:
+ sound.playSfx(paths.getValue("newQuestSfx", ""));
+ break;
+ case 1:
+ sound.playSfx(paths.getValue("completeQuestSfx", ""));
+ break;
+ default:
+ break;
+ }
+ }
}
}
diff --git a/src/gui/questswindow.h b/src/gui/questswindow.h
index 5b7babb5d..0c4d5789e 100644
--- a/src/gui/questswindow.h
+++ b/src/gui/questswindow.h
@@ -59,7 +59,7 @@ class QuestsWindow : public Window, public gcn::ActionListener
void updateQuest(int var, int val);
- void rebuild();
+ void rebuild(bool playSound);
void showQuest(QuestItem *quest);
diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp
index b3cec9fe2..68ab75806 100644
--- a/src/net/tmwa/questhandler.cpp
+++ b/src/net/tmwa/questhandler.cpp
@@ -76,7 +76,7 @@ void QuestHandler::processSetQuestVar(Net::MessageIn &msg A_UNUSED)
if (questsWindow)
{
questsWindow->updateQuest(var, val);
- questsWindow->rebuild();
+ questsWindow->rebuild(true);
}
}
@@ -91,7 +91,7 @@ void QuestHandler::processPlayerQuests(Net::MessageIn &msg A_UNUSED)
questsWindow->updateQuest(var, val);
}
if (questsWindow)
- questsWindow->rebuild();
+ questsWindow->rebuild(false);
}
} // namespace TmwAthena
diff --git a/src/sound.cpp b/src/sound.cpp
index edabe6bf8..3e322a585 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -20,12 +20,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "sound.h"
+
#include <SDL.h>
#include "configuration.h"
#include "localplayer.h"
#include "logger.h"
-#include "sound.h"
#include "resources/music.h"
#include "resources/resourcemanager.h"