project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
changeset 4354 c4e1820fa792
parent 4098 40df542b5f62
child 4356 d1d26f8963a3
equal deleted inserted replaced
4352:5a7b02cadc68 4354:c4e1820fa792
    55     [pool release];
    55     [pool release];
    56     return retVal;
    56     return retVal;
    57 }
    57 }
    58 
    58 
    59 @implementation SDLUIKitDelegate
    59 @implementation SDLUIKitDelegate
    60 @synthesize mainViewController, uiwindow, secondWindow, isInGame;
    60 @synthesize mainViewController, overlayController, uiwindow, secondWindow, isInGame;
    61 
    61 
    62 // convenience method
    62 // convenience method
    63 +(SDLUIKitDelegate *)sharedAppDelegate {
    63 +(SDLUIKitDelegate *)sharedAppDelegate {
    64     // the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    64     // the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    65     return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    65     return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    75     return self;
    75     return self;
    76 }
    76 }
    77 
    77 
    78 -(void) dealloc {
    78 -(void) dealloc {
    79     [mainViewController release];
    79     [mainViewController release];
       
    80     [overlayController release];
    80     [uiwindow release];
    81     [uiwindow release];
    81     [secondWindow release];
    82     [secondWindow release];
    82     [super dealloc];
    83     [super dealloc];
    83 }
    84 }
    84 
    85 
   151 }
   152 }
   152 
   153 
   153 // overlay with controls, become visible later, with a transparency effect
   154 // overlay with controls, become visible later, with a transparency effect
   154 -(void) displayOverlayLater:(id) object {
   155 -(void) displayOverlayLater:(id) object {
   155     NSDictionary *dict = (NSDictionary *)object;
   156     NSDictionary *dict = (NSDictionary *)object;
   156     OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
   157     self.overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
   157     overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
   158     self.overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
   158     overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
   159     self.overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
   159     
   160     
   160     UIWindow *gameWindow;
   161     UIWindow *gameWindow;
   161     if (IS_DUALHEAD())
   162     if (IS_DUALHEAD())
   162         gameWindow = self.uiwindow;
   163         gameWindow = self.uiwindow;
   163     else
   164     else
   164         gameWindow = [[UIApplication sharedApplication] keyWindow];
   165         gameWindow = [[UIApplication sharedApplication] keyWindow];
   165     [gameWindow addSubview:overlayController.view];
   166     [gameWindow addSubview:self.overlayController.view];
   166     //[[[gameWindow subviews] objectAtIndex:0] addSubview:overlayController.view];
       
   167     // don't release a controller according to http://developer.apple.com/library/ios/#qa/qa2010/qa1688.html
       
   168     //[overlayController release];
       
   169 }
   167 }
   170 
   168 
   171 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
   169 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
   172 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   170 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   173     [application setStatusBarHidden:YES];
   171     [application setStatusBarHidden:YES];