strangely enough, the new sdl rotation code is incompatible with our system... this is a workaround that should hold up until their code becomes more stable
authorkoda
Wed, 06 Apr 2011 00:29:49 +0200
changeset 5109 6d2e8a24277e
parent 5106 517bdd3865f1
child 5111 d8856d98ce7d
strangely enough, the new sdl rotation code is incompatible with our system... this is a workaround that should hold up until their code becomes more stable
hedgewars/hwengine.pas
hedgewars/uStore.pas
project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
--- a/hedgewars/hwengine.pas	Tue Apr 05 22:21:02 2011 +0200
+++ b/hedgewars/hwengine.pas	Wed Apr 06 00:29:49 2011 +0200
@@ -209,11 +209,7 @@
     cFullScreen:= false;
     cTimerInterval:= 8;
     PathPrefix:= 'Data';
-{$IFDEF DEBUGFILE}
-    cShowFPS:= true;
-{$ELSE}
-    cShowFPS:= false;
-{$ENDIF}
+    cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
     val(gameArgs[0], ipcPort);
     val(gameArgs[1], cScreenWidth);
     val(gameArgs[2], cScreenHeight);
--- a/hedgewars/uStore.pas	Tue Apr 05 22:21:02 2011 +0200
+++ b/hedgewars/uStore.pas	Wed Apr 06 00:29:49 2011 +0200
@@ -931,7 +931,7 @@
         x:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}(SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
         y:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}(SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
         SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
-                        {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS {$ENDIF});
+                          {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS {$ENDIF});  // do not set SDL_WINDOW_RESIZABLE on iOS
         SDLrender:= SDL_CreateRenderer(SDLwindow, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
     end;
 
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Tue Apr 05 22:21:02 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Wed Apr 06 00:29:49 2011 +0200
@@ -211,8 +211,12 @@
     print_free_memory();
 }
 
+//TODO: when the SDLUIKitDelegate methods applicationWillResignActive and applicationDidBecomeActive do work
+// you'll be able to remove the methods below and just handle the SDL_WINDOWEVENT_MINIMIZED/SDL_WINDOWEVENT_RESTORED
+// events in the MainLoop
+
 -(void) applicationWillResignActive:(UIApplication *)application {
-    [super applicationWillResignActive: application];
+    //[super applicationWillResignActive:application];
 
     UIDevice* device = [UIDevice currentDevice];
     if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
@@ -236,7 +240,7 @@
 }
 
 -(void) applicationDidBecomeActive:(UIApplication *)application {
-    [super applicationDidBecomeActive:application];
+    //[super applicationDidBecomeActive:application];
 
     UIDevice* device = [UIDevice currentDevice];
     if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Tue Apr 05 22:21:02 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Wed Apr 06 00:29:49 2011 +0200
@@ -53,9 +53,6 @@
     BOOL useClassicMenu;
     NSInteger initialOrientation;
     
-    // the containing window
-    UIWindow *containerWindow;
-    
     // dual head support
     NSInteger initialScreenCount;
     NSInteger a, b;
@@ -68,7 +65,6 @@
 @property (assign) BOOL isNetGame;
 @property (assign) BOOL useClassicMenu;
 @property (assign) NSInteger initialOrientation;
-@property (assign) UIWindow *containerWindow;
 
 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Tue Apr 05 22:21:02 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Wed Apr 06 00:29:49 2011 +0200
@@ -39,10 +39,11 @@
                             [[self.view viewWithTag:GRENADE_TAG] removeFromSuperview];
 
 @implementation OverlayViewController
-@synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation, containerWindow;
+@synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation;
 
 #pragma mark -
 #pragma mark rotation
+
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
     // don't rotate until the game is running for performance and synchronization with the sdlview
     if (isGameRunning() == NO)
@@ -98,17 +99,20 @@
         return;
 
     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
-    
+    UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG];
+
     [UIView beginAnimations:@"rotation" context:NULL];
     [UIView setAnimationDuration:0.7];
     switch (orientation) {
         case UIDeviceOrientationLandscapeLeft:
             self.view.frame = [[UIScreen mainScreen] bounds];
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(a));
             break;
         case UIDeviceOrientationLandscapeRight:
             self.view.frame = [[UIScreen mainScreen] bounds];
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90));
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(b));
             break;
         default:
             // a debug log would spam too much
@@ -151,7 +155,6 @@
         initialScreenCount = 1;
 
     // set initial orientation of the controller orientation
-    if (IS_DUALHEAD()) {
         switch (self.interfaceOrientation) {
             case UIDeviceOrientationLandscapeLeft:
                 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
@@ -168,7 +171,6 @@
                                                  selector:@selector(dualHeadRotation:)
                                                      name:UIDeviceOrientationDidChangeNotification
                                                    object:nil];
-    }
 
     // the timer used to dim the overlay
     dimTimer = [[NSTimer alloc] initWithFireDate:(IS_DUALHEAD()) ? HIDING_TIME_NEVER : [NSDate dateWithTimeIntervalSinceNow:6]
@@ -205,8 +207,6 @@
                                                    object:nil];
     }
     
-    self.containerWindow = [[UIApplication sharedApplication] keyWindow];
-
     // present the overlay
     [UIView beginAnimations:@"showing overlay" context:NULL];
     [UIView setAnimationDuration:2];