From: Ingo Ruhnke Date: Thu, 31 Jul 2014 02:37:42 +0000 (+0200) Subject: Added PHYSICAL_SCREEN_WIDTH global variable, little ugly, but should do for now,... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1c68be3f1862c2f8ada0c0b48302771329b64c95;p=supertux.git Added PHYSICAL_SCREEN_WIDTH global variable, little ugly, but should do for now, still needs to be updated properly on window resize --- diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index a777972a4..3ff034bd0 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -770,9 +770,8 @@ Menu::event(const SDL_Event& event) case SDL_MOUSEBUTTONDOWN: if(event.button.button == SDL_BUTTON_LEFT) { -#ifdef OLD_SDL1 - int x = int(event.motion.x * float(SCREEN_WIDTH)/g_screen->w); - int y = int(event.motion.y * float(SCREEN_HEIGHT)/g_screen->h); + int x = int(event.motion.x * float(SCREEN_WIDTH) / PHYSICAL_SCREEN_WIDTH); + int y = int(event.motion.y * float(SCREEN_HEIGHT) / PHYSICAL_SCREEN_WIDTH); if(x > pos.x - get_width()/2 && x < pos.x + get_width()/2 && @@ -781,15 +780,13 @@ Menu::event(const SDL_Event& event) { menuaction = MENU_ACTION_HIT; } -#endif } break; case SDL_MOUSEMOTION: { -#ifdef OLD_SDL1 - float x = event.motion.x * SCREEN_WIDTH/g_screen->w; - float y = event.motion.y * SCREEN_HEIGHT/g_screen->h; + float x = event.motion.x * SCREEN_WIDTH / PHYSICAL_SCREEN_WIDTH; + float y = event.motion.y * SCREEN_HEIGHT / PHYSICAL_SCREEN_HEIGHT; if(x > pos.x - get_width()/2 && x < pos.x + get_width()/2 && @@ -813,7 +810,6 @@ Menu::event(const SDL_Event& event) if(MouseCursor::current()) MouseCursor::current()->set_state(MC_NORMAL); } -#endif } break; diff --git a/src/gui/mousecursor.cpp b/src/gui/mousecursor.cpp index 8bfdfa0bd..74cc075ba 100644 --- a/src/gui/mousecursor.cpp +++ b/src/gui/mousecursor.cpp @@ -57,15 +57,14 @@ void MouseCursor::set_mid(int x, int y) void MouseCursor::draw(DrawingContext& context) { -#ifdef OLD_SDL1 if(cur_state == MC_HIDE) return; int x,y,w,h; Uint8 ispressed = SDL_GetMouseState(&x,&y); - x = int(x * float(SCREEN_WIDTH)/g_screen->w); - y = int(y * float(SCREEN_HEIGHT)/g_screen->h); + x = int(x * float(SCREEN_WIDTH) / PHYSICAL_SCREEN_WIDTH); + y = int(y * float(SCREEN_HEIGHT) / PHYSICAL_SCREEN_HEIGHT); w = (int) cursor->get_width(); h = (int) (cursor->get_height() / MC_STATES_NB); @@ -81,7 +80,6 @@ void MouseCursor::draw(DrawingContext& context) context.draw_surface_part(cursor, Vector(0, h*cur_state), Vector(w, h), Vector(x-mid_x, y-mid_y), LAYER_GUI+100); -#endif } /* EOF */ diff --git a/src/supertux/globals.cpp b/src/supertux/globals.cpp index 207c119d8..6b2711204 100644 --- a/src/supertux/globals.cpp +++ b/src/supertux/globals.cpp @@ -23,6 +23,9 @@ tinygettext::DictionaryManager* dictionary_manager = 0; int SCREEN_WIDTH; int SCREEN_HEIGHT; +int PHYSICAL_SCREEN_WIDTH; +int PHYSICAL_SCREEN_HEIGHT; + ScreenManager* g_screen_manager = 0; TextureManager* texture_manager = 0; diff --git a/src/supertux/globals.hpp b/src/supertux/globals.hpp index 890261947..6962ef0c4 100644 --- a/src/supertux/globals.hpp +++ b/src/supertux/globals.hpp @@ -39,6 +39,9 @@ extern int SCREEN_WIDTH; shrink or scale things) */ extern int SCREEN_HEIGHT; +extern int PHYSICAL_SCREEN_WIDTH; +extern int PHYSICAL_SCREEN_HEIGHT; + // global variables extern JoystickKeyboardController* g_jk_controller; diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index d36c82388..beb0c0b03 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -466,7 +466,10 @@ Main::init_video() // FIXME: Add something here SCREEN_WIDTH = 800; SCREEN_HEIGHT = 600; - + + PHYSICAL_SCREEN_WIDTH = SCREEN_WIDTH; + PHYSICAL_SCREEN_HEIGHT = SCREEN_HEIGHT; + context_pointer->init_renderer(); #ifdef OLD_SDL1