pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3183 - in trunk/pingus/src: . gui input


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3183 - in trunk/pingus/src: . gui input
Date: Tue, 18 Sep 2007 23:16:18 +0200

Author: grumbel
Date: 2007-09-18 23:16:17 +0200 (Tue, 18 Sep 2007)
New Revision: 3183

Modified:
   trunk/pingus/src/globals.cpp
   trunk/pingus/src/globals.hpp
   trunk/pingus/src/gui/display.cpp
   trunk/pingus/src/gui/screen_manager.cpp
   trunk/pingus/src/gui/screen_manager.hpp
   trunk/pingus/src/input/sdl_driver.cpp
   trunk/pingus/src/pingus_main.cpp
Log:
- added window resize (just some function, doesn't to anything with the game 
yet)

Modified: trunk/pingus/src/globals.cpp
===================================================================
--- trunk/pingus/src/globals.cpp        2007-09-18 18:16:45 UTC (rev 3182)
+++ trunk/pingus/src/globals.cpp        2007-09-18 21:16:17 UTC (rev 3183)
@@ -58,6 +58,8 @@
 
 bool        fullscreen_enabled              = false;
 
+bool        resize_enabled                  = false;
+
 #if defined(WIN32) || defined(__APPLE__)
 // The clanSDL target is a little buggy on Windows and OSX - Use OpenGL by 
default
 bool        use_opengl                      = true;

Modified: trunk/pingus/src/globals.hpp
===================================================================
--- trunk/pingus/src/globals.hpp        2007-09-18 18:16:45 UTC (rev 3182)
+++ trunk/pingus/src/globals.hpp        2007-09-18 21:16:17 UTC (rev 3183)
@@ -46,6 +46,7 @@
 extern bool        drag_drop_scrolling; 
 extern int         tile_size;                       ///< --tile-size
 extern bool        fullscreen_enabled;              ///< --enable-fullscreen
+extern bool        resize_enabled;                  ///< --resize-fullscreen
 extern int         screen_width;                    ///<
 extern int         screen_height;                   ///<
 extern bool        draw_collision_map;              ///<

Modified: trunk/pingus/src/gui/display.cpp
===================================================================
--- trunk/pingus/src/gui/display.cpp    2007-09-18 18:16:45 UTC (rev 3182)
+++ trunk/pingus/src/gui/display.cpp    2007-09-18 21:16:17 UTC (rev 3183)
@@ -91,16 +91,21 @@
 void
 Display::set_video_mode(int width, int height)
 {
+  Uint32 flags = 0;
+  
+  if (resize_enabled)
+    flags |= SDL_RESIZABLE;
+
   if (fullscreen_enabled)
+    flags |= SDL_FULLSCREEN;
+
+  screen = SDL_SetVideoMode(width, height, 0, flags);
+
+  if (screen == NULL) 
     {
-      screen = SDL_SetVideoMode(width, height, 0, SDL_FULLSCREEN);
-    } else {
-    screen = SDL_SetVideoMode(width, height, 0, SDL_DOUBLEBUF);
-  }
-  if (screen == NULL) {
-    printf("Unable to set video mode: %s\n", SDL_GetError());
-    exit(1);
-  }
+      std::cout << "Unable to set video mode: " << SDL_GetError() << std::endl;
+      exit(1);
+    }
 }
 
 int

Modified: trunk/pingus/src/gui/screen_manager.cpp
===================================================================
--- trunk/pingus/src/gui/screen_manager.cpp     2007-09-18 18:16:45 UTC (rev 
3182)
+++ trunk/pingus/src/gui/screen_manager.cpp     2007-09-18 21:16:17 UTC (rev 
3183)
@@ -20,6 +20,7 @@
 #include "SDL.h"
 #include <iostream>
 #include "../globals.hpp"
+#include "math/size.hpp"
 #include "cursor.hpp"
 #include "display.hpp"
 #include "screen_manager.hpp"
@@ -287,6 +288,12 @@
 }
 
 void
+ScreenManager::resize(const Size& size)
+{
+  std::cout << "Resize: " << size.width << "x" << size.height << std::endl;
+}
+
+void
 ScreenManager::init()
 {
   instance_ = 0;
@@ -299,5 +306,4 @@
   instance_ = 0;
 }
 
-
 /* EOF */

Modified: trunk/pingus/src/gui/screen_manager.hpp
===================================================================
--- trunk/pingus/src/gui/screen_manager.hpp     2007-09-18 18:16:45 UTC (rev 
3182)
+++ trunk/pingus/src/gui/screen_manager.hpp     2007-09-18 21:16:17 UTC (rev 
3183)
@@ -25,7 +25,7 @@
 
 #include "screen_ptr.hpp"
 
-
+class Size;
 class DrawingContext;
 class Screen;
 
@@ -53,6 +53,8 @@
 public:
   ~ScreenManager();
 
+  void resize(const Size& size);
+
   /** Start the screen manager and let it take control, this will
       not return until the somebody signals a quit() */
   void display ();
@@ -98,7 +100,6 @@
   ScreenManager& operator= (const ScreenManager&);
 };
 
-
 #endif
 
 /* EOF */

Modified: trunk/pingus/src/input/sdl_driver.cpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.cpp       2007-09-18 18:16:45 UTC (rev 
3182)
+++ trunk/pingus/src/input/sdl_driver.cpp       2007-09-18 21:16:17 UTC (rev 
3183)
@@ -20,6 +20,8 @@
 */
 
 #include "global_event.hpp"
+#include "gui/screen_manager.hpp"
+#include "math/size.hpp"
 #include "file_reader.hpp"
 #include "sdl_driver.hpp"
 
@@ -206,6 +208,9 @@
 void
 SDLDriver::update(float delta)
 {
+  // FIXME: Little hackywacky, better way would be to fetch event
+  // loops somewhere else and only forward the relevant SDL_Events to
+  // the SDLDriver
   SDL_Event event;
   while (SDL_PollEvent(&event))
     {
@@ -244,6 +249,10 @@
               }
             break;
 
+          case SDL_VIDEORESIZE:
+            ScreenManager::instance()->resize(Size(event.resize.w, 
event.resize.h));
+            break;
+
           case SDL_KEYDOWN:
             if (keyboard_binding)
               keyboard_binding->send_char(event.key.keysym.unicode);

Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp    2007-09-18 18:16:45 UTC (rev 3182)
+++ trunk/pingus/src/pingus_main.cpp    2007-09-18 21:16:17 UTC (rev 3183)
@@ -216,6 +216,8 @@
                   _("Start in Window Mode"));
   argp.add_option('f', "fullscreen", "",
                   _("Start in Fullscreen"));
+  argp.add_option('R', "allow-resize", "",
+                  _("Allow Window resize (buggy)"));
   argp.add_option(346, "enable-swcursor", "",
                   _("Enable software cursor"));
   argp.add_option('g', "geometry", "{width}x{height}",  
@@ -392,6 +394,10 @@
         case 'f': // --fullscreen
           fullscreen_enabled = true;
           break;
+
+        case 'R': // --allow-resize
+          resize_enabled = true;
+          break;
           
         case 'w': // --window
           fullscreen_enabled = false;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]