From fd053ced672252dc1619b314714b1700d43150a1 Mon Sep 17 00:00:00 2001 From: coz Date: Sun, 10 Jun 2007 01:13:39 +0000 Subject: [PATCH] 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 --- src/game_manager.cpp | 2 +- src/gui/base_gui.cpp | 9 +++++++-- src/gui/race_gui.cpp | 2 +- src/gui/race_menu.cpp | 10 ++++++---- src/gui/race_results_gui.cpp | 10 +++++----- src/world.cpp | 18 +++++++++++++++--- src/world.hpp | 3 +++ 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/game_manager.cpp b/src/game_manager.cpp index f0522b3ac..bb168ad9c 100644 --- a/src/game_manager.cpp +++ b/src/game_manager.cpp @@ -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); diff --git a/src/gui/base_gui.cpp b/src/gui/base_gui.cpp index 380ad5018..c884c9cce 100644 --- a/src/gui/base_gui.cpp +++ b/src/gui/base_gui.cpp @@ -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(); } diff --git a/src/gui/race_gui.cpp b/src/gui/race_gui.cpp index c4be48b76..5afb32acd 100644 --- a/src/gui/race_gui.cpp +++ b/src/gui/race_gui.cpp @@ -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: diff --git a/src/gui/race_menu.cpp b/src/gui/race_menu.cpp index 78a3f42e7..17d3d9a2e 100644 --- a/src/gui/race_menu.cpp +++ b/src/gui/race_menu.cpp @@ -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; diff --git a/src/gui/race_results_gui.cpp b/src/gui/race_results_gui.cpp index abcb22a7a..848f95183 100644 --- a/src/gui/race_results_gui.cpp +++ b/src/gui/race_results_gui.cpp @@ -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 diff --git a/src/world.cpp b/src/world.cpp index 2fb6acd19..21cf692b8 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -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 */ diff --git a/src/world.hpp b/src/world.hpp index a89158126..0df39ba92 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -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;