Fixed sound being shortly unpaused when switching screen and sound is off
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6265 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -254,8 +254,10 @@ void SFXOpenAL::onSoundEnabledBack()
|
||||
if (!m_ok) init();
|
||||
if (m_ok)
|
||||
{
|
||||
alSourcef(m_soundSource, AL_GAIN, 0);
|
||||
play();
|
||||
pause();
|
||||
alSourcef(m_soundSource, AL_GAIN, (m_gain < 0.0f ? m_defaultGain : m_gain));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
|
||||
m_use_highscores = true;
|
||||
m_track = NULL;
|
||||
m_clear_back_buffer = false;
|
||||
m_schedule_pause = false;
|
||||
m_schedule_unpause = false;
|
||||
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
} // World
|
||||
@@ -397,6 +399,32 @@ void World::resetAllKarts()
|
||||
m_karts[i]->getCamera()->setInitialTransform();
|
||||
} // resetAllKarts
|
||||
|
||||
|
||||
void World::pause(Phase phase)
|
||||
{
|
||||
if (m_schedule_unpause)
|
||||
{
|
||||
m_schedule_unpause = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_schedule_pause = true;
|
||||
m_scheduled_pause_phase = phase;
|
||||
}
|
||||
}
|
||||
|
||||
void World::unpause()
|
||||
{
|
||||
if (m_schedule_pause)
|
||||
{
|
||||
m_schedule_pause = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_schedule_unpause = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This is the main interface to update the world. This function calls
|
||||
* update(), and checks then for the end of the race. Note that race over
|
||||
@@ -409,6 +437,17 @@ void World::resetAllKarts()
|
||||
*/
|
||||
void World::updateWorld(float dt)
|
||||
{
|
||||
if (m_schedule_pause)
|
||||
{
|
||||
doPause(m_scheduled_pause_phase);
|
||||
m_schedule_pause = false;
|
||||
}
|
||||
else if (m_schedule_unpause)
|
||||
{
|
||||
doUnpause();
|
||||
m_schedule_unpause = false;
|
||||
}
|
||||
|
||||
// Don't update world if a menu is shown or the race is over.
|
||||
if( m_phase == FINISH_PHASE ||
|
||||
m_phase == IN_GAME_MENU_PHASE )
|
||||
@@ -690,7 +729,7 @@ void World::restartRace()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Pauses the music (and then pauses WorldStatus).
|
||||
*/
|
||||
void World::pause(Phase phase)
|
||||
void World::doPause(Phase phase)
|
||||
{
|
||||
music_manager->pauseMusic();
|
||||
sfx_manager->pauseAll();
|
||||
@@ -698,7 +737,7 @@ void World::pause(Phase phase)
|
||||
} // pause
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void World::unpause()
|
||||
void World::doUnpause()
|
||||
{
|
||||
music_manager->resumeMusic() ;
|
||||
sfx_manager->resumeAll();
|
||||
|
||||
@@ -146,6 +146,25 @@ protected:
|
||||
*/
|
||||
virtual float estimateFinishTimeForKart(Kart* kart) {return getTime(); }
|
||||
|
||||
/** Pausing/unpausing are not done immediately, but at next udpdate. The use of
|
||||
this is when switching between screens : if we leave a screen that paused the
|
||||
game, only to go to another screen that pauses back the game, this mechanism
|
||||
prevents the game from moving on between the switch
|
||||
*/
|
||||
bool m_schedule_pause;
|
||||
|
||||
/** Pausing/unpausing are not done immediately, but at next udpdate. The use of
|
||||
this is when switching between screens : if we leave a screen that paused the
|
||||
game, only to go to another screen that pauses back the game, this mechanism
|
||||
prevents the game from moving on between the switch
|
||||
*/
|
||||
bool m_schedule_unpause;
|
||||
|
||||
Phase m_scheduled_pause_phase;
|
||||
|
||||
void doPause(Phase phase);
|
||||
void doUnpause();
|
||||
|
||||
public:
|
||||
World();
|
||||
virtual ~World();
|
||||
|
||||
Reference in New Issue
Block a user