summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-25 19:32:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-25 19:32:16 +0300
commitefb4b7ff6abee2932fd2a71e269f1d81c75618da (patch)
treee8b61af5bedc8174a720e649675fb6c3e65547c0
parent036b55e414e6f25c1187753c3de6ac561c022996 (diff)
downloadmv-efb4b7ff6abee2932fd2a71e269f1d81c75618da.tar.gz
mv-efb4b7ff6abee2932fd2a71e269f1d81c75618da.tar.bz2
mv-efb4b7ff6abee2932fd2a71e269f1d81c75618da.tar.xz
mv-efb4b7ff6abee2932fd2a71e269f1d81c75618da.zip
Add option to enable/disable music fade out (disabled by default).
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/setup_audio.cpp4
-rw-r--r--src/soundmanager.cpp14
-rw-r--r--src/soundmanager.h3
4 files changed, 20 insertions, 2 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 6cdfedfc6..42d6f1fd9 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -293,6 +293,7 @@ DefaultsData* getConfigDefaults()
AddDEF("highlightWords", "");
AddDEF("selfMouseHeal", true);
AddDEF("serverslistupdate", "");
+ AddDEF("fadeoutmusic", false);
return configData;
}
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 79bbc2d14..faea24c1e 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -82,6 +82,10 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) :
new SetupItemSlider(_("Music volume"), "", "musicVolume",
this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true);
+ new SetupItemCheckBox(_("Enable music fade out (can be very slow)"), "",
+ "fadeoutmusic", this, "fadeoutmusicEvent");
+
+
new SetupItemIntTextField(_("Audio frequency"), "",
"audioFrequency", this, "audioFrequencyEvent", 14000, 192000);
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 7ab66110a..5fc06eb79 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -56,6 +56,7 @@ SoundManager::SoundManager():
mPlayBattle(false),
mPlayGui(false),
mPlayMusic(false),
+ mFadeoutMusic(true),
mGuiChannel(-1)
{
// This set up our callback function used to
@@ -88,6 +89,8 @@ void SoundManager::optionChanged(const std::string &value)
setSfxVolume(config.getIntValue("sfxVolume"));
else if (value == "musicVolume")
setMusicVolume(config.getIntValue("musicVolume"));
+ else if (value == "fadeoutmusic")
+ mFadeoutMusic = config.getIntValue("fadeoutmusic");
}
void SoundManager::init()
@@ -101,11 +104,16 @@ void SoundManager::init()
mPlayBattle = config.getBoolValue("playBattleSound");
mPlayGui = config.getBoolValue("playGuiSound");
mPlayMusic = config.getBoolValue("playMusic");
+ mFadeoutMusic = config.getBoolValue("fadeoutmusic");
+ mMusicVolume = config.getIntValue("musicVolume");
+ mSfxVolume = config.getIntValue("sfxVolume");
+
config.addListener("playBattleSound", this);
config.addListener("playGuiSound", this);
config.addListener("playMusic", this);
config.addListener("sfxVolume", this);
config.addListener("musicVolume", this);
+ config.addListener("fadeoutmusic", this);
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
{
@@ -244,6 +252,7 @@ void SoundManager::stopMusic()
haltMusic();
}
+/*
void SoundManager::fadeInMusic(const std::string &fileName, const int ms)
{
mCurrentMusicFile = fileName;
@@ -260,6 +269,7 @@ void SoundManager::fadeInMusic(const std::string &fileName, const int ms)
mMusic->play(-1, ms);
}
}
+*/
void SoundManager::fadeOutMusic(const int ms)
{
@@ -270,7 +280,7 @@ void SoundManager::fadeOutMusic(const int ms)
logger->log("SoundManager::fadeOutMusic() Fading-out (%i ms)", ms);
- if (mMusic)
+ if (mMusic && mFadeoutMusic)
{
Mix_FadeOutMusic(ms);
// Note: The fadeOutCallBack handler will take care about freeing
@@ -279,6 +289,8 @@ void SoundManager::fadeOutMusic(const int ms)
else
{
sFadingOutEnded = true;
+ if (!mFadeoutMusic)
+ haltMusic();
}
}
diff --git a/src/soundmanager.h b/src/soundmanager.h
index d36cad92b..227b03579 100644
--- a/src/soundmanager.h
+++ b/src/soundmanager.h
@@ -87,7 +87,7 @@ class SoundManager final : public ConfigListener
* @param fileName The name of the music file.
* @param ms Duration of fade-in effect (ms)
*/
- void fadeInMusic(const std::string &fileName, const int ms = 1000);
+// void fadeInMusic(const std::string &fileName, const int ms = 1000);
/**
* Fades out currently running background music track.
@@ -170,6 +170,7 @@ class SoundManager final : public ConfigListener
bool mPlayBattle;
bool mPlayGui;
bool mPlayMusic;
+ bool mFadeoutMusic;
int mGuiChannel;
};