From e0d746af17c486b66cdf37b5911ede05b08e9331 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Feb 2011 16:09:40 +0200 Subject: Start/Stop playing music after enable/disable music. --- src/gui/setup_audio.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/gui/setup_audio.cpp') diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 66a7a4e88..03f4479e1 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -26,6 +26,7 @@ #include "sound.h" #include "gui/okdialog.h" +#include "gui/viewport.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/label.h" @@ -106,7 +107,6 @@ void Setup_Audio::apply() config.setValue("sound", mAudioEnabled); config.setValue("playBattleSound", mGameSoundEnabled); config.setValue("playGuiSound", mGuiSoundEnabled); - config.setValue("playMusic", mMusicEnabled); config.setValue("enableMumble", mMumbleEnabled); @@ -130,11 +130,30 @@ void Setup_Audio::apply() new OkDialog(_("Sound Engine"), err); logger->log("Warning: %s", err); } + if (mMusicEnabled) + { + if (viewport && !config.getBoolValue("playMusic")) + { + Map *map = viewport->getMap(); + if (map) + { + config.setValue("playMusic", mMusicEnabled); + sound.playMusic(map->getMusicFile()); + } + } + } + else if (config.getBoolValue("playMusic")) + { + sound.stopMusic(); + } + } else { sound.close(); } + + config.setValue("playMusic", mMusicEnabled); } void Setup_Audio::cancel() @@ -155,11 +174,11 @@ void Setup_Audio::cancel() config.setValue("sound", mAudioEnabled); config.setValue("playBattleSound", mGameSoundEnabled); config.setValue("playGuiSound", mGuiSoundEnabled); - config.setValue("playMusic", mMusicEnabled); config.setValue("enableMumble", mMumbleEnabled); config.setValue("download-music", mDownloadEnabled); config.setValue("sfxVolume", mSfxVolume); config.setValue("musicVolume", mMusicVolume); + config.setValue("playMusic", mMusicEnabled); } void Setup_Audio::action(const gcn::ActionEvent &event) -- cgit v1.2.3-60-g2f50