From 4cd8cf7f527553abad86c07c8ebbb2ba8b5d3699 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Mon, 11 Apr 2011 21:56:38 +0200 Subject: Implemented a simple non-blocking fadeOutAndPlay system. It's currently used when changing maps. Resolves: TMW-Mantis: #750. Reviewed-by: Thorbjorn. Conflicts: src/game.cpp src/sound.cpp src/sound.h --- src/sound.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/sound.h') diff --git a/src/sound.h b/src/sound.h index 0de9f0636..6a509a574 100644 --- a/src/sound.h +++ b/src/sound.h @@ -73,16 +73,25 @@ class Sound : public ConfigListener * @param path The full path to the music file. * @param ms Duration of fade-in effect (ms) */ - void fadeInMusic(const std::string &path, int ms = 2000); + void fadeInMusic(const std::string &path, int ms = 1000); /** * Fades out currently running background music track. * * @param ms Duration of fade-out effect (ms) */ - void fadeOutMusic(int ms); + void fadeOutMusic(int ms = 1000); - int getMaxVolume() const; + /** + * Fades out a background music and play a new one. + * + * @param path The full path to the fade in music file. + * @param ms Duration of fade-out effect (ms) + */ + void fadeOutAndPlayMusic(const std::string &path, int ms = 1000); + + int getMaxVolume() const + { return MIX_MAX_VOLUME; } void setMusicVolume(int volume); void setSfxVolume(int volume); @@ -110,6 +119,13 @@ class Sound : public ConfigListener std::string getCurrentMusicFile() { return mCurrentMusicFile; } + /** + * The sound logic. + * Currently used to check whether the music file can be freed after + * a fade out, and whether new music has to be played. + */ + void logic(); + private: /** Logs various info about sound device. */ void info(); @@ -117,6 +133,12 @@ class Sound : public ConfigListener /** Halts and frees currently playing music. */ void haltMusic(); + /** + * When calling fadeOutAndPlayMusic(), + * the music file below will then be played + */ + std::string mNextMusicPath; + bool mInstalled; int mSfxVolume; -- cgit v1.2.3-60-g2f50