cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
changeset 3361 cfc6cd502f85
parent 3335 2520ee7a5484
child 3365 37ac593e9027
equal deleted inserted replaced
3360:717b4e46e855 3361:cfc6cd502f85
    51 	[pool release];
    51 	[pool release];
    52 	return retVal;
    52 	return retVal;
    53 }
    53 }
    54 
    54 
    55 @implementation SDLUIKitDelegate
    55 @implementation SDLUIKitDelegate
    56 @synthesize uiwindow, window, viewController;
    56 @synthesize uiwindow, window;
    57 
    57 
    58 // convenience method
    58 // convenience method
    59 +(SDLUIKitDelegate *)sharedAppDelegate {
    59 +(SDLUIKitDelegate *)sharedAppDelegate {
    60 	// the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    60 	// the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    61 	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    61 	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    63 
    63 
    64 -(id) init {
    64 -(id) init {
    65 	if (self = [super init]){
    65 	if (self = [super init]){
    66         self.uiwindow = nil;
    66         self.uiwindow = nil;
    67         self.window = NULL;
    67         self.window = NULL;
    68         self.viewController = nil;
    68         viewController = nil;
    69         isInGame = NO;
    69         isInGame = NO;
    70         return self;
    70         return self;
    71     } else 
    71     } else 
    72         return nil;
    72         return nil;
    73 }
    73 }
    74 
    74 
    75 -(void) dealloc {
    75 -(void) dealloc {
       
    76     SDL_DestroyWindow(self.window);
    76     [viewController release];
    77     [viewController release];
    77 	[uiwindow release];
    78 	[uiwindow release];
    78 	[super dealloc];
    79 	[super dealloc];
    79 }
    80 }
    80 
    81 
   109 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   110 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   110 	//[application setStatusBarHidden:YES animated:NO];
   111 	//[application setStatusBarHidden:YES animated:NO];
   111     //[application setStatusBarHidden:YES withAnimation:NO];
   112     //[application setStatusBarHidden:YES withAnimation:NO];
   112     [application setStatusBarHidden:YES];
   113     [application setStatusBarHidden:YES];
   113     [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
   114     [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
   114 		
   115     
   115 	self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   116 	self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   116 	self.uiwindow.backgroundColor = [UIColor blackColor];
   117 	self.uiwindow.backgroundColor = [UIColor blackColor];
   117 	
   118 	
   118     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   119     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   119         self.viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
   120         viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
   120     else
   121     else
   121         self.viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil];
   122         viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil];
   122 	[uiwindow addSubview:viewController.view];
   123 	[uiwindow addSubview:viewController.view];
   123     [viewController release];
       
   124 	
   124 	
   125 	// Set working directory to resource path
   125 	// Set working directory to resource path
   126 	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
   126 	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
   127 
   127 
   128 	[uiwindow makeKeyAndVisible];
   128 	[uiwindow makeKeyAndVisible];