# HG changeset patch # User koda # Date 1272718435 0 # Node ID 361bd29293f4c3afb338d50e5e5a016a312f883c # Parent 7eb4707d43f0bda5979e79f94adf06eff408bba4 add automatic rotation in ipad (landscape only) possible fix for compiling hw under haiku restore randomity in choosing the theme diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/MapConfigViewController.m --- a/cocoaTouch/MapConfigViewController.m Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/MapConfigViewController.m Sat May 01 12:53:55 2010 +0000 @@ -430,7 +430,9 @@ #pragma mark view management -(void) viewDidLoad { [super viewDidLoad]; - + + srandom(time(NULL)); + CGSize screenSize = [[UIScreen mainScreen] bounds].size; self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/OverlayViewController.m --- a/cocoaTouch/OverlayViewController.m Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/OverlayViewController.m Sat May 01 12:53:55 2010 +0000 @@ -29,34 +29,37 @@ // Release any cached data, images, etc that aren't in use. } -/* -- (void)didRotate:(NSNotification *)notification { +-(void) didRotate:(NSNotification *)notification { + UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + CGRect rect = [[UIScreen mainScreen] bounds]; + if (orientation == UIDeviceOrientationLandscapeLeft) { - } - if (orientation == UIDeviceOrientationLandscapeRight) { - } - if (orientation == UIDeviceOrientationPortrait) { - } - if (orientation == UIDeviceOrientationPortrait) { - } + [UIView beginAnimations:@"flip1" context:NULL]; + [UIView setAnimationDuration:0.8f]; + [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; + [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(0)); + self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90)); + self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height); + [UIView commitAnimations]; + } else + if (orientation == UIDeviceOrientationLandscapeRight) { + [UIView beginAnimations:@"flip2" context:NULL]; + [UIView setAnimationDuration:0.8f]; + [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; + [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(180)); + self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90)); + self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height); + [UIView commitAnimations]; + } } -*/ + -(void) viewDidLoad { - /* - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didRotate:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; - */ + isPopoverVisible = NO; self.view.alpha = 0; - - // needed for rotation to work on os < 3.2 self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); - self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0)); - self.view.frame = [[UIScreen mainScreen] applicationFrame]; + dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6] interval:1000 @@ -98,7 +101,20 @@ // draws the controller overlay after the sdl window has taken control -(void) showMenuAfterwards { [[SDLUIKitDelegate sharedAppDelegate].uiwindow bringSubviewToFront:self.view]; - + + // need to split paths because iphone doesn't rotate (so we don't need to subscribe to any notification + // nor perform engine actions when rotating + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(didRotate:) + name:@"UIDeviceOrientationDidChangeNotification" + object:nil]; + + [self didRotate:nil]; + } else + self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0)); + [UIView beginAnimations:@"showing overlay" context:NULL]; [UIView setAnimationDuration:1]; self.view.alpha = 1; diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Sat May 01 12:53:55 2010 +0000 @@ -30,7 +30,7 @@ SDL_Window *window; UIWindow *uiwindow; - MainMenuViewController *viewController; + MainMenuViewController *mainViewController; BOOL isInGame; } diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Sat May 01 12:53:55 2010 +0000 @@ -66,7 +66,7 @@ if (self = [super init]){ self.uiwindow = nil; self.window = NULL; - viewController = nil; + mainViewController = nil; isInGame = NO; return self; } else @@ -75,14 +75,14 @@ -(void) dealloc { SDL_DestroyWindow(self.window); - [viewController release]; + [mainViewController release]; [uiwindow release]; [super dealloc]; } // main routine for calling the actual game engine -(IBAction) startSDLgame { - [viewController disappear]; + [mainViewController disappear]; // pull out useful configuration info from various files GameSetup *setup = [[GameSetup alloc] init]; @@ -104,7 +104,7 @@ free(gameArgs); [overlayController.view removeFromSuperview]; - [viewController appear]; + [mainViewController appear]; } // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) @@ -118,10 +118,10 @@ self.uiwindow.backgroundColor = [UIColor blackColor]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil]; + mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil]; else - viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil]; - [uiwindow addSubview:viewController.view]; + mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil]; + [uiwindow addSubview:mainViewController.view]; // Set working directory to resource path [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]]; diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/otherSrc/CGPointUtils.c --- a/cocoaTouch/otherSrc/CGPointUtils.c Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/otherSrc/CGPointUtils.c Sat May 01 12:53:55 2010 +0000 @@ -10,8 +10,6 @@ #include "CGPointUtils.h" #include -#define degreesToRadian(x) (M_PI * x / 180.0) -#define radiansToDegrees(x) (180.0 * x / M_PI) CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) { CGFloat deltaX = second.x - first.x; diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/otherSrc/CGPointUtils.h --- a/cocoaTouch/otherSrc/CGPointUtils.h Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/otherSrc/CGPointUtils.h Sat May 01 12:53:55 2010 +0000 @@ -9,6 +9,9 @@ #import +#define degreesToRadian(x) (M_PI * x / 180.0) +#define radiansToDegrees(x) (180.0 * x / M_PI) + CGFloat distanceBetweenPoints (CGPoint first, CGPoint second); CGFloat angleBetweenPoints(CGPoint first, CGPoint second); CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint lin2End); diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/otherSrc/CommodityFunctions.m --- a/cocoaTouch/otherSrc/CommodityFunctions.m Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/otherSrc/CommodityFunctions.m Sat May 01 12:53:55 2010 +0000 @@ -44,7 +44,7 @@ BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); + return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); else return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/otherSrc/PascalImports.h --- a/cocoaTouch/otherSrc/PascalImports.h Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/otherSrc/PascalImports.h Sat May 01 12:53:55 2010 +0000 @@ -51,6 +51,7 @@ void HW_terminate(BOOL); + void HW_setRotationQt(float); #ifdef __cplusplus } #endif diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/xib/GameConfigViewController-iPad.xib --- a/cocoaTouch/xib/GameConfigViewController-iPad.xib Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/xib/GameConfigViewController-iPad.xib Sat May 01 12:53:55 2010 +0000 @@ -12,7 +12,6 @@ YES - YES @@ -38,7 +37,7 @@ IBIPadFramework - + 292 YES @@ -75,7 +74,6 @@ {1024, 768} - 3 MQA @@ -192,7 +190,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - {{252, 103}, {1024, 768}} + {{252, 106}, {1024, 768}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/xib/MainMenuViewController-iPad.xib --- a/cocoaTouch/xib/MainMenuViewController-iPad.xib Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/xib/MainMenuViewController-iPad.xib Sat May 01 12:53:55 2010 +0000 @@ -246,6 +246,15 @@ 51 + + + switchViews: + + + 7 + + 54 + @@ -368,7 +377,7 @@ - 53 + 54 diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/xib/MapConfigViewController-iPad.xib --- a/cocoaTouch/xib/MapConfigViewController-iPad.xib Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/xib/MapConfigViewController-iPad.xib Sat May 01 12:53:55 2010 +0000 @@ -44,7 +44,7 @@ YES - 292 + 289 {{756, 170}, {240, 30}} NO @@ -97,7 +97,7 @@ - 292 + 289 {{746, 20}, {256, 128}} NO @@ -167,7 +167,7 @@ - 274 + 265 {{724, 224}, {300, 500}} @@ -422,7 +422,7 @@ YES MapConfigViewController UIResponder - {{255, -206}, {1024, 768}} + {{255, 106}, {1024, 768}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin diff -r 7eb4707d43f0 -r 361bd29293f4 cocoaTouch/xib/OverlayViewController.xib --- a/cocoaTouch/xib/OverlayViewController.xib Sat May 01 05:15:16 2010 +0000 +++ b/cocoaTouch/xib/OverlayViewController.xib Sat May 01 12:53:55 2010 +0000 @@ -624,7 +624,7 @@ YES OverlayViewController UIResponder - {{222, 776}, {480, 320}} + {{222, 756}, {480, 320}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -881,6 +881,20 @@ UIViewController IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource UIKit.framework/Headers/UITabBarController.h @@ -905,7 +919,7 @@ YES - ../../project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj + ../../project_files/HedgewarsMobile/Hedgewars.xcodeproj 3 YES diff -r 7eb4707d43f0 -r 361bd29293f4 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sat May 01 05:15:16 2010 +0000 +++ b/hedgewars/SDLh.pas Sat May 01 12:53:55 2010 +0000 @@ -27,13 +27,22 @@ {$IFDEF FREEBSD} {$DEFINE UNIX} {$ENDIF} -// UNIX is already defined in Darwin +{$IFDEF DARWIN} + {$DEFINE UNIX} +{$ENDIF} +{$IFDEF HAIKU} + {$DEFINE UNIX} +{$ENDIF} {$IFDEF UNIX} {$IFNDEF DARWIN} {$linklib c} {$ENDIF} - {$linklib pthread} + {$IFDEF HAIKU} + {$linklib root} + {$ELSE} + {$linklib pthread} + {$ENDIF} {$ENDIF} {$IFDEF FPC} diff -r 7eb4707d43f0 -r 361bd29293f4 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat May 01 05:15:16 2010 +0000 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat May 01 12:53:55 2010 +0000 @@ -1194,9 +1194,7 @@ /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers, "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**", - "\"$(SRCROOT)/../../../Library/lpng141\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"", - "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer\"", ); IPHONEOS_DEPLOYMENT_TARGET = 3.0; ONLY_ACTIVE_ARCH = NO; @@ -1398,9 +1396,7 @@ /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers, "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**", - "\"$(SRCROOT)/../../../Library/lpng141\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"", - "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer\"", ); IPHONEOS_DEPLOYMENT_TARGET = 3.0; ONLY_ACTIVE_ARCH = NO; @@ -1437,9 +1433,7 @@ /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers, "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**", - "\"$(SRCROOT)/../../../Library/lpng141\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"", - "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer\"", ); IPHONEOS_DEPLOYMENT_TARGET = 3.0; ONLY_ACTIVE_ARCH = NO; diff -r 7eb4707d43f0 -r 361bd29293f4 project_files/HedgewarsMobile/Info.plist --- a/project_files/HedgewarsMobile/Info.plist Sat May 01 05:15:16 2010 +0000 +++ b/project_files/HedgewarsMobile/Info.plist Sat May 01 12:53:55 2010 +0000 @@ -28,7 +28,7 @@ LSRequiresIPhoneOS UIInterfaceOrientation - UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight UIStatusBarHidden