enable window resizing (tested only on linux) - fix issue 103
authorkoda
Tue, 23 Aug 2011 12:53:47 +0200
changeset 5670 e01f0b6f1969
parent 5668 36c1d1b789b8
child 5672 34bb680476d4
enable window resizing (tested only on linux) - fix issue #103
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uStore.pas
--- a/hedgewars/SDLh.pas	Tue Aug 23 10:19:33 2011 +0200
+++ b/hedgewars/SDLh.pas	Tue Aug 23 12:53:47 2011 +0200
@@ -211,7 +211,7 @@
     SDL_JOYBUTTONDOWN   = 10;
     SDL_JOYBUTTONUP     = 11;
     SDL_QUITEV          = 12;
-    SDL_VIDEORESIZE     = 16; // TODO: outdated? no longer in SDL 1.3?
+    SDL_VIDEORESIZE     = 16;
 
     // SDL_Surface flags
     SDL_SWSURFACE   = $00000000;
@@ -608,7 +608,7 @@
             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
             SDL_QUITEV: (quit: TSDL_QuitEvent);
             //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
-            //SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
+            SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
 {$ENDIF}
         end;
 
--- a/hedgewars/hwengine.pas	Tue Aug 23 10:19:33 2011 +0200
+++ b/hedgewars/hwengine.pas	Tue Aug 23 12:53:47 2011 +0200
@@ -175,6 +175,15 @@
                         if prevFocusState xor cHasFocus then
                             onFocusStateChanged()
                         end;
+                SDL_VIDEORESIZE: begin
+                    // using lower values causes widget overlap and video issues
+                    if event.resize.w > 768 then cScreenWidth:= event.resize.w
+                    else cScreenWidth:= 768;
+                    if event.resize.h > 576 then cScreenHeight:= event.resize.h
+                    else cScreenHeight:= 576;
+                    ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true);
+                    WriteLnToConsole('window resize');
+                    end;
 {$ENDIF}
                 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
                 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
--- a/hedgewars/uStore.pas	Tue Aug 23 10:19:33 2011 +0200
+++ b/hedgewars/uStore.pas	Tue Aug 23 12:53:47 2011 +0200
@@ -1009,7 +1009,7 @@
     SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
     SDLTry(SDLwindow <> nil, true);
 {$ELSE}
-    flags:= SDL_OPENGL;// or SDL_RESIZABLE;
+    flags:= SDL_OPENGL or SDL_RESIZABLE;
     if cFullScreen then
         flags:= flags or SDL_FULLSCREEN;