diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-11 21:56:38 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-11 21:56:38 +0200 |
commit | 5957475d12c7739fbe69e569316a33588c621c51 (patch) | |
tree | 542fb61c4034d477ee8bfe111efca3589471cef1 /src/sound.h | |
parent | d30a53bf394079f2286fcf1faa8932d0becc2980 (diff) | |
download | mana-5957475d12c7739fbe69e569316a33588c621c51.tar.gz mana-5957475d12c7739fbe69e569316a33588c621c51.tar.bz2 mana-5957475d12c7739fbe69e569316a33588c621c51.tar.xz mana-5957475d12c7739fbe69e569316a33588c621c51.zip |
Implemented a simple non-blocking fadeOutAndPlay system.
It's currently used when changing maps.
Resolves: TMW-Mantis: #750.
Reviewed-by: Thorbjorn.
Diffstat (limited to 'src/sound.h')
-rw-r--r-- | src/sound.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/sound.h b/src/sound.h index bfb3837b..1dee55e7 100644 --- a/src/sound.h +++ b/src/sound.h @@ -68,16 +68,25 @@ class Sound * @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); @@ -91,6 +100,13 @@ class Sound */ void playSfx(const std::string &path, int x = 0, int y = 0); + /** + * 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(); @@ -98,6 +114,12 @@ class Sound /** 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; |