# 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 <math.h> -#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 <CoreGraphics/CoreGraphics.h> +#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 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="2"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -38,7 +37,7 @@ <string key="targetRuntimeIdentifier">IBIPadFramework</string> </object> <object class="IBUIView" id="766721923"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">292</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -75,7 +74,6 @@ </object> </object> <string key="NSFrameSize">{1024, 768}</string> - <reference key="NSSuperview"/> <object class="NSColor" key="IBUIBackgroundColor"> <int key="NSColorSpace">3</int> <bytes key="NSWhite">MQA</bytes> @@ -192,7 +190,7 @@ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>{{252, 103}, {1024, 768}}</string> + <string>{{252, 106}, {1024, 768}}</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> </object> 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 @@ </object> <int key="connectionID">51</int> </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchEventConnection" key="connection"> + <string key="label">switchViews:</string> + <reference key="source" ref="898948205"/> + <reference key="destination" ref="372490531"/> + <int key="IBEventType">7</int> + </object> + <int key="connectionID">54</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -368,7 +377,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">53</int> + <int key="maxID">54</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> 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 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBUISegmentedControl" id="88728219"> <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">292</int> + <int key="NSvFlags">289</int> <string key="NSFrame">{{756, 170}, {240, 30}}</string> <reference key="NSSuperview" ref="191373211"/> <bool key="IBUIOpaque">NO</bool> @@ -97,7 +97,7 @@ </object> <object class="IBUIButton" id="326163764"> <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">292</int> + <int key="NSvFlags">289</int> <string key="NSFrame">{{746, 20}, {256, 128}}</string> <reference key="NSSuperview" ref="191373211"/> <bool key="IBUIOpaque">NO</bool> @@ -167,7 +167,7 @@ </object> <object class="IBUITableView" id="565214171"> <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">274</int> + <int key="NSvFlags">265</int> <string key="NSFrame">{{724, 224}, {300, 500}}</string> <reference key="NSSuperview" ref="191373211"/> <object class="NSColor" key="IBUIBackgroundColor"> @@ -422,7 +422,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>MapConfigViewController</string> <string>UIResponder</string> - <string>{{255, -206}, {1024, 768}}</string> + <string>{{255, 106}, {1024, 768}}</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> 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 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>OverlayViewController</string> <string>UIResponder</string> - <string>{{222, 776}, {480, 320}}</string> + <string>{{222, 756}, {480, 320}}</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> @@ -881,6 +881,20 @@ <string key="className">UIViewController</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string> </object> </object> @@ -905,7 +919,7 @@ <integer value="3100" key="NS.object.0"/> </object> <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> - <string key="IBDocument.LastKnownRelativeProjectPath">../../project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj</string> + <string key="IBDocument.LastKnownRelativeProjectPath">../../project_files/HedgewarsMobile/Hedgewars.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes"> <bool key="EncodedWithXMLCoder">YES</bool> 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 @@ <key>LSRequiresIPhoneOS</key> <true/> <key>UIInterfaceOrientation</key> - <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> <key>UIStatusBarHidden</key> <true/> </dict>