Draw music description properly in network
This commit is contained in:
parent
62ce61d980
commit
7a112ee6ef
@ -173,7 +173,7 @@
|
|||||||
<delay-finish time="1.0"/>
|
<delay-finish time="1.0"/>
|
||||||
|
|
||||||
<!-- How long the music credits are shown. -->
|
<!-- How long the music credits are shown. -->
|
||||||
<credits music="10"/>
|
<credits music="8"/>
|
||||||
|
|
||||||
<!-- time is the time till a bomb explodes. time-increase is the time added
|
<!-- time is the time till a bomb explodes. time-increase is the time added
|
||||||
to timer when bomb is passed on. -->
|
to timer when bomb is passed on. -->
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "guiengine/modaldialog.hpp"
|
#include "guiengine/modaldialog.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/profile_world.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
#include "network/protocols/client_lobby.hpp"
|
#include "network/protocols/client_lobby.hpp"
|
||||||
#include "network/rewind_manager.hpp"
|
#include "network/rewind_manager.hpp"
|
||||||
@ -65,7 +65,9 @@ void WorldStatus::reset(bool restart)
|
|||||||
m_time_ticks = 0;
|
m_time_ticks = 0;
|
||||||
m_auxiliary_ticks = 0;
|
m_auxiliary_ticks = 0;
|
||||||
m_count_up_ticks = 0;
|
m_count_up_ticks = 0;
|
||||||
|
m_start_music_ticks = -1;
|
||||||
|
m_race_ticks = -1;
|
||||||
|
m_live_join_ticks = -1;
|
||||||
m_engines_started = false;
|
m_engines_started = false;
|
||||||
|
|
||||||
// Using SETUP_PHASE will play the track into sfx first, and has no
|
// Using SETUP_PHASE will play the track into sfx first, and has no
|
||||||
@ -335,6 +337,21 @@ void WorldStatus::updateTime(int ticks)
|
|||||||
|
|
||||||
// event
|
// event
|
||||||
onGo();
|
onGo();
|
||||||
|
// In artist debug mode, when without opponents,
|
||||||
|
// skip the ready/set/go counter faster
|
||||||
|
m_start_music_ticks =
|
||||||
|
UserConfigParams::m_artist_debug_mode &&
|
||||||
|
!NetworkConfig::get()->isNetworking() &&
|
||||||
|
race_manager->getNumberOfKarts() -
|
||||||
|
race_manager->getNumSpareTireKarts() == 1 &&
|
||||||
|
race_manager->getTrackName() != "tutorial" ?
|
||||||
|
stk_config->time2Ticks(0.2f) :
|
||||||
|
stk_config->time2Ticks(1.0f);
|
||||||
|
// how long to display the 'music' message
|
||||||
|
// no graphics mode goes race phase at 3 seconds;
|
||||||
|
m_race_ticks = ProfileWorld::isNoGraphics() ?
|
||||||
|
stk_config->time2Ticks(3.0f) :
|
||||||
|
stk_config->time2Ticks(stk_config->m_music_credit_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_auxiliary_ticks++;
|
m_auxiliary_ticks++;
|
||||||
@ -351,49 +368,36 @@ void WorldStatus::updateTime(int ticks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return; // Do not increase time
|
return; // Do not increase time
|
||||||
case GO_PHASE :
|
case GO_PHASE:
|
||||||
// 2.5 seconds
|
{
|
||||||
if (m_auxiliary_ticks>stk_config->time2Ticks(2.5f) &&
|
if (m_start_music_ticks != -1 &&
|
||||||
music_manager->getCurrentMusic() &&
|
m_count_up_ticks >= m_start_music_ticks)
|
||||||
!music_manager->getCurrentMusic()->isPlaying())
|
|
||||||
{
|
|
||||||
music_manager->startMusic();
|
|
||||||
}
|
|
||||||
// how long to display the 'go' message
|
|
||||||
if (m_auxiliary_ticks > 3 * stk_config->getPhysicsFPS())
|
|
||||||
{
|
{
|
||||||
|
m_start_music_ticks = -1;
|
||||||
|
if (music_manager->getCurrentMusic() &&
|
||||||
|
!music_manager->getCurrentMusic()->isPlaying())
|
||||||
|
{
|
||||||
|
music_manager->startMusic();
|
||||||
|
}
|
||||||
m_phase = MUSIC_PHASE;
|
m_phase = MUSIC_PHASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_auxiliary_ticks++;
|
|
||||||
|
|
||||||
// In artist debug mode, when without opponents,
|
|
||||||
// skip the ready/set/go counter faster
|
|
||||||
if (UserConfigParams::m_artist_debug_mode &&
|
|
||||||
race_manager->getNumberOfKarts() -
|
|
||||||
race_manager->getNumSpareTireKarts() == 1 &&
|
|
||||||
race_manager->getTrackName() != "tutorial")
|
|
||||||
{
|
|
||||||
m_auxiliary_ticks += 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
break; // Now the world time starts
|
break; // Now the world time starts
|
||||||
|
}
|
||||||
case MUSIC_PHASE:
|
case MUSIC_PHASE:
|
||||||
|
{
|
||||||
// Start the music here when starting fast
|
// Start the music here when starting fast
|
||||||
if (UserConfigParams::m_race_now)
|
if (UserConfigParams::m_race_now)
|
||||||
{
|
{
|
||||||
music_manager->startMusic();
|
music_manager->startMusic();
|
||||||
UserConfigParams::m_race_now = false;
|
UserConfigParams::m_race_now = false;
|
||||||
}
|
}
|
||||||
// how long to display the 'music' message
|
if (m_race_ticks != -1 && m_count_up_ticks >= m_race_ticks)
|
||||||
if (m_auxiliary_ticks >
|
|
||||||
stk_config->time2Ticks(stk_config->m_music_credit_time) )
|
|
||||||
{
|
{
|
||||||
|
m_race_ticks = -1;
|
||||||
m_phase = RACE_PHASE;
|
m_phase = RACE_PHASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_auxiliary_ticks++;
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RACE_PHASE:
|
case RACE_PHASE:
|
||||||
// Nothing to do for race phase, switch to delay finish phase
|
// Nothing to do for race phase, switch to delay finish phase
|
||||||
// happens when
|
// happens when
|
||||||
@ -465,6 +469,7 @@ void WorldStatus::updateTime(int ticks)
|
|||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
} // switch m_phase
|
} // switch m_phase
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -545,11 +550,14 @@ void WorldStatus::unpause()
|
|||||||
*/
|
*/
|
||||||
void WorldStatus::endLiveJoinWorld(int ticks_now)
|
void WorldStatus::endLiveJoinWorld(int ticks_now)
|
||||||
{
|
{
|
||||||
|
m_live_join_ticks = ticks_now;
|
||||||
m_live_join_world = false;
|
m_live_join_world = false;
|
||||||
m_auxiliary_ticks = 0;
|
m_auxiliary_ticks = 0;
|
||||||
m_phase = RACE_PHASE;
|
m_phase = MUSIC_PHASE;
|
||||||
|
m_race_ticks = m_live_join_ticks + stk_config->time2Ticks(
|
||||||
|
stk_config->m_music_credit_time);
|
||||||
onGo();
|
onGo();
|
||||||
startEngines();
|
startEngines();
|
||||||
music_manager->startMusic();
|
music_manager->startMusic();
|
||||||
setTicksForRewind(ticks_now);
|
setTicksForRewind(m_live_join_ticks);
|
||||||
} // endLiveJoinWorld
|
} // endLiveJoinWorld
|
||||||
|
@ -130,6 +130,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
int m_auxiliary_ticks;
|
int m_auxiliary_ticks;
|
||||||
|
|
||||||
|
int m_start_music_ticks;
|
||||||
|
|
||||||
|
int m_race_ticks;
|
||||||
|
|
||||||
|
int m_live_join_ticks;
|
||||||
|
|
||||||
/** Special counter to count ticks since start (in terms of physics
|
/** Special counter to count ticks since start (in terms of physics
|
||||||
* timestep size). */
|
* timestep size). */
|
||||||
int m_count_up_ticks;
|
int m_count_up_ticks;
|
||||||
@ -219,6 +225,12 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setLiveJoinWorld(bool val) { m_live_join_world = val; }
|
void setLiveJoinWorld(bool val) { m_live_join_world = val; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
int getMusicDescriptionTicks() const
|
||||||
|
{
|
||||||
|
return m_live_join_ticks == -1 ?
|
||||||
|
m_count_up_ticks : m_count_up_ticks - m_live_join_ticks;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
void endLiveJoinWorld(int ticks_now);
|
void endLiveJoinWorld(int ticks_now);
|
||||||
}; // WorldStatus
|
}; // WorldStatus
|
||||||
|
|
||||||
|
@ -527,12 +527,11 @@ void RaceGUIBase::drawGlobalMusicDescription()
|
|||||||
gui::IGUIFont* font = GUIEngine::getFont();
|
gui::IGUIFont* font = GUIEngine::getFont();
|
||||||
|
|
||||||
float race_time =
|
float race_time =
|
||||||
stk_config->ticks2Time(World::getWorld()->getTicksSinceStart());
|
stk_config->ticks2Time(World::getWorld()->getMusicDescriptionTicks());
|
||||||
|
|
||||||
// ---- Manage pulsing effect
|
// ---- Manage pulsing effect
|
||||||
// 3.0 is the duration of ready/set (TODO: don't hardcode)
|
|
||||||
float timeProgression = (float)(race_time) /
|
float timeProgression = (float)(race_time) /
|
||||||
(float)(stk_config->m_music_credit_time - 2.0f);
|
(float)(stk_config->m_music_credit_time);
|
||||||
|
|
||||||
const int x_pulse = (int)(sin(race_time*9.0f)*10.0f);
|
const int x_pulse = (int)(sin(race_time*9.0f)*10.0f);
|
||||||
const int y_pulse = (int)(cos(race_time*9.0f)*10.0f);
|
const int y_pulse = (int)(cos(race_time*9.0f)*10.0f);
|
||||||
|
Loading…
Reference in New Issue
Block a user