Make demo mode use less hard-coded items
The player kart, difficulty, game mode, and reverse are no longer static values Also ensure that there is a value pressed when exiting demo via a keypress
This commit is contained in:
parent
969de9e751
commit
f269b4db91
@ -590,7 +590,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
|
|||||||
// Abort demo mode if a key is pressed during the race in demo mode,
|
// Abort demo mode if a key is pressed during the race in demo mode,
|
||||||
// if a dialog is not active
|
// if a dialog is not active
|
||||||
if(dynamic_cast<DemoWorld*>(World::getWorld()) &&
|
if(dynamic_cast<DemoWorld*>(World::getWorld()) &&
|
||||||
!GUIEngine::ModalDialog::isADialogActive())
|
!GUIEngine::ModalDialog::isADialogActive() && value)
|
||||||
{
|
{
|
||||||
RaceManager::get()->exitRace();
|
RaceManager::get()->exitRace();
|
||||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||||
|
@ -48,9 +48,36 @@ DemoWorld::DemoWorld()
|
|||||||
setPhase(SETUP_PHASE);
|
setPhase(SETUP_PHASE);
|
||||||
m_abort = false;
|
m_abort = false;
|
||||||
ProfileWorld::setProfileModeLaps(m_num_laps);
|
ProfileWorld::setProfileModeLaps(m_num_laps);
|
||||||
RaceManager::get()->setReverseTrack(false);
|
|
||||||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
|
// Randomly select whether reverse mode is activated or not.
|
||||||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
if (rand() % 2 == 0)
|
||||||
|
RaceManager::get()->setReverseTrack(true);
|
||||||
|
else
|
||||||
|
RaceManager::get()->setReverseTrack(false);
|
||||||
|
|
||||||
|
// Selects the user's current game mode setting (not all modes are supported)
|
||||||
|
switch (atoi(UserConfigParams::m_game_mode.toString().c_str()))
|
||||||
|
{
|
||||||
|
case 0: RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE); break;
|
||||||
|
case 1: RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL); break;
|
||||||
|
case 2: RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER); break;
|
||||||
|
default: RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE); break;
|
||||||
|
}
|
||||||
|
// Selects the user's current difficulty setting
|
||||||
|
switch (atoi(UserConfigParams::m_difficulty.toString().c_str()))
|
||||||
|
{
|
||||||
|
case 0: RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY); break;
|
||||||
|
case 1: RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_MEDIUM); break;
|
||||||
|
case 2: RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_HARD); break;
|
||||||
|
case 3: RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_BEST); break;
|
||||||
|
default: RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_HARD); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info("[DemoWorld]", "Reverse mode state: %d", RaceManager::get()->getReverseTrack());
|
||||||
|
Log::info("[DemoWorld]", "Current game mode: %s", RaceManager::get()->getMinorModeName().c_str());
|
||||||
|
Log::info("[DemoWorld]", "Current difficulty: %s", RaceManager::get()->
|
||||||
|
getDifficultyAsString(RaceManager::get()->getDifficulty()).c_str());
|
||||||
|
|
||||||
RaceManager::get()->setNumKarts(m_default_num_karts);
|
RaceManager::get()->setNumKarts(m_default_num_karts);
|
||||||
RaceManager::get()->setNumPlayers(1);
|
RaceManager::get()->setNumPlayers(1);
|
||||||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||||
@ -155,7 +182,8 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
|
|||||||
|
|
||||||
m_do_demo = true;
|
m_do_demo = true;
|
||||||
RaceManager::get()->setNumKarts(m_default_num_karts);
|
RaceManager::get()->setNumKarts(m_default_num_karts);
|
||||||
RaceManager::get()->setPlayerKart(0, "tux");
|
// Use the user's last selected kart
|
||||||
|
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||||
RaceManager::get()->setupPlayerKartInfo();
|
RaceManager::get()->setupPlayerKartInfo();
|
||||||
RaceManager::get()->startSingleRace(m_demo_tracks[0], m_num_laps, false);
|
RaceManager::get()->startSingleRace(m_demo_tracks[0], m_num_laps, false);
|
||||||
m_demo_tracks.push_back(m_demo_tracks[0]);
|
m_demo_tracks.push_back(m_demo_tracks[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user