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:
coz 2007-06-10 01:13:39 +00:00
parent dafb628e2d
commit fd053ced67
7 changed files with 38 additions and 16 deletions

View File

@ -78,7 +78,7 @@ void GameManager::run()
if (race_manager->raceIsActive()) if (race_manager->raceIsActive())
{ {
scene->draw(); scene->draw();
if ( ! widgetSet -> get_paused ()) if ( world->getPhase() != World::LIMBO_PHASE)
{ {
world->update((m_curr_time - m_prev_time ) * 0.001); world->update((m_curr_time - m_prev_time ) * 0.001);

View File

@ -21,6 +21,7 @@
#include "base_gui.hpp" #include "base_gui.hpp"
#include "widget_set.hpp" #include "widget_set.hpp"
#include "world.hpp"
#include "menu_manager.hpp" #include "menu_manager.hpp"
void BaseGUI::input(InputType type, int id0, int id1, int id2, int value) 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->getMenuStackSize() > 1)
{ {
if(menu_manager->isCurrentMenu(MENUID_RACEMENU)) if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
widgetSet->tgl_paused(); {
world->unpause();
}
menu_manager->popMenu(); 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->getMenuStackSize() > 1)
{ {
if(menu_manager->isCurrentMenu(MENUID_RACEMENU)) if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
widgetSet->tgl_paused(); {
world->unpause();
}
menu_manager->popMenu(); menu_manager->popMenu();
} }

View File

@ -202,7 +202,7 @@ void RaceGUI::inputKeyboard(int key, int pressed)
// Fall through to put the game into pause mode. // Fall through to put the game into pause mode.
#endif #endif
case SDLK_ESCAPE: // ESC case SDLK_ESCAPE: // ESC
widgetSet->tgl_paused(); world->pause();
menu_manager->pushMenu(MENUID_RACEMENU); menu_manager->pushMenu(MENUID_RACEMENU);
break; break;
case SDLK_F10: case SDLK_F10:

View File

@ -26,6 +26,7 @@
#include "menu_manager.hpp" #include "menu_manager.hpp"
#include "race_manager.hpp" #include "race_manager.hpp"
#include "sound_manager.hpp"
#include "translation.hpp" #include "translation.hpp"
enum WidgetTokens { enum WidgetTokens {
@ -72,7 +73,6 @@ RaceMenu::~RaceMenu()
void RaceMenu::update(float dt) void RaceMenu::update(float dt)
{ {
widgetSet -> timer(m_menu_id, dt) ; widgetSet -> timer(m_menu_id, dt) ;
// widgetSet -> blank();
widgetSet -> paint(m_menu_id) ; widgetSet -> paint(m_menu_id) ;
} }
@ -80,21 +80,22 @@ void RaceMenu::update(float dt)
void RaceMenu::select() void RaceMenu::select()
{ {
int clicked_token = widgetSet->get_token(widgetSet->click()); int clicked_token = widgetSet->get_token(widgetSet->click());
if(clicked_token != WTOK_OPTIONS && clicked_token != WTOK_HELP)
widgetSet -> tgl_paused();
switch (clicked_token) switch (clicked_token)
{ {
case WTOK_RETURN_RACE: case WTOK_RETURN_RACE:
world->unpause();
menu_manager->popMenu(); menu_manager->popMenu();
break; break;
case WTOK_SETUP_NEW_RACE: case WTOK_SETUP_NEW_RACE:
world->unpause();
race_manager->exit_race(); race_manager->exit_race();
menu_manager->pushMenu(MENUID_DIFFICULTY); menu_manager->pushMenu(MENUID_DIFFICULTY);
break; break;
case WTOK_RESTART_RACE: case WTOK_RESTART_RACE:
world->unpause();
menu_manager->popMenu(); menu_manager->popMenu();
world->restartRace(); world->restartRace();
break; break;
@ -108,6 +109,7 @@ void RaceMenu::select()
break; break;
case WTOK_EXIT_RACE: case WTOK_EXIT_RACE:
world->unpause();
race_manager->exit_race(); race_manager->exit_race();
break; break;
@ -124,7 +126,7 @@ void RaceMenu::inputKeyboard(int key, int pressed)
case SDLK_ESCAPE: //ESC case SDLK_ESCAPE: //ESC
if(!pressed) if(!pressed)
break; break;
widgetSet -> tgl_paused(); world->unpause();
menu_manager->popMenu(); menu_manager->popMenu();
break; break;

View File

@ -154,18 +154,18 @@ void RaceResultsGUI::select()
switch( widgetSet->get_token( widgetSet->click() ) ) switch( widgetSet->get_token( widgetSet->click() ) )
{ {
case WTOK_CONTINUE: case WTOK_CONTINUE:
widgetSet->tgl_paused(); world->unpause();
race_manager->next(); race_manager->next();
break; break;
case WTOK_RESTART_RACE: case WTOK_RESTART_RACE:
widgetSet->tgl_paused(); world->unpause();
menu_manager->popMenu(); menu_manager->popMenu();
// TODO: Maybe let this go through the race_manager for // TODO: Maybe let this go through the race_manager for
// more flexibility. // more flexibility.
world->restartRace(); world->restartRace();
break; break;
case WTOK_SETUP_NEW_RACE: case WTOK_SETUP_NEW_RACE:
widgetSet->tgl_paused(); world->unpause();
race_manager->exit_race(); race_manager->exit_race();
menu_manager->pushMenu(MENUID_DIFFICULTY); menu_manager->pushMenu(MENUID_DIFFICULTY);
break; 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 { // Usually here would be code to close this gui. Not only
// that doesn't has any real function in this gui, // that doesn't has any real function in this gui,
// but also closing this gui causes bug #9157. // but also closing this gui causes bug #9157.
widgetSet->tgl_paused(); world->unpause();
race_manager->next(); race_manager->next();
} }
else else
@ -208,7 +208,7 @@ void RaceResultsGUI::inputKeyboard(int key, int pressed)
{ // Usually here would be code to close this gui. Not only { // Usually here would be code to close this gui. Not only
// that doesn't has any real function in this gui, // that doesn't has any real function in this gui,
// but also causes bug #9157. // but also causes bug #9157.
widgetSet->tgl_paused(); world->unpause();
race_manager->next(); race_manager->next();
} // sif SDLK_ESCAPE } // sif SDLK_ESCAPE
} // inputKeyboard } // inputKeyboard

View File

@ -310,10 +310,8 @@ void World::update(float delta)
} }
} }
delete []index; delete []index;
widgetSet->tgl_paused(); pause();
menu_manager->pushMenu(MENUID_RACERESULT); menu_manager->pushMenu(MENUID_RACERESULT);
m_phase = LIMBO_PHASE;
} }
float inc = 0.05f; float inc = 0.05f;
@ -754,4 +752,18 @@ Kart* World::loadRobot(const KartProperties *kart_properties, int position,
return currentRobot; return currentRobot;
} }
//-----------------------------------------------------------------------------
void World::pause()
{
sound_manager -> pauseMusic() ;
m_phase = LIMBO_PHASE;
}
//-----------------------------------------------------------------------------
void World::unpause()
{
sound_manager -> resumeMusic() ;
m_phase = RACE_PHASE;
}
/* EOF */ /* EOF */

View File

@ -104,6 +104,9 @@ public:
float getFastestLapTime() const { return m_fastest_lap; } float getFastestLapTime() const { return m_fastest_lap; }
void setFastestLap(Kart *k, float time) {m_fastest_kart=k;m_fastest_lap=time;} void setFastestLap(Kart *k, float time) {m_fastest_kart=k;m_fastest_lap=time;}
const Highscores* getHighscores() const { return m_highscores; } const Highscores* getHighscores() const { return m_highscores; }
void pause();
void unpause();
private: private:
Karts m_kart; Karts m_kart;
StaticSSG* m_static_ssg; StaticSSG* m_static_ssg;