Moved the pause code from being dependant on the widgetSet to being dependant from world.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1146 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
dafb628e2d
commit
fd053ced67
@ -78,7 +78,7 @@ void GameManager::run()
|
||||
if (race_manager->raceIsActive())
|
||||
{
|
||||
scene->draw();
|
||||
if ( ! widgetSet -> get_paused ())
|
||||
if ( world->getPhase() != World::LIMBO_PHASE)
|
||||
{
|
||||
world->update((m_curr_time - m_prev_time ) * 0.001);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "base_gui.hpp"
|
||||
#include "widget_set.hpp"
|
||||
#include "world.hpp"
|
||||
#include "menu_manager.hpp"
|
||||
|
||||
void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
|
||||
@ -53,7 +54,9 @@ void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
|
||||
if (menu_manager->getMenuStackSize() > 1)
|
||||
{
|
||||
if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
|
||||
widgetSet->tgl_paused();
|
||||
{
|
||||
world->unpause();
|
||||
}
|
||||
|
||||
menu_manager->popMenu();
|
||||
}
|
||||
@ -76,7 +79,9 @@ void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
|
||||
if (menu_manager->getMenuStackSize() > 1)
|
||||
{
|
||||
if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
|
||||
widgetSet->tgl_paused();
|
||||
{
|
||||
world->unpause();
|
||||
}
|
||||
|
||||
menu_manager->popMenu();
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void RaceGUI::inputKeyboard(int key, int pressed)
|
||||
// Fall through to put the game into pause mode.
|
||||
#endif
|
||||
case SDLK_ESCAPE: // ESC
|
||||
widgetSet->tgl_paused();
|
||||
world->pause();
|
||||
menu_manager->pushMenu(MENUID_RACEMENU);
|
||||
break;
|
||||
case SDLK_F10:
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "menu_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
|
||||
enum WidgetTokens {
|
||||
@ -72,7 +73,6 @@ RaceMenu::~RaceMenu()
|
||||
void RaceMenu::update(float dt)
|
||||
{
|
||||
widgetSet -> timer(m_menu_id, dt) ;
|
||||
// widgetSet -> blank();
|
||||
widgetSet -> paint(m_menu_id) ;
|
||||
}
|
||||
|
||||
@ -80,21 +80,22 @@ void RaceMenu::update(float dt)
|
||||
void RaceMenu::select()
|
||||
{
|
||||
int clicked_token = widgetSet->get_token(widgetSet->click());
|
||||
if(clicked_token != WTOK_OPTIONS && clicked_token != WTOK_HELP)
|
||||
widgetSet -> tgl_paused();
|
||||
|
||||
switch (clicked_token)
|
||||
{
|
||||
case WTOK_RETURN_RACE:
|
||||
world->unpause();
|
||||
menu_manager->popMenu();
|
||||
break;
|
||||
|
||||
case WTOK_SETUP_NEW_RACE:
|
||||
world->unpause();
|
||||
race_manager->exit_race();
|
||||
menu_manager->pushMenu(MENUID_DIFFICULTY);
|
||||
break;
|
||||
|
||||
case WTOK_RESTART_RACE:
|
||||
world->unpause();
|
||||
menu_manager->popMenu();
|
||||
world->restartRace();
|
||||
break;
|
||||
@ -108,6 +109,7 @@ void RaceMenu::select()
|
||||
break;
|
||||
|
||||
case WTOK_EXIT_RACE:
|
||||
world->unpause();
|
||||
race_manager->exit_race();
|
||||
break;
|
||||
|
||||
@ -124,7 +126,7 @@ void RaceMenu::inputKeyboard(int key, int pressed)
|
||||
case SDLK_ESCAPE: //ESC
|
||||
if(!pressed)
|
||||
break;
|
||||
widgetSet -> tgl_paused();
|
||||
world->unpause();
|
||||
menu_manager->popMenu();
|
||||
break;
|
||||
|
||||
|
@ -154,18 +154,18 @@ void RaceResultsGUI::select()
|
||||
switch( widgetSet->get_token( widgetSet->click() ) )
|
||||
{
|
||||
case WTOK_CONTINUE:
|
||||
widgetSet->tgl_paused();
|
||||
world->unpause();
|
||||
race_manager->next();
|
||||
break;
|
||||
case WTOK_RESTART_RACE:
|
||||
widgetSet->tgl_paused();
|
||||
world->unpause();
|
||||
menu_manager->popMenu();
|
||||
// TODO: Maybe let this go through the race_manager for
|
||||
// more flexibility.
|
||||
world->restartRace();
|
||||
break;
|
||||
case WTOK_SETUP_NEW_RACE:
|
||||
widgetSet->tgl_paused();
|
||||
world->unpause();
|
||||
race_manager->exit_race();
|
||||
menu_manager->pushMenu(MENUID_DIFFICULTY);
|
||||
break;
|
||||
@ -184,7 +184,7 @@ void RaceResultsGUI::input(InputType type, int id0, int id1, int id2, int value
|
||||
{ // Usually here would be code to close this gui. Not only
|
||||
// that doesn't has any real function in this gui,
|
||||
// but also closing this gui causes bug #9157.
|
||||
widgetSet->tgl_paused();
|
||||
world->unpause();
|
||||
race_manager->next();
|
||||
}
|
||||
else
|
||||
@ -208,7 +208,7 @@ void RaceResultsGUI::inputKeyboard(int key, int pressed)
|
||||
{ // Usually here would be code to close this gui. Not only
|
||||
// that doesn't has any real function in this gui,
|
||||
// but also causes bug #9157.
|
||||
widgetSet->tgl_paused();
|
||||
world->unpause();
|
||||
race_manager->next();
|
||||
} // sif SDLK_ESCAPE
|
||||
} // inputKeyboard
|
||||
|
@ -310,10 +310,8 @@ void World::update(float delta)
|
||||
}
|
||||
}
|
||||
delete []index;
|
||||
widgetSet->tgl_paused();
|
||||
pause();
|
||||
menu_manager->pushMenu(MENUID_RACERESULT);
|
||||
|
||||
m_phase = LIMBO_PHASE;
|
||||
}
|
||||
|
||||
float inc = 0.05f;
|
||||
@ -754,4 +752,18 @@ Kart* World::loadRobot(const KartProperties *kart_properties, int position,
|
||||
return currentRobot;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void World::pause()
|
||||
{
|
||||
sound_manager -> pauseMusic() ;
|
||||
m_phase = LIMBO_PHASE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void World::unpause()
|
||||
{
|
||||
sound_manager -> resumeMusic() ;
|
||||
m_phase = RACE_PHASE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@ -104,6 +104,9 @@ public:
|
||||
float getFastestLapTime() const { return m_fastest_lap; }
|
||||
void setFastestLap(Kart *k, float time) {m_fastest_kart=k;m_fastest_lap=time;}
|
||||
const Highscores* getHighscores() const { return m_highscores; }
|
||||
|
||||
void pause();
|
||||
void unpause();
|
||||
private:
|
||||
Karts m_kart;
|
||||
StaticSSG* m_static_ssg;
|
||||
|
Loading…
Reference in New Issue
Block a user