From 957fc9281bd0ef5772d1dfec33152b1e2a6ea06e Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 6 Dec 2009 02:19:37 +0000 Subject: [PATCH] A menu that uses animations can now choose not to throttle FPS to 35. This means credits and feature unlocked are now smoother git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4251 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/screen.cpp | 2 ++ src/guiengine/screen.hpp | 2 ++ src/main_loop.cpp | 2 +- src/states_screens/credits.cpp | 2 ++ src/states_screens/feature_unlocked.cpp | 1 + src/states_screens/state_manager.cpp | 7 +++++++ src/states_screens/state_manager.hpp | 3 +++ 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/guiengine/screen.cpp b/src/guiengine/screen.cpp index 829cf7f1f..47adbf229 100644 --- a/src/guiengine/screen.cpp +++ b/src/guiengine/screen.cpp @@ -42,6 +42,8 @@ using namespace GUIEngine; Screen::Screen(const char* file) { + throttleFPS = true; + m_mouse_x = 0; m_mouse_y = 0; this->m_filename = file; diff --git a/src/guiengine/screen.hpp b/src/guiengine/screen.hpp index 581f77cf4..167485454 100644 --- a/src/guiengine/screen.hpp +++ b/src/guiengine/screen.hpp @@ -93,6 +93,8 @@ namespace GUIEngine bool m_render_3d; public: + bool throttleFPS; + ptr_vector m_widgets; // current mouse position, read-only... diff --git a/src/main_loop.cpp b/src/main_loop.cpp index caf4aa1e5..436a2d130 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -78,7 +78,7 @@ float MainLoop::getLimitedDt() // Throttle fps if more than maximum, which can reduce // the noise the fan on a graphics card makes. // When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus - const int max_fps = (StateManager::get()->getGameState() == GUIEngine::GAME ? UserConfigParams::m_max_fps : 35); + const int max_fps = (StateManager::get()->throttleFPS() ? 35 : UserConfigParams::m_max_fps); const int current_fps = (int)(1000.0f/dt); if( current_fps > max_fps ) { diff --git a/src/states_screens/credits.cpp b/src/states_screens/credits.cpp index b4dba7055..752e9c86a 100644 --- a/src/states_screens/credits.cpp +++ b/src/states_screens/credits.cpp @@ -77,6 +77,8 @@ namespace GUIEngine { reset(); + throttleFPS = false; + std::string creditsfile = file_manager->getDataDir() + "/CREDITS"; std::ifstream file( creditsfile.c_str() ) ; diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp index cf2b25750..2ffa048c2 100644 --- a/src/states_screens/feature_unlocked.cpp +++ b/src/states_screens/feature_unlocked.cpp @@ -18,6 +18,7 @@ FeatureUnlockedCutScene::FeatureUnlockedCutScene() : Screen("feature_unlocked.st { setNeeds3D(true); + throttleFPS = false; m_unlocked_kart = NULL; m_unlocked_thing_picture = NULL; } diff --git a/src/states_screens/state_manager.cpp b/src/states_screens/state_manager.cpp index 8cc7de0eb..859a99b40 100644 --- a/src/states_screens/state_manager.cpp +++ b/src/states_screens/state_manager.cpp @@ -18,7 +18,9 @@ #include "states_screens/state_manager.hpp" +#include "guiengine/engine.hpp" #include "guiengine/modaldialog.hpp" +#include "guiengine/screen.hpp" #include "input/input_manager.hpp" #include "states_screens/dialogs/race_paused_dialog.hpp" #include "utils/translation.hpp" @@ -100,6 +102,11 @@ void StateManager::resetActivePlayers() m_active_players.clearWithoutDeleting(); } +bool StateManager::throttleFPS() +{ + return m_game_mode != GUIEngine::GAME && GUIEngine::getCurrentScreen()->throttleFPS; +} + void StateManager::escapePressed() { // in input sensing mode diff --git a/src/states_screens/state_manager.hpp b/src/states_screens/state_manager.hpp index 21f12bf05..9f5655995 100644 --- a/src/states_screens/state_manager.hpp +++ b/src/states_screens/state_manager.hpp @@ -44,6 +44,7 @@ class StateManager : public GUIEngine::AbstractStateManager void updateActivePlayerIDs(); + public: ptr_vector& getActivePlayers(); ActivePlayer* getActivePlayer(const int id); @@ -59,6 +60,8 @@ public: int activePlayerCount(); void resetActivePlayers(); + bool throttleFPS(); + void escapePressed(); //void eventCallback(GUIEngine::Widget* widget, const std::string& name);