A bit better formatting in world status

This commit is contained in:
Deve 2014-08-30 18:34:44 +02:00
parent 507d9566a0
commit 47b46558f2

View File

@ -44,7 +44,9 @@ WorldStatus::WorldStatus()
m_play_racestart_sounds = true;
IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // WorldStatus
//-----------------------------------------------------------------------------
@ -62,7 +64,9 @@ void WorldStatus::reset()
m_track_intro_sound->stop();
IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // reset
//-----------------------------------------------------------------------------
@ -74,7 +78,9 @@ WorldStatus::~WorldStatus()
sfx_manager->deleteSFX(m_start_sound);
sfx_manager->deleteSFX(m_track_intro_sound);
IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // ~WorldStatus
//-----------------------------------------------------------------------------
@ -96,14 +102,12 @@ void WorldStatus::setClockMode(const ClockType mode, const float initial_time)
void WorldStatus::enterRaceOverState()
{
// Don't enter race over if it's already race over
if( m_phase == DELAY_FINISH_PHASE
|| m_phase == RESULT_DISPLAY_PHASE
|| m_phase == FINISH_PHASE )
if (m_phase == DELAY_FINISH_PHASE || m_phase == RESULT_DISPLAY_PHASE ||
m_phase == FINISH_PHASE)
return;
m_phase = DELAY_FINISH_PHASE;
m_auxiliary_timer = 0.0f;
} // enterRaceOverState
//-----------------------------------------------------------------------------
@ -148,7 +152,9 @@ void WorldStatus::update(const float dt)
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt * 6;
}
// Work around a bug that occurred on linux once:
// the sfx_manager kept on reporting that it is playing,
@ -156,57 +162,82 @@ void WorldStatus::update(const float dt)
// ... phase. Since the sound effect is about 3 seconds
// long, we use the aux timer to force the next phase
// after 3.5 seconds.
if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING
&& m_auxiliary_timer<3.5f)
if (m_track_intro_sound->getStatus() == SFXManager::SFX_PLAYING &&
m_auxiliary_timer < 3.5f)
return;
// Wait before ready phase if sounds are disabled
if (!UserConfigParams::m_sfx && m_auxiliary_timer < 3.0f)
return;
m_auxiliary_timer = 0.0f;
if (m_play_racestart_sounds) m_prestart_sound->play();
if (m_play_racestart_sounds)
m_prestart_sound->play();
m_phase = READY_PHASE;
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
{
World::getWorld()->getKart(i)->startEngineSFX();
}
break;
case READY_PHASE:
if (m_auxiliary_timer > 1.0)
{
if (m_play_racestart_sounds) m_prestart_sound->play();
if (m_play_racestart_sounds)
{
m_prestart_sound->play();
}
m_phase = SET_PHASE;
}
m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6;
}
return;
case SET_PHASE:
if (m_auxiliary_timer > 2.0)
{
// set phase is over, go to the next one
m_phase = GO_PHASE;
if (m_play_racestart_sounds) m_start_sound->play();
if (m_play_racestart_sounds)
{
m_start_sound->play();
}
World::getWorld()->getTrack()->startMusic();
// event
onGo();
}
m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6;
}
return;
case GO_PHASE :
if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic())
{
music_manager->startMusic(music_manager->getCurrentMusic());
}
if (m_auxiliary_timer > 3.0f) // how long to display the 'go' message
{
@ -219,12 +250,18 @@ void WorldStatus::update(const float dt)
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6;
}
break;
case MUSIC_PHASE:
// how long to display the 'music' message
if (m_auxiliary_timer>stk_config->m_music_credit_time)
{
m_phase = RACE_PHASE;
}
m_auxiliary_timer += dt;
break;
case RACE_PHASE:
@ -241,6 +278,7 @@ void WorldStatus::update(const float dt)
m_phase = RESULT_DISPLAY_PHASE;
terminateRace();
}
break;
}
case RESULT_DISPLAY_PHASE:
@ -298,10 +336,13 @@ void WorldStatus::setTime(const float time)
void WorldStatus::pause(Phase phase)
{
assert(m_previous_phase == UNDEFINED_PHASE);
m_previous_phase = m_phase;
m_phase = phase;
IrrlichtDevice *device = irr_driver->getDevice();
if (!device->getTimer()->isStopped()) device->getTimer()->stop();
if (!device->getTimer()->isStopped())
device->getTimer()->stop();
} // pause
//-----------------------------------------------------------------------------
@ -314,5 +355,7 @@ void WorldStatus::unpause()
// in pause to detect incorrect pause/unpause sequences.
m_previous_phase = UNDEFINED_PHASE;
IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // unpause