From: Ingo Ruhnke Date: Thu, 19 Nov 2009 17:06:22 +0000 (+0000) Subject: Renamed MainLoop to ScreenManager X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=4368db3bf92809c1b7751bb3ce6efeae15b329c4;p=supertux.git Renamed MainLoop to ScreenManager SVN-Revision: 6051 --- diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 3a7867944..6e48496f2 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -23,7 +23,7 @@ #include "gui/menu_manager.hpp" #include "gui/mousecursor.hpp" #include "supertux/globals.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/resources.hpp" #include "supertux/timer.hpp" #include "util/gettext.hpp" diff --git a/src/object/endsequence_fireworks.cpp b/src/object/endsequence_fireworks.cpp index 4fab4e1e7..2e4f8308a 100644 --- a/src/object/endsequence_fireworks.cpp +++ b/src/object/endsequence_fireworks.cpp @@ -17,7 +17,8 @@ #include "object/endsequence_fireworks.hpp" #include "object/fireworks.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/globals.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" EndSequenceFireworks::EndSequenceFireworks() : @@ -39,7 +40,7 @@ void EndSequenceFireworks::starting() { EndSequence::starting(); - endsequence_timer.start(7.3f * g_main_loop->get_speed()); + endsequence_timer.start(7.3f * g_screen_manager->get_speed()); Sector::current()->add_object(new Fireworks()); } diff --git a/src/object/endsequence_walkleft.cpp b/src/object/endsequence_walkleft.cpp index 809b8ba7c..19e2041d3 100644 --- a/src/object/endsequence_walkleft.cpp +++ b/src/object/endsequence_walkleft.cpp @@ -16,7 +16,8 @@ #include "object/endsequence_walkleft.hpp" #include "object/player.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/globals.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" EndSequenceWalkLeft::EndSequenceWalkLeft() : @@ -40,7 +41,7 @@ EndSequenceWalkLeft::starting() { EndSequence::starting(); last_x_pos = -1; - endsequence_timer.start(7.3f * g_main_loop->get_speed()); + endsequence_timer.start(7.3f * g_screen_manager->get_speed()); } void diff --git a/src/object/endsequence_walkright.cpp b/src/object/endsequence_walkright.cpp index 581297542..1631c166f 100644 --- a/src/object/endsequence_walkright.cpp +++ b/src/object/endsequence_walkright.cpp @@ -16,7 +16,8 @@ #include "object/endsequence_walkright.hpp" #include "object/player.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/globals.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" EndSequenceWalkRight::EndSequenceWalkRight() : @@ -40,7 +41,7 @@ EndSequenceWalkRight::starting() { EndSequence::starting(); last_x_pos = -1; - endsequence_timer.start(7.3f * g_main_loop->get_speed()); + endsequence_timer.start(7.3f * g_screen_manager->get_speed()); } void diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 853f20494..245feac38 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -25,7 +25,7 @@ #include "supertux/game_session.hpp" #include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" #include "supertux/shrinkfade.hpp" #include "supertux/textscroller.hpp" @@ -64,27 +64,27 @@ void wait(HSQUIRRELVM vm, float seconds) void wait_for_screenswitch(HSQUIRRELVM vm) { - g_main_loop->waiting_threads.add(vm); + g_screen_manager->waiting_threads.add(vm); } void exit_screen() { - g_main_loop->exit_screen(); + g_screen_manager->exit_screen(); } void fadeout_screen(float seconds) { - g_main_loop->set_screen_fade(new FadeOut(seconds)); + g_screen_manager->set_screen_fade(new FadeOut(seconds)); } void shrink_screen(float dest_x, float dest_y, float seconds) { - g_main_loop->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds)); + g_screen_manager->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds)); } void abort_screenfade() { - g_main_loop->set_screen_fade(NULL); + g_screen_manager->set_screen_fade(NULL); } std::string translate(const std::string& text) @@ -94,19 +94,19 @@ std::string translate(const std::string& text) void display_text_file(const std::string& filename) { - g_main_loop->push_screen(new TextScroller(filename)); + g_screen_manager->push_screen(new TextScroller(filename)); } void load_worldmap(const std::string& filename) { using namespace WorldMapNS; - g_main_loop->push_screen(new WorldMap(filename)); + g_screen_manager->push_screen(new WorldMap(filename)); } void load_level(const std::string& filename) { - g_main_loop->push_screen(new GameSession(filename)); + g_screen_manager->push_screen(new GameSession(filename)); } static SQInteger squirrel_read_char(SQUserPointer file) @@ -277,7 +277,7 @@ void set_gamma(float gamma) { void quit() { - g_main_loop->quit(); + g_screen_manager->quit(); } int rand() diff --git a/src/supertux/globals.cpp b/src/supertux/globals.cpp index 22a731175..c85a4467a 100644 --- a/src/supertux/globals.cpp +++ b/src/supertux/globals.cpp @@ -24,4 +24,8 @@ tinygettext::DictionaryManager dictionary_manager; int SCREEN_WIDTH; int SCREEN_HEIGHT; +ScreenManager* g_screen_manager = NULL; + +TextureManager* texture_manager = NULL; + /* EOF */ diff --git a/src/supertux/globals.hpp b/src/supertux/globals.hpp index eb9a25266..6fe934f4e 100644 --- a/src/supertux/globals.hpp +++ b/src/supertux/globals.hpp @@ -19,6 +19,10 @@ #include +class JoystickKeyboardController; +class ScreenManager; +class TextureManager; + /** The width of the display (this is a logical value, not the physical value, since aspect_ration and projection_area might shrink or scale things) */ @@ -30,11 +34,14 @@ extern int SCREEN_WIDTH; extern int SCREEN_HEIGHT; // global variables -class JoystickKeyboardController; extern JoystickKeyboardController* g_main_controller; extern SDL_Surface* g_screen; +extern ScreenManager* g_screen_manager; + +extern TextureManager* texture_manager; + #endif /* EOF */ diff --git a/src/supertux/menu/contrib_world_menu.cpp b/src/supertux/menu/contrib_world_menu.cpp index b3e0fe116..f7205f07e 100644 --- a/src/supertux/menu/contrib_world_menu.cpp +++ b/src/supertux/menu/contrib_world_menu.cpp @@ -18,6 +18,7 @@ #include "audio/sound_manager.hpp" #include "gui/menu_item.hpp" +#include "supertux/globals.hpp" #include "supertux/screen_manager.hpp" #include "supertux/title_screen.hpp" #include "supertux/world.hpp" diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index 2b4478ecc..d43ce30e0 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -42,8 +42,6 @@ static const int MAX_FRAME_SKIP = 2; float g_game_speed = 1.0f; -ScreenManager* g_screen_manager = NULL; - ScreenManager::ScreenManager() : waiting_threads(), running(), diff --git a/src/supertux/screen_manager.hpp b/src/supertux/screen_manager.hpp index 09acd6afd..1cb5ffcbd 100644 --- a/src/supertux/screen_manager.hpp +++ b/src/supertux/screen_manager.hpp @@ -76,8 +76,6 @@ private: bool screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */ }; -extern ScreenManager* g_screen_manager; - #endif /* EOF */ diff --git a/src/supertux/world.cpp b/src/supertux/world.cpp index 07de751ba..02ac4a9d0 100644 --- a/src/supertux/world.cpp +++ b/src/supertux/world.cpp @@ -19,6 +19,7 @@ #include "physfs/ifile_stream.hpp" #include "scripting/serialize.hpp" #include "scripting/squirrel_util.hpp" +#include "supertux/globals.hpp" #include "supertux/screen_manager.hpp" #include "supertux/player_status.hpp" #include "supertux/world.hpp" diff --git a/src/video/surface.cpp b/src/video/surface.cpp index 6265a1aeb..b15d80b62 100644 --- a/src/video/surface.cpp +++ b/src/video/surface.cpp @@ -26,7 +26,10 @@ Surface::Surface(const std::string& file) : texture(texture_manager->get(file)), surface_data(), - x(0), y(0), w(0), h(0), + x(0), + y(0), + w(0), + h(0), flipx(false) { texture->ref(); @@ -38,7 +41,10 @@ Surface::Surface(const std::string& file) : Surface::Surface(const std::string& file, int x, int y, int w, int h) : texture(texture_manager->get(file)), surface_data(), - x(x), y(y), w(w), h(h), + x(x), + y(y), + w(w), + h(h), flipx(false) { texture->ref(); @@ -48,8 +54,10 @@ Surface::Surface(const std::string& file, int x, int y, int w, int h) : Surface::Surface(const Surface& other) : texture(other.texture), surface_data(), - x(other.x), y(other.y), - w(other.w), h(other.h), + x(other.x), + y(other.y), + w(other.w), + h(other.h), flipx(false) { texture->ref(); @@ -57,7 +65,7 @@ Surface::Surface(const Surface& other) : } const Surface& -Surface::operator= (const Surface& other) +Surface::operator=(const Surface& other) { other.texture->ref(); texture->unref(); diff --git a/src/video/texture.hpp b/src/video/texture.hpp index 589fd9592..74710bd60 100644 --- a/src/video/texture.hpp +++ b/src/video/texture.hpp @@ -22,6 +22,7 @@ #include #include +#include "supertux/globals.hpp" #include "video/texture_manager.hpp" /// bitset for drawing effects diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index c15d4cf82..ca311ed31 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -25,8 +25,6 @@ #include "video/gl/gl_texture.hpp" #include "video/video_systems.hpp" -TextureManager* texture_manager = NULL; - TextureManager::TextureManager() : image_textures() #ifdef HAVE_OPENGL diff --git a/src/video/texture_manager.hpp b/src/video/texture_manager.hpp index e40479059..496c41543 100644 --- a/src/video/texture_manager.hpp +++ b/src/video/texture_manager.hpp @@ -77,8 +77,6 @@ private: #endif }; -extern TextureManager* texture_manager; - #endif /* EOF */ diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 82e87add7..c61e667c9 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -45,7 +45,7 @@ #include "sprite/sprite_manager.hpp" #include "supertux/game_session.hpp" #include "supertux/globals.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/menu/worldmap_menu.hpp" @@ -294,8 +294,8 @@ WorldMap::move_to_spawnpoint(const std::string& spawnpoint, bool pan) void WorldMap::change(const std::string& filename, const std::string& force_spawnpoint) { - g_main_loop->exit_screen(); - g_main_loop->push_screen(new WorldMap(filename, force_spawnpoint)); + g_screen_manager->exit_screen(); + g_screen_manager->push_screen(new WorldMap(filename, force_spawnpoint)); } void @@ -597,7 +597,7 @@ WorldMap::update(float delta) MenuManager::set_current(0); break; case MNID_QUITWORLDMAP: // Quit Worldmap - g_main_loop->exit_screen(); + g_screen_manager->exit_screen(); break; } } @@ -723,7 +723,7 @@ WorldMap::update(float delta) // update state and savegame save_state(); - g_main_loop->push_screen(new GameSession(levelfile, &level->statistics), + g_screen_manager->push_screen(new GameSession(levelfile, &level->statistics), new ShrinkFade(shrinkpos, 1.0f)); in_level = true; } catch(std::exception& e) {