cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
changeset 2740 03df0573a9fd
parent 2738 bfccb2ec4334
child 2743 39d097ac2276
equal deleted inserted replaced
2739:f860f27028cc 2740:03df0573a9fd
    78 	[setup startThread:@"engineProtocol"];
    78 	[setup startThread:@"engineProtocol"];
    79 
    79 
    80 	// remove the current view to free resources
    80 	// remove the current view to free resources
    81 	[UIView beginAnimations:@"removing main controller" context:NULL];
    81 	[UIView beginAnimations:@"removing main controller" context:NULL];
    82 	[UIView setAnimationDuration:1];
    82 	[UIView setAnimationDuration:1];
    83 	viewController.view.alpha = 0;
    83 	self.viewController.view.alpha = 0;
    84 	[UIView commitAnimations];
    84 	[UIView commitAnimations];
    85 	[viewController.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1];
       
    86 
    85 
    87 	NSLog(@"Game is launching...");
    86 	NSLog(@"Game is launching...");
    88 	const char **gameArgs = [setup getSettings];
    87 	const char **gameArgs = [setup getSettings];
    89 	
    88 	
    90 	// direct execution or thread? check the one that gives most fps
    89 	// direct execution or thread? check the one that gives most fps
    94 	free(gameArgs);
    93 	free(gameArgs);
    95 	NSLog(@"Game is exting...");
    94 	NSLog(@"Game is exting...");
    96 	
    95 	
    97 	[setup release];
    96 	[setup release];
    98 
    97 
       
    98 	[uiwindow addSubview: viewController.view];
       
    99 	[uiwindow makeKeyAndVisible];
       
   100 	
    99 	[UIView beginAnimations:@"inserting main controller" context:NULL];
   101 	[UIView beginAnimations:@"inserting main controller" context:NULL];
   100 	[UIView setAnimationDuration:1];
   102 	[UIView setAnimationDuration:1];
   101 	viewController.view.alpha = 1;
   103 	self.viewController.view.alpha = 1;
   102 	[UIView commitAnimations];
   104 	[UIView commitAnimations];
   103 	
       
   104 	[uiwindow addSubview: viewController.view];
       
   105 	[uiwindow makeKeyAndVisible];
       
   106 	
   105 	
   107 	[internal_pool release];
   106 	[internal_pool release];
   108 }
   107 }
   109 
   108 
   110 -(BOOL) checkFirstRun {
   109 -(BOOL) checkFirstRun {
   149 	*/
   148 	*/
   150 }
   149 }
   151 
   150 
   152 #pragma mark -
   151 #pragma mark -
   153 #pragma mark SDLUIKitDelegate methods
   152 #pragma mark SDLUIKitDelegate methods
   154 
       
   155 
       
   156 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib)
   153 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib)
   157 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   154 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   158 	[application setStatusBarHidden:YES animated:NO];
   155 	[application setStatusBarHidden:YES animated:NO];
   159 	[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
   156 	[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
       
   157 		
       
   158 	self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
       
   159 	self.uiwindow.backgroundColor = [UIColor blackColor];
   160 	
   160 	
   161 	[self checkFirstRun];
   161 	self.viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
   162 	
   162 	
   163 	/* Set working directory to resource path */
   163 	/* Set working directory to resource path */
   164 	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
   164 	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
   165 
   165 
   166 	[uiwindow addSubview:viewController.view];
   166 	[uiwindow addSubview:viewController.view];
   167 	[uiwindow makeKeyAndVisible];
   167 	[uiwindow makeKeyAndVisible];
       
   168 	[uiwindow layoutSubviews];
       
   169 	[self checkFirstRun];
   168 }
   170 }
   169 
   171 
   170 -(void) applicationWillTerminate:(UIApplication *)application {
   172 -(void) applicationWillTerminate:(UIApplication *)application {
   171 	SDL_SendQuit();
   173 	SDL_SendQuit();
   172 	/* hack to prevent automatic termination.  See SDL_uikitevents.m for details */
   174 	/* hack to prevent automatic termination.  See SDL_uikitevents.m for details */