merge
authorkoda
Wed, 06 Apr 2011 00:30:02 +0200
changeset 5111 d8856d98ce7d
parent 5109 6d2e8a24277e (diff)
parent 5110 d48230ef9447 (current diff)
child 5112 4e2ebd8ac298
merge
hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas	Tue Apr 05 16:27:58 2011 -0400
+++ b/hedgewars/hwengine.pas	Wed Apr 06 00:30:02 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 16:27:58 2011 -0400
+++ b/hedgewars/uStore.pas	Wed Apr 06 00:30:02 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 16:27:58 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Wed Apr 06 00:30:02 2011 +0200
@@ -35,25 +35,14 @@
 
 #define BLACKVIEW_TAG 17935
 #define SECONDBLACKVIEW_TAG 48620
-#define VALGRIND "/opt/fink/bin/valgrind"
+
+@implementation SDLUIKitDelegate (customDelegate)
 
-int main (int argc, char *argv[]) {
-#ifdef VALGRIND_REXEC
-    // Using the valgrind build config, rexec ourself in valgrind
-    // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
-    if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0))
-        execl(VALGRIND, VALGRIND, "--leak-check=full", "--dsymutil=yes", argv[0], "-valgrind", NULL);
-#endif
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    int retVal = UIApplicationMain(argc, argv, nil, @"HedgewarsAppDelegate");
-    [pool release];
-    return retVal;
++(NSString *)getAppDelegateClassName {
+    return @"HedgewarsAppDelegate";
 }
 
-int SDL_main(int argc, char **argv) {
-    // dummy function to prevent linkage fail
-    return 0;
-}
+@end
 
 @implementation HedgewarsAppDelegate
 @synthesize mainViewController, overlayController, uiwindow, secondWindow, isInGame;
@@ -222,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)] &&
@@ -247,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/ObjcExports.m	Tue Apr 05 16:27:58 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m	Wed Apr 06 00:30:02 2011 +0200
@@ -154,3 +154,10 @@
 void updateVisualsNewTurn(void) {
     [amvc_instance updateAmmoVisuals];
 }
+
+// dummy function to prevent linkage fail
+int SDL_main(int argc, char **argv) {
+    return 0;
+}
+
+
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Tue Apr 05 16:27:58 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Wed Apr 06 00:30:02 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 16:27:58 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Wed Apr 06 00:30:02 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];
--- a/project_files/HedgewarsMobile/SDL.patch	Tue Apr 05 16:27:58 2011 -0400
+++ b/project_files/HedgewarsMobile/SDL.patch	Wed Apr 06 00:30:02 2011 +0200
@@ -1,26 +1,26 @@
-diff -r 48067bfc300c Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
---- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Feb 14 11:50:18 2011 -0600
-+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Sun Mar 13 18:22:16 2011 +0100
-@@ -1695,6 +1695,7 @@
+diff -r 8a04b596b472 Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
+--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Tue Apr 05 09:50:25 2011 -0700
++++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Tue Apr 05 22:19:33 2011 +0200
+@@ -1602,6 +1602,7 @@
  				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  				GCC_C_LANGUAGE_STANDARD = c99;
  				GCC_DEBUGGING_SYMBOLS = full;
 +				GCC_THUMB_SUPPORT = NO;
  				GCC_WARN_ABOUT_RETURN_TYPE = YES;
  				GCC_WARN_UNUSED_VARIABLE = NO;
- 				IPHONEOS_DEPLOYMENT_TARGET = 3.1;
-@@ -1712,6 +1713,7 @@
+ 				IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
+@@ -1619,6 +1620,7 @@
  				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
  				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  				GCC_C_LANGUAGE_STANDARD = c99;
 +				GCC_THUMB_SUPPORT = NO;
  				GCC_WARN_ABOUT_RETURN_TYPE = YES;
  				GCC_WARN_UNUSED_VARIABLE = NO;
- 				IPHONEOS_DEPLOYMENT_TARGET = 3.1;
-diff -r 48067bfc300c include/SDL_config_iphoneos.h
---- a/include/SDL_config_iphoneos.h	Mon Feb 14 11:50:18 2011 -0600
-+++ b/include/SDL_config_iphoneos.h	Sun Mar 13 18:22:16 2011 +0100
-@@ -119,7 +119,7 @@
+ 				IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
+diff -r 8a04b596b472 include/SDL_config_iphoneos.h
+--- a/include/SDL_config_iphoneos.h	Tue Apr 05 09:50:25 2011 -0700
++++ b/include/SDL_config_iphoneos.h	Tue Apr 05 22:19:33 2011 +0200
+@@ -107,7 +107,7 @@
  /* enable iPhone version of Core Audio driver */
  #define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
  /* Enable the dummy audio driver (src/audio/dummy/\*.c) */
@@ -29,7 +29,7 @@
  
  /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
  #define SDL_HAPTIC_DISABLED	1
-@@ -140,15 +140,18 @@
+@@ -128,15 +128,18 @@
  
  /* Supported video drivers */
  #define SDL_VIDEO_DRIVER_UIKIT	1
@@ -51,7 +51,7 @@
  
  /* enable iPhone keyboard support */
  #define SDL_IPHONE_KEYBOARD 1
-@@ -158,4 +161,7 @@
+@@ -146,4 +149,7 @@
   */
  #define SDL_IPHONE_MAX_GFORCE 5.0
  
@@ -59,33 +59,14 @@
 +#define SDL_VIEW_TAG 456987
 +
  #endif /* _SDL_config_iphoneos_h */
-diff -r 48067bfc300c src/video/uikit/SDL_uikitappdelegate.m
---- a/src/video/uikit/SDL_uikitappdelegate.m	Mon Feb 14 11:50:18 2011 -0600
-+++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun Mar 13 18:22:16 2011 +0100
-@@ -35,6 +35,7 @@
- static int forward_argc;
- static char **forward_argv;
- 
-+#if 0
- int main(int argc, char **argv) {
- 
-     int i;
-@@ -55,6 +56,7 @@
-     [pool release];
-     
- }
-+#endif
- 
- @implementation SDLUIKitDelegate
- 
-diff -r 48067bfc300c src/video/uikit/SDL_uikitopengles.m
---- a/src/video/uikit/SDL_uikitopengles.m	Mon Feb 14 11:50:18 2011 -0600
-+++ b/src/video/uikit/SDL_uikitopengles.m	Sun Mar 13 18:22:16 2011 +0100
+diff -r 8a04b596b472 src/video/uikit/SDL_uikitopengles.m
+--- a/src/video/uikit/SDL_uikitopengles.m	Tue Apr 05 09:50:25 2011 -0700
++++ b/src/video/uikit/SDL_uikitopengles.m	Tue Apr 05 22:19:33 2011 +0200
 @@ -117,6 +117,7 @@
                                      majorVersion: _this->gl_config.major_version];
      
      data->view = view;
 +    view.tag = SDL_VIEW_TAG;
-     
-     /* add the view to our window */
-     [uiwindow addSubview: view ];
+     view->viewcontroller = data->viewcontroller;
+     if (view->viewcontroller != nil) {
+         [view->viewcontroller setView:view];