Added PHYSICAL_SCREEN_WIDTH global variable, little ugly, but should do for now,...
authorIngo Ruhnke <grumbel@gmail.com>
Thu, 31 Jul 2014 02:37:42 +0000 (04:37 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Thu, 31 Jul 2014 02:37:42 +0000 (04:37 +0200)
src/gui/menu.cpp
src/gui/mousecursor.cpp
src/supertux/globals.cpp
src/supertux/globals.hpp
src/supertux/main.cpp

index a777972..3ff034b 100644 (file)
@@ -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;
 
index 8bfdfa0..74cc075 100644 (file)
@@ -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 */
index 207c119..6b27112 100644 (file)
@@ -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;
index 8902619..6962ef0 100644 (file)
@@ -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;
 
index d36c823..beb0c0b 100644 (file)
@@ -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