the game now respects the orientation of the frontend
authorkoda
Wed, 07 Jul 2010 03:03:59 +0200
changeset 3627 f1da1d8fb56c
parent 3626 19f78afa0188
child 3628 2b4d878ba565
the game now respects the orientation of the frontend
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Wed Jul 07 02:52:11 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Wed Jul 07 03:03:59 2010 +0200
@@ -112,6 +112,22 @@
     self.view.alpha = 0;
     self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0);
     
+    // set initial orientation
+    ///[self didRotate:[NSNotification notificationWithName:UIDeviceOrientationDidChangeNotification object:nil]];
+    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
+    UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:12345];
+    switch (orientation) {
+        case UIDeviceOrientationLandscapeLeft:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
+            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
+            break;
+        case UIDeviceOrientationLandscapeRight:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
+            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
+            break;
+    }
+    CGRect rect = [[UIScreen mainScreen] bounds];
+    self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
     
     dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
                                         interval:1000
@@ -133,9 +149,6 @@
     [UIView setAnimationDuration:1];
     self.view.alpha = 1;
     [UIView commitAnimations];
-
-    // set initial orientation
-    [self didRotate:[NSNotification notificationWithName:UIDeviceOrientationDidChangeNotification object:nil]];
 }
 
 /* these are causing problems at reloading so let's remove 'em
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Wed Jul 07 02:52:11 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Wed Jul 07 03:03:59 2010 +0200
@@ -89,7 +89,7 @@
     [setup release];
 
     // since the sdlwindow is not yet created, we add the overlayController with a delay
-    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.3];
+    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.1];
     
     // this is the pascal fuction that starts the game (wrapped around isInGame)
     isInGame = YES;