X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fscreen_manager.cpp;h=decc603e39b7a810acdb1e0d35b8f04752503566;hb=4344af0025fd9b399666864e4cb96b3f81fd50bc;hp=f680e7a7b3fc13434137c59d24268296d3134b29;hpb=be53843f506b5f2b1990452b07122e3775a54cde;p=supertux.git diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index f680e7a7b..decc603e3 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -21,11 +21,13 @@ #include "control/input_manager.hpp" #include "gui/menu.hpp" #include "gui/menu_manager.hpp" +#include "scripting/scripting.hpp" #include "scripting/squirrel_util.hpp" #include "scripting/time_scheduler.hpp" #include "supertux/console.hpp" #include "supertux/constants.hpp" #include "supertux/gameconfig.hpp" +#include "supertux/game_session.hpp" #include "supertux/globals.hpp" #include "supertux/main.hpp" #include "supertux/menu/menu_storage.hpp" @@ -127,7 +129,6 @@ ScreenManager::draw(DrawingContext& context) assert(!m_screen_stack.empty()); static Uint32 fps_ticks = SDL_GetTicks(); - static int frame_count = 0; m_screen_stack.back()->draw(context); m_menu_manager->draw(context); @@ -155,6 +156,7 @@ ScreenManager::draw(DrawingContext& context) /* Calculate frames per second */ if (g_config->show_fps) { + static int frame_count = 0; ++frame_count; if (SDL_GetTicks() - fps_ticks >= 500) @@ -169,7 +171,7 @@ ScreenManager::draw(DrawingContext& context) void ScreenManager::update_gamelogic(float elapsed_time) { - scripting::update_debugger(); + scripting::Scripting::current()->update_debugger(); scripting::TimeScheduler::instance->update(game_time); if (!m_screen_stack.empty()) @@ -190,11 +192,11 @@ ScreenManager::update_gamelogic(float elapsed_time) void ScreenManager::process_events() { - g_input_manager->update(); + InputManager::current()->update(); SDL_Event event; while (SDL_PollEvent(&event)) { - g_input_manager->process_event(event); + InputManager::current()->process_event(event); m_menu_manager->event(event); @@ -208,10 +210,16 @@ ScreenManager::process_events() switch(event.window.event) { case SDL_WINDOWEVENT_RESIZED: - VideoSystem::current()->get_renderer().resize(event.window.data1, - event.window.data2); + VideoSystem::current()->resize(event.window.data1, + event.window.data2); m_menu_manager->on_window_resize(); break; + + case SDL_WINDOWEVENT_FOCUS_LOST: + if(GameSession::current() != NULL) { + GameSession::current()->toggle_pause(); + } + break; } break; @@ -223,7 +231,7 @@ ScreenManager::process_events() else if (event.key.keysym.sym == SDLK_F11) { g_config->use_fullscreen = !g_config->use_fullscreen; - VideoSystem::current()->get_renderer().apply_config(); + VideoSystem::current()->apply_config(); m_menu_manager->on_window_resize(); } else if (event.key.keysym.sym == SDLK_PRINTSCREEN || @@ -238,6 +246,12 @@ ScreenManager::process_events() g_config->console_enabled = true; g_config->save(); } + else if (event.key.keysym.sym == SDLK_F2 && + event.key.keysym.mod & KMOD_CTRL) + { + g_config->developer_mode = !g_config->developer_mode; + log_info << "developer mode: " << g_config->developer_mode << std::endl; + } break; } } @@ -365,7 +379,7 @@ ScreenManager::run(DrawingContext &context) draw(context); } - sound_manager->update(); + SoundManager::current()->update(); handle_screen_switch(); }