Fixed music starting in menu, also corrected using the startRightNow parameter in MusicManager::startMusic()

This commit is contained in:
Torben Carrington 2014-01-16 19:13:23 -08:00
parent 472274561d
commit 15401c0b02
4 changed files with 15 additions and 1 deletions

View File

@ -273,6 +273,8 @@ void MusicInformation::stopMusic()
delete m_fast_music; delete m_fast_music;
m_fast_music=NULL; m_fast_music=NULL;
} }
if(m_music_waiting)
m_music_waiting = false;
} // stopMusic } // stopMusic
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -284,6 +286,12 @@ void MusicInformation::pauseMusic()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MusicInformation::resumeMusic() void MusicInformation::resumeMusic()
{ {
if(m_music_waiting)
{
startMusic();
m_music_waiting = false;
return;
}
if (m_normal_music != NULL) m_normal_music->resumeMusic(); if (m_normal_music != NULL) m_normal_music->resumeMusic();
if (m_fast_music != NULL) m_fast_music->resumeMusic(); if (m_fast_music != NULL) m_fast_music->resumeMusic();
} // resumeMusic } // resumeMusic

View File

@ -48,6 +48,10 @@ private:
std::vector<std::string> m_all_tracks; std::vector<std::string> m_all_tracks;
//int m_numLoops; //int m_numLoops;
/** If music is loaded but hasn't been started yet (MusicManager::startMusic()
* was told not to start right away). */
bool m_music_waiting;
/** If faster music is enabled at all (either separate file or using /** If faster music is enabled at all (either separate file or using
* the pitch shift approach). */ * the pitch shift approach). */
bool m_enable_fast; bool m_enable_fast;
@ -87,6 +91,7 @@ public:
//int getNumLoops () const {return m_numLoops; } //int getNumLoops () const {return m_numLoops; }
float getFasterTime () const {return m_faster_time; } float getFasterTime () const {return m_faster_time; }
float getMaxPitch () const {return m_max_pitch; } float getMaxPitch () const {return m_max_pitch; }
void setMusicWaiting () {m_music_waiting = true;}
void addMusicToTracks (); void addMusicToTracks ();
void update (float dt); void update (float dt);
void startMusic (); void startMusic ();

View File

@ -182,6 +182,7 @@ void MusicManager::startMusic(MusicInformation* mi, bool startRightNow)
mi->volumeMusic(m_masterGain); mi->volumeMusic(m_masterGain);
if (startRightNow) mi->startMusic(); if (startRightNow) mi->startMusic();
else mi->setMusicWaiting();
} // startMusic } // startMusic
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -147,7 +147,7 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
if(w->getState() == false) if(w->getState() == false)
music_manager->stopMusic(); music_manager->stopMusic();
else else
music_manager->startMusic(music_manager->getCurrentMusic()); music_manager->startMusic(music_manager->getCurrentMusic(), 0);
} }
else if(name == "sfx_enabled") else if(name == "sfx_enabled")
{ {