# HG changeset patch # User koda # Date 1265166104 0 # Node ID 03df0573a9fd6b9d423db1d38167e2e1c613507b # Parent f860f27028cc014f9f3cb0106c479b1f14f2b440 programmatically load main controller adapt settings to landscape transition between main controller and other views diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/MainMenuViewController.h --- a/cocoaTouch/MainMenuViewController.h Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/MainMenuViewController.h Wed Feb 03 03:01:44 2010 +0000 @@ -7,20 +7,17 @@ // #import - +#import "SettingsViewController.h" @interface MainMenuViewController : UIViewController { - UIButton *passandplayButton; - UIButton *netplayButton; - UIButton *storeButton; UILabel *versionLabel; + SettingsViewController *settingsViewController; } -@property (nonatomic, retain) IBOutlet UIButton *passandplayButton; -@property (nonatomic, retain) IBOutlet UIButton *netplayButton; -@property (nonatomic, retain) IBOutlet UIButton *storeButton; @property (nonatomic, retain) IBOutlet UILabel *versionLabel; +@property (nonatomic, retain) SettingsViewController *settingsViewController; -(IBAction) startPlaying; -(IBAction) notYetImplemented; +-(IBAction) switchViews:(id)sender; @end diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/MainMenuViewController.m --- a/cocoaTouch/MainMenuViewController.m Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/MainMenuViewController.m Wed Feb 03 03:01:44 2010 +0000 @@ -11,7 +11,7 @@ @implementation MainMenuViewController -@synthesize passandplayButton, netplayButton, storeButton, versionLabel; +@synthesize versionLabel, settingsViewController; /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. @@ -23,70 +23,89 @@ } */ +-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { + return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); +} + + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. + if (nil == self.settingsViewController.view.superview) { + self.settingsViewController = nil; + } +} + // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -(void) viewDidLoad { - self.versionLabel.text = @"Hedgewars version 0.9.13-dev"; - [super viewDidLoad]; -} - --(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { - if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES; - else return NO; + self.versionLabel.text = @"0.9.13-dev"; + [super viewDidLoad]; } -/* -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} -*/ - - (void)viewDidUnload { // Release any retained subviews of the main view. - self.passandplayButton = nil; - self.netplayButton = nil; - self.storeButton = nil; self.versionLabel = nil; } - (void)dealloc { - [passandplayButton release]; - [netplayButton release]; - [storeButton release]; [versionLabel release]; - [super dealloc]; + [settingsViewController release]; + [super dealloc]; } // disable the buttons when to prevent launching twice the game -(void) viewWillDisappear:(BOOL)animated { - passandplayButton.enabled = NO; - netplayButton.enabled = NO; - storeButton.enabled = NO; + self.view.userInteractionEnabled = NO; [super viewWillDisappear:animated]; } -(void) viewWillAppear:(BOOL)animated { - passandplayButton.enabled = YES; - netplayButton.enabled = YES; - storeButton.enabled = YES; + self.view.userInteractionEnabled = YES; [super viewWillAppear:animated]; } +#pragma mark - +#pragma mark Action buttons -(IBAction) startPlaying { [[SDLUIKitDelegate sharedAppDelegate] startSDLgame]; } -(IBAction) notYetImplemented { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented" - message:@"Sorry, this feature is not yet implemented" - delegate:nil - cancelButtonTitle:@"Well, don't worry" - otherButtonTitles:nil]; + message:@"Sorry, this feature is not yet implemented" + delegate:nil + cancelButtonTitle:@"Well, don't worry" + otherButtonTitles:nil]; [alert show]; [alert release]; } +-(IBAction) switchViews:(id)sender { + + // view not displayed or not created + if (nil == self.settingsViewController.view.superview) { + // view not created + if (nil == self.settingsViewController) { + SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" + bundle:nil]; + self.settingsViewController = controller; + [controller release]; + } + self.settingsViewController.view.frame = CGRectMake(0, -480, 480, 320); + + [UIView beginAnimations:@"View Switch" context:NULL]; + [UIView setAnimationDuration:3]; + [UIView setAnimationDuration:UIViewAnimationCurveEaseOut]; + self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320); + + // we have the new controller, let's switch + [self.view addSubview:settingsViewController.view]; + [UIView commitAnimations]; + } + +} + @end diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/MainMenuViewController.xib --- a/cocoaTouch/MainMenuViewController.xib Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/MainMenuViewController.xib Wed Feb 03 03:01:44 2010 +0000 @@ -12,7 +12,7 @@ YES - + YES @@ -49,18 +49,30 @@ 3 MCAwAA - NO - 4 NO NSImage background.png + + + 292 + {{20, 20}, {240, 94}} + + NO + NO + 4 + NO + + NSImage + title.png + + 292 - {{223, 46}, {232, 61}} + {{240, 145}, {220, 52}} 1 @@ -95,7 +107,7 @@ 292 - {{199, 130}, {232, 61}} + {{240, 241}, {220, 52}} 1 @@ -120,7 +132,7 @@ 292 - {{223, 213}, {232, 61}} + {{28, 194}, {220, 52}} 1 @@ -145,7 +157,7 @@ 292 - {{44, 384}, {232, 21}} + {{268, 26}, {199, 21}} NO YES @@ -165,6 +177,27 @@ 10 2 + + + 292 + {{352, 55}, {59, 52}} + + NO + NO + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + settingsButton.png + + {480, 320} @@ -183,30 +216,6 @@ 3 - - passandplayButton - - - - 9 - - - - netplayButton - - - - 10 - - - - storeButton - - - - 11 - - startPlaying @@ -241,6 +250,15 @@ 17 + + + switchViews: + + + 7 + + 20 + @@ -257,10 +275,12 @@ YES - - + + + + @@ -300,6 +320,16 @@ + + 18 + + + + + 19 + + + @@ -311,6 +341,8 @@ 1.IBEditorWindowLastContentRect 1.IBPluginDependency 13.IBPluginDependency + 18.IBPluginDependency + 19.IBPluginDependency 4.IBPluginDependency 5.IBPluginDependency 7.IBPluginDependency @@ -320,7 +352,9 @@ YES MainMenuViewController UIResponder - {{493, 614}, {480, 320}} + {{577, 514}, {480, 320}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -345,7 +379,7 @@ - 17 + 20 @@ -359,27 +393,25 @@ YES notYetImplemented startPlaying + switchViews: YES id id + id YES YES - netplayButton - passandplayButton - storeButton + settingsViewController versionLabel YES - UIButton - UIButton - UIButton + SettingsViewController UILabel @@ -388,6 +420,54 @@ ../../../hedge.build/trunk/cocoaTouch/MainMenuViewController.h + + SettingsViewController + UIViewController + + YES + + YES + backgroundTap: + deleteData: + sliderChanged: + textFieldDoneEditing: + + + YES + id + id + id + id + + + + YES + + YES + buttonContainer + password + table + username + volumeCell + volumeLabel + volumeSlider + + + YES + UIView + UITextField + UITableView + UITextField + UITableViewCell + UILabel + UISlider + + + + IBProjectSource + ../../../hedge.build/trunk/cocoaTouch/SettingsViewController.h + + YES @@ -562,6 +642,14 @@ + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + UISearchBar UIView @@ -578,14 +666,43 @@ - UIView + UISlider + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISlider.h + + + + UITableView + UIScrollView IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UITableViewCell + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITableViewCell.h + + + + UITextField + UIControl + + IBFrameworkSource UIKit.framework/Headers/UITextField.h UIView + + + + UIView UIResponder IBFrameworkSource diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/MainWindow.xib --- a/cocoaTouch/MainWindow.xib Mon Feb 01 22:01:35 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,489 +0,0 @@ - - - - 784 - 10C540 - 740 - 1038.25 - 458.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 62 - - - YES - - - YES - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - YES - - YES - - - YES - - - - YES - - IBFilesOwner - - - IBFirstResponder - - - - - 1316 - - {480, 320} - - - - 1 - MCAwIDAAA - - NO - - - MainMenuViewController - YES - - - - - YES - - - delegate - - - - 4 - - - - uiwindow - - - - 25 - - - - viewController - - - - 28 - - - - - YES - - 0 - - - - - - 2 - - - YES - - - - - -1 - - - File's Owner - - - 3 - - - - - -2 - - - - - 26 - - - - - - - YES - - YES - -1.CustomClassName - -2.CustomClassName - 2.IBAttributePlaceholdersKey - 2.IBEditorWindowLastContentRect - 2.IBPluginDependency - 26.CustomClassName - 26.IBEditorWindowLastContentRect - 26.IBPluginDependency - 3.CustomClassName - 3.IBPluginDependency - - - YES - UIApplication - UIResponder - - YES - - - YES - - - {{530, 261}, {480, 320}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - MainMenuViewController - {{349, 679}, {480, 320}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - SDLUIKitDelegate - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - YES - - - YES - - - - - YES - - - YES - - - - 28 - - - - YES - - MainMenuViewController - UIViewController - - YES - - YES - notYetImplemented - startPlaying - - - YES - id - id - - - - YES - - YES - netplayButton - passandplayButton - storeButton - versionLabel - - - YES - UIButton - UIButton - UIButton - UILabel - - - - IBProjectSource - ../../../hedge.build/trunk/cocoaTouch/MainMenuViewController.h - - - - SDLUIKitDelegate - NSObject - - YES - - YES - uiwindow - viewController - - - YES - UIWindow - UIViewController - - - - IBProjectSource - ../../../hedge.build/trunk/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h - - - - - YES - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSNetServices.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPort.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSStream.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSXMLParser.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CAAnimation.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CALayer.h - - - - NSObject - - IBFrameworkSource - UIKit.framework/Headers/UIAccessibility.h - - - - NSObject - - IBFrameworkSource - UIKit.framework/Headers/UINibLoading.h - - - - NSObject - - IBFrameworkSource - UIKit.framework/Headers/UIResponder.h - - - - UIApplication - UIResponder - - IBFrameworkSource - UIKit.framework/Headers/UIApplication.h - - - - UIButton - UIControl - - IBFrameworkSource - UIKit.framework/Headers/UIButton.h - - - - UIControl - UIView - - IBFrameworkSource - UIKit.framework/Headers/UIControl.h - - - - UILabel - UIView - - IBFrameworkSource - UIKit.framework/Headers/UILabel.h - - - - UIResponder - NSObject - - - - UISearchBar - UIView - - IBFrameworkSource - UIKit.framework/Headers/UISearchBar.h - - - - UISearchDisplayController - NSObject - - IBFrameworkSource - UIKit.framework/Headers/UISearchDisplayController.h - - - - UIView - - IBFrameworkSource - UIKit.framework/Headers/UITextField.h - - - - UIView - UIResponder - - IBFrameworkSource - UIKit.framework/Headers/UIView.h - - - - UIViewController - - IBFrameworkSource - UIKit.framework/Headers/UINavigationController.h - - - - UIViewController - - IBFrameworkSource - UIKit.framework/Headers/UITabBarController.h - - - - UIViewController - UIResponder - - IBFrameworkSource - UIKit.framework/Headers/UIViewController.h - - - - UIWindow - UIView - - IBFrameworkSource - UIKit.framework/Headers/UIWindow.h - - - - - 0 - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 - - - YES - ../../../Documents/xcode/hwengine/hwengine.xcodeproj - 3 - 3.1 - - diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Wed Feb 03 03:01:44 2010 +0000 @@ -22,17 +22,18 @@ #import #import "SDL_video.h" +#import "MainMenuViewController.h" @interface SDLUIKitDelegate:NSObject { SDL_Window *window; UIWindow *uiwindow; - UIViewController *viewController; + MainMenuViewController *viewController; } // the outlets are set in MainWindow.xib @property (readwrite, assign) SDL_Window *window; -@property (readwrite, retain) IBOutlet UIWindow *uiwindow; -@property (nonatomic, retain) IBOutlet UIViewController *viewController; +@property (readwrite, retain) UIWindow *uiwindow; +@property (nonatomic, retain) MainMenuViewController *viewController; +(SDLUIKitDelegate *)sharedAppDelegate; -(NSString *)dataFilePath:(NSString *)fileName; diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Wed Feb 03 03:01:44 2010 +0000 @@ -80,9 +80,8 @@ // remove the current view to free resources [UIView beginAnimations:@"removing main controller" context:NULL]; [UIView setAnimationDuration:1]; - viewController.view.alpha = 0; + self.viewController.view.alpha = 0; [UIView commitAnimations]; - [viewController.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; NSLog(@"Game is launching..."); const char **gameArgs = [setup getSettings]; @@ -96,14 +95,14 @@ [setup release]; + [uiwindow addSubview: viewController.view]; + [uiwindow makeKeyAndVisible]; + [UIView beginAnimations:@"inserting main controller" context:NULL]; [UIView setAnimationDuration:1]; - viewController.view.alpha = 1; + self.viewController.view.alpha = 1; [UIView commitAnimations]; - [uiwindow addSubview: viewController.view]; - [uiwindow makeKeyAndVisible]; - [internal_pool release]; } @@ -151,20 +150,23 @@ #pragma mark - #pragma mark SDLUIKitDelegate methods - - // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) -(void) applicationDidFinishLaunching:(UIApplication *)application { [application setStatusBarHidden:YES animated:NO]; [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; + + self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.uiwindow.backgroundColor = [UIColor blackColor]; - [self checkFirstRun]; + self.viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil]; /* Set working directory to resource path */ [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; [uiwindow addSubview:viewController.view]; [uiwindow makeKeyAndVisible]; + [uiwindow layoutSubviews]; + [self checkFirstRun]; } -(void) applicationWillTerminate:(UIApplication *)application { diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/SDLOverrides/SDL_uikitview.m --- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Wed Feb 03 03:01:44 2010 +0000 @@ -93,13 +93,11 @@ void IPH_showControls (void) { NSLog(@"Showing controls"); - /* [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; attackButton.frame = CGRectMake(30, 430, 260, 50); menuButton.frame = CGRectMake(0, 430, 30, 50); [UIView commitAnimations]; - */ } #pragma mark - @@ -114,7 +112,7 @@ #pragma mark - #pragma mark Custom SDL_UIView input handling -#define kMinimumPinchDelta 30 +#define kMinimumPinchDelta 40 #define kMinimumGestureLength 10 #define kMaximumVariance 3 diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/SettingsViewController.m --- a/cocoaTouch/SettingsViewController.m Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/SettingsViewController.m Wed Feb 03 03:01:44 2010 +0000 @@ -118,13 +118,13 @@ [buttonContainer release]; [super dealloc]; } -/* + // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations - return (interfaceOrientation == UIInterfaceOrientationPortrait); + return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } -*/ + // makes the keyboard go away when background is tapped -(IBAction) backgroundTap: (id)sender { @@ -163,6 +163,7 @@ #pragma mark - #pragma mark UIActionSheet Methods -(IBAction) deleteData: (id)sender { + /* temporary commented out UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") delegate:self cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") @@ -170,6 +171,15 @@ otherButtonTitles:nil]; [actionSheet showInView:self.view]; [actionSheet release]; + */ + [UIView beginAnimations:@"Get Back" context:NULL]; + [UIView setAnimationDuration:3]; + [UIView setAnimationDuration:UIViewAnimationCurveEaseOut]; + + self.view.frame = CGRectMake(0, -480, 480, 320); + [UIView commitAnimations]; + + [self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2]; } -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { diff -r f860f27028cc -r 03df0573a9fd cocoaTouch/SettingsViewController.xib --- a/cocoaTouch/SettingsViewController.xib Mon Feb 01 22:01:35 2010 +0000 +++ b/cocoaTouch/SettingsViewController.xib Wed Feb 03 03:01:44 2010 +0000 @@ -12,6 +12,8 @@ YES + + YES @@ -88,27 +90,27 @@ - + 292 YES 274 - {320, 431} + {480, 320} NO 4 NO NSImage - Background.png + background.png 274 - {{0, 18}, {320, 393}} + {{0, 20}, {480, 280}} NO YES @@ -124,12 +126,12 @@ 10 - {320, 431} - - 3 - MQA + {480, 320} + + + 1 + MCAwIDAAA - @@ -187,10 +189,7 @@ 17 16 - - 1 - MCAwIDAAA - + 1 10 @@ -225,9 +224,8 @@ 292 - {{20, 38}, {280, 50}} + {{100, 39}, {280, 50}} - NO NO 0 @@ -239,7 +237,10 @@ 1 Erase All Data - + + 3 + MQA + 1 MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA @@ -250,9 +251,8 @@ - {320, 100} + {480, 100} - 3 MQA @@ -522,7 +522,7 @@ SettingsViewController UIResponder UIControl - {{556, 412}, {320, 480}} + {{476, 492}, {480, 320}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -532,7 +532,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin {{1352, 334}, {220, 50}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin - {{734, 817}, {320, 100}} + {{476, 500}, {480, 100}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin