Permalink
Browse files

Improve code to switch between GUI-cutscenes. Still not fully functio…

…nal, but better
  • Loading branch information...
1 parent 1dc6384 commit e5532c32ffef1370d211127902aeeeb4c5a7e22d @auriamg auriamg committed Jun 11, 2014
@@ -140,7 +140,7 @@ void AbstractStateManager::pushScreen(Screen* screen)
void AbstractStateManager::replaceTopMostScreen(Screen* screen)
{
- assert(m_game_mode != GAME);
+ //assert(m_game_mode != GAME);
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
@@ -156,7 +156,8 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen)
assert(m_menu_stack.size() > 0);
// Send tear-down event to previous menu
- getCurrentScreen()->tearDown();
+ if (getCurrentScreen() != NULL)
+ getCurrentScreen()->tearDown();
m_menu_stack[m_menu_stack.size()-1] = name;
switchToScreen(name.c_str());
@@ -32,6 +32,7 @@
#include "physics/physics.hpp"
#include "states_screens/credits.hpp"
#include "states_screens/cutscene_gui.hpp"
+#include "states_screens/feature_unlocked.hpp"
#include "states_screens/offline_kart_selection.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "tracks/track.hpp"
@@ -367,20 +368,26 @@ void CutsceneWorld::update(float dt)
}
}
- bool isOver = (m_time > m_duration);
- if (isOver && (s_use_duration || m_aborted))
- {
- GUIEngine::CutsceneScreen* cs = dynamic_cast<GUIEngine::CutsceneScreen*>(
- GUIEngine::getCurrentScreen());
- if (cs != NULL)
- cs->onCutsceneEnd();
- }
+ //bool isOver = (m_time > m_duration);
+ //if (isOver && (s_use_duration || m_aborted))
+ //{
+ // GUIEngine::CutsceneScreen* cs = dynamic_cast<GUIEngine::CutsceneScreen*>(
+ // GUIEngine::getCurrentScreen());
+ // if (cs != NULL)
+ // cs->onCutsceneEnd();
+ //}
} // update
//-----------------------------------------------------------------------------
void CutsceneWorld::enterRaceOverState()
{
+ GUIEngine::CutsceneScreen* cs = dynamic_cast<GUIEngine::CutsceneScreen*>(
+ GUIEngine::getCurrentScreen());
+ if (cs != NULL)
+ cs->onCutsceneEnd();
+
+
int partId = -1;
for (int i=0; i<(int)m_parts.size(); i++)
{
@@ -408,9 +415,49 @@ void CutsceneWorld::enterRaceOverState()
else if (m_parts.size() == 1 && m_parts[0] == "gpwin")
{
race_manager->exitRace();
- StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
- if (race_manager->raceWasStartedFromOverworld())
- OverWorld::enterOverWorld();
+
+ // un-set the GP mode so that after unlocking, it doesn't try to continue the GP
+ race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
+
+ if (PlayerManager::getCurrentPlayer()
+ ->getRecentlyCompletedChallenges().size() > 0)
+ {
+ std::vector<const ChallengeData*> unlocked =
+ PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
+ PlayerManager::getCurrentPlayer()->clearUnlocked();
+
+ StateManager::get()->enterGameState();
+ race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
+ race_manager->setNumKarts(0);
+ race_manager->setNumPlayers(0);
+ race_manager->setNumLocalPlayers(0);
+ race_manager->startSingleRace("featunlocked", 999, false);
+
+ FeatureUnlockedCutScene* scene =
+ FeatureUnlockedCutScene::getInstance();
+ std::vector<std::string> parts;
+ parts.push_back("featunlocked");
+ ((CutsceneWorld*)World::getWorld())->setParts(parts);
+
+ assert(unlocked.size() > 0);
+ scene->addTrophy(race_manager->getDifficulty());
+ scene->findWhatWasUnlocked(race_manager->getDifficulty());
+
+ StateManager::get()->replaceTopMostScreen(scene);
+ }
+ else
+ {
+ if (race_manager->raceWasStartedFromOverworld())
+ {
+ OverWorld::enterOverWorld();
+ }
+ else
+ {
+ StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
+ // we assume the main menu was pushed before showing this menu
+ //StateManager::get()->popMenu();
+ }
+ }
}
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "gplose")
View
@@ -794,6 +794,11 @@ void World::updateWorld(float dt)
return;
update(dt);
+
+#ifdef DEBUG
+ assert(m_magic_number == 0xB01D6543);
+#endif
+
if( (!isFinishPhase()) && isRaceOver())
{
enterRaceOverState();
@@ -117,6 +117,8 @@ void GrandPrixLose::onCutsceneEnd()
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
if (unlocked.size() > 0)
{
+ race_manager->exitRace();
+
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
@@ -114,43 +114,6 @@ void GrandPrixWin::onCutsceneEnd()
m_podium_steps[0] = NULL;
m_podium_steps[1] = NULL;
m_podium_steps[2] = NULL;
-
-
-
- // un-set the GP mode so that after unlocking, it doesn't try to continue the GP
- race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
-
- if (PlayerManager::getCurrentPlayer()
- ->getRecentlyCompletedChallenges().size() > 0)
- {
- std::vector<const ChallengeData*> unlocked =
- PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
- PlayerManager::getCurrentPlayer()->clearUnlocked();
-
- StateManager::get()->enterGameState();
- race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
- race_manager->setNumKarts(0);
- race_manager->setNumPlayers(0);
- race_manager->setNumLocalPlayers(0);
- race_manager->startSingleRace("featunlocked", 999, false);
-
- FeatureUnlockedCutScene* scene =
- FeatureUnlockedCutScene::getInstance();
- std::vector<std::string> parts;
- parts.push_back("featunlocked");
- ((CutsceneWorld*)World::getWorld())->setParts(parts);
-
- assert(unlocked.size() > 0);
- scene->addTrophy(race_manager->getDifficulty());
- scene->findWhatWasUnlocked(race_manager->getDifficulty());
-
- StateManager::get()->replaceTopMostScreen(scene);
- }
- else
- {
- // we assume the main menu was pushed before showing this menu
- StateManager::get()->popMenu();
- }
}
// -------------------------------------------------------------------------------------

0 comments on commit e5532c3

Please sign in to comment.