summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-04 23:14:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-04 23:14:37 (GMT)
commit326cd32e2c9e3ec9bac54f5bb952928680c93749 (patch)
tree6992a6810897fdcdc9cce9cc2c7e2b79bf0e6011 /Swift/Controllers/SoundEventController.cpp
parenta9173b68bf4a44325ec55843017d65d04a7f0c75 (diff)
downloadswift-326cd32e2c9e3ec9bac54f5bb952928680c93749.zip
swift-326cd32e2c9e3ec9bac54f5bb952928680c93749.tar.bz2
Allow sounds to be toggled.
Doesn't persist option yet. Resolves: #192
Diffstat (limited to 'Swift/Controllers/SoundEventController.cpp')
-rw-r--r--Swift/Controllers/SoundEventController.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp
index 456de44..29f7fbf 100644
--- a/Swift/Controllers/SoundEventController.cpp
+++ b/Swift/Controllers/SoundEventController.cpp
@@ -4,14 +4,18 @@
#include "Swift/Controllers/EventController.h"
#include "Swift/Controllers/SoundPlayer.h"
+#include "Swift/Controllers/UIEvents/UIEventStream.h"
+#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h"
namespace Swift {
-SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds) {
+SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds, UIEventStream* uiEvents) {
eventController_ = eventController;
eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1));
soundPlayer_ = soundPlayer;
playSounds_ = playSounds;
+ uiEvents_ = uiEvents;
+ uiEvents_->onUIEvent.connect(boost::bind(&SoundEventController::handleUIEvent, this, _1));
}
void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent>) {
@@ -22,4 +26,11 @@ void SoundEventController::setPlaySounds(bool playSounds) {
playSounds_ = playSounds;
}
+void SoundEventController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
+ boost::shared_ptr<ToggleSoundsUIEvent> soundEvent = boost::dynamic_pointer_cast<ToggleSoundsUIEvent>(event);
+ if (soundEvent) {
+ setPlaySounds(soundEvent->getEnabled());
+ }
+}
+
}