From 1319e54e6a7dab30ce2f95b0301964c53afe9e58 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 8 Aug 2012 01:39:10 +0300 Subject: Play sound on getting new quest and complete quest. New items for paths.xml: newQuestSfx and completeQuestSfx. --- src/gui/questswindow.cpp | 25 ++++++++++++++++++++++++- src/gui/questswindow.h | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src/gui') 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 complete; std::vector incomplete; int updatedQuest = -1; + int newCompleteStatus = -1; for (std::map::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); -- cgit v1.2.3-60-g2f50