cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
changeset 3006 da6023c2745b
parent 2803 1f446fc5c8ec
child 3025 01682ec58eb0
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Tue Mar 16 21:48:58 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Wed Mar 17 00:26:35 2010 +0000
@@ -29,6 +29,7 @@
 #import "GameSetup.h"
 #import "PascalImports.h"
 #import "MainMenuViewController.h"
+#import "overlayViewController.h"
 
 #ifdef main
 #undef main
@@ -43,7 +44,7 @@
 
 @implementation SDLUIKitDelegate
 
-@synthesize uiwindow, window, viewController;
+@synthesize uiwindow, window, viewController, overlayController;
 
 // convenience method
 +(SDLUIKitDelegate *)sharedAppDelegate {
@@ -67,6 +68,16 @@
 
 #pragma mark -
 #pragma mark Custom stuff
+-(void) showMenuAfterwards {
+    // draws the controller overlay after the sdl window has taken control
+    [uiwindow bringSubviewToFront:overlayController.view];
+
+	[UIView beginAnimations:@"showing overlay" context:NULL];
+	[UIView setAnimationDuration:1];
+	self. overlayController.view.alpha = 1;
+	[UIView commitAnimations];
+}
+
 -(IBAction) startSDLgame {
 	NSAutoreleasePool *internal_pool = [[NSAutoreleasePool alloc] init];
 
@@ -79,15 +90,24 @@
 	self.viewController.mainView.alpha = 0;
 	[UIView commitAnimations];
 
-	NSLog(@"Game is launching...");
+	NSLog(@"...Game is launching...");
 	const char **gameArgs = [setup getSettings];
 	[setup release];
-	
-	// this is the pascal fuction that starts the game
-	Game(gameArgs);
-	
+    
+    // overlay with controls
+    overlayController = [[overlayViewController alloc] initWithNibName:@"overlayViewController" bundle:nil];
+    overlayController.view.alpha = 0;
+    [uiwindow addSubview: overlayController.view];
+    [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(showMenuAfterwards) userInfo:nil repeats:NO];
+    
+	Game(gameArgs); // this is the pascal fuction that starts the game
+    
+    // let's clean memory
 	free(gameArgs);
-	NSLog(@"Game is exting...");
+    [overlayController.view removeFromSuperview];
+    [overlayController release];
+    
+	NSLog(@"...Game is exting...");
 
 	[uiwindow addSubview: viewController.view];
 	[uiwindow makeKeyAndVisible];