Fixed what happens when pressing escape on feature unlocked screen

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4894 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-03-01 23:40:20 +00:00
parent 2efb0ceb10
commit 90b95f6944
4 changed files with 39 additions and 34 deletions

View File

@ -149,6 +149,10 @@ namespace GUIEngine
virtual void init() = 0;
virtual void tearDown() = 0;
/** Called when escape is pressed.
* @return true if the screen should be closed, false if you handled the press another way */
virtual bool onEscapePressed() { return true; }
/**
* will be called everytime sometimes happens.
* Events are generally a widget state change. In this case, a pointer to the said widget is passed along its

View File

@ -251,6 +251,33 @@ void FeatureUnlockedCutScene::onUpdate(float dt, irr::video::IVideoDriver* drive
// -------------------------------------------------------------------------------------
bool FeatureUnlockedCutScene::onEscapePressed()
{
continueButtonPressed();
return false; // continueButtonPressed already pop'ed the menu
}
// -------------------------------------------------------------------------------------
void FeatureUnlockedCutScene::continueButtonPressed()
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// in GP mode, continue GP after viewing this screen (TODO: test)
StateManager::get()->popMenu();
race_manager->next();
}
else
{
// back to menu
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
}
// -------------------------------------------------------------------------------------
void FeatureUnlockedCutScene::eventCallback(GUIEngine::Widget* widget,
const std::string& name,
const int playerID)
@ -258,41 +285,9 @@ void FeatureUnlockedCutScene::eventCallback(GUIEngine::Widget* widget,
if (name == "continue")
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// in GP mode, continue GP after viewing this screen (TODO: test)
StateManager::get()->popMenu();
race_manager->next();
}
else
{
// back to menu
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
continueButtonPressed();
}
/*
if (eventSource == "raceagainbtn")
{
network_manager->setState(NetworkManager::NS_MAIN_MENU);
World::getWorld()->unpause();
race_manager->rerunRace();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "backtomenu")
{
World::getWorld()->unpause();
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "continuegp")
{
World::getWorld()->unpause();
race_manager->next();
return GUIEngine::EVENT_BLOCK;
}*/
}
// -------------------------------------------------------------------------------------

View File

@ -38,6 +38,9 @@ class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::Scre
//irr::scene::ISceneNode* m_chest_top;
//irr::scene::ISceneNode* m_key;
irr::scene::ILightSceneNode* m_light;
void continueButtonPressed();
public:
void onUpdate(float dt, irr::video::IVideoDriver*);
@ -52,6 +55,9 @@ public:
/** Call before showing up the screen to make a picture come out of the chest */
void setUnlockedPicture(irr::video::ITexture* picture);
/** override from base class to handle escape press */
virtual bool onEscapePressed();
};
#endif

View File

@ -166,7 +166,7 @@ void StateManager::escapePressed()
// In menus
else
{
popMenu();
if (getCurrentScreen()->onEscapePressed()) popMenu();
}
}