project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
changeset 3941 017b2b31e1c6
parent 3940 cc29628976cc
child 3952 d6412423da45
equal deleted inserted replaced
3940:cc29628976cc 3941:017b2b31e1c6
    84 }
    84 }
    85 
    85 
    86 // main routine for calling the actual game engine
    86 // main routine for calling the actual game engine
    87 -(void) startSDLgame:(NSDictionary *)gameDictionary {
    87 -(void) startSDLgame:(NSDictionary *)gameDictionary {
    88     UIWindow *gameWindow;
    88     UIWindow *gameWindow;
    89     if ([[UIScreen screens] count] > 1)
    89     if (IS_DUALHEAD())
    90         gameWindow = self.secondWindow;
    90         gameWindow = self.secondWindow;
    91     else
    91     else
    92         gameWindow = self.uiwindow;
    92         gameWindow = self.uiwindow;
       
    93 
    93     UIView *blackView = [[UIView alloc] initWithFrame:gameWindow.frame];
    94     UIView *blackView = [[UIView alloc] initWithFrame:gameWindow.frame];
    94     blackView.backgroundColor = [UIColor blackColor];
    95     blackView.backgroundColor = [UIColor blackColor];
    95     blackView.opaque = YES;
    96     blackView.opaque = YES;
    96     blackView.tag = BLACKVIEW_TAG;
    97     blackView.tag = BLACKVIEW_TAG;
    97     [gameWindow addSubview:blackView];
    98     [gameWindow addSubview:blackView];    
    98     [blackView release];
    99     if (IS_DUALHEAD()) {
    99     
   100         blackView.alpha = 0;
   100     if ([[UIScreen screens] count] > 1) {
   101         [UIView beginAnimations:@"fading to game first" context:NULL];
       
   102         [UIView setAnimationDuration:1];
       
   103         blackView.alpha = 1;
       
   104         [UIView commitAnimations];
       
   105         
   101         UIView *secondBlackView = [[UIView alloc] initWithFrame:self.uiwindow.frame];
   106         UIView *secondBlackView = [[UIView alloc] initWithFrame:self.uiwindow.frame];
   102         secondBlackView.backgroundColor = [UIColor blackColor];
   107         secondBlackView.backgroundColor = [UIColor blackColor];
   103         secondBlackView.opaque = YES;
   108         secondBlackView.opaque = YES;
   104         secondBlackView.tag = SECONDBLACKVIEW_TAG;
   109         secondBlackView.tag = SECONDBLACKVIEW_TAG;
   105         secondBlackView.alpha = 0;
   110         secondBlackView.alpha = 0;
   106         [self.uiwindow addSubview:secondBlackView];
   111         [self.uiwindow addSubview:secondBlackView];
   107         [UIView beginAnimations:@"fading to game" context:NULL];
   112         [UIView beginAnimations:@"fading to game second" context:NULL];
   108         [UIView setAnimationDuration:1];
   113         [UIView setAnimationDuration:1];
   109         secondBlackView.alpha = 1;
   114         secondBlackView.alpha = 1;
   110         [UIView commitAnimations];
   115         [UIView commitAnimations];
   111         [secondBlackView release];
   116         [secondBlackView release];
   112     }
   117     }
       
   118     [blackView release];
   113 
   119 
   114     // pull out useful configuration info from various files
   120     // pull out useful configuration info from various files
   115     GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
   121     GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
   116     NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"];
   122     NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"];
   117     
   123     
   151     OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
   157     OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
   152     overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
   158     overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
   153     overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
   159     overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
   154     
   160     
   155     UIWindow *gameWindow;
   161     UIWindow *gameWindow;
   156     if ([[UIScreen screens] count] > 1)
   162     if (IS_DUALHEAD())
   157         gameWindow = self.uiwindow;
   163         gameWindow = self.uiwindow;
   158     else
   164     else
   159         gameWindow = [[UIApplication sharedApplication] keyWindow];
   165         gameWindow = [[UIApplication sharedApplication] keyWindow];
   160     [gameWindow addSubview:overlayController.view];
   166     [gameWindow addSubview:overlayController.view];
   161     //[overlayController release];
   167     [overlayController release];
   162 }
   168 }
   163 
   169 
   164 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
   170 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
   165 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   171 -(void) applicationDidFinishLaunching:(UIApplication *)application {
   166     [application setStatusBarHidden:YES];
   172     [application setStatusBarHidden:YES];
   179 
   185 
   180     // set working directory to resource path
   186     // set working directory to resource path
   181     [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
   187     [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
   182 
   188 
   183     // check for dual monitor support
   189     // check for dual monitor support
   184     if ([[UIScreen screens] count] > 1) {
   190     if (IS_DUALHEAD()) {
   185         DLog(@"dual head mode ftw");
   191         DLog(@"dual head mode ftw");
   186         self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]];
   192         self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]];
   187         self.secondWindow.backgroundColor = [UIColor blackColor];
   193         self.secondWindow.backgroundColor = [UIColor blackColor];
   188         self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1];
   194         self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1];
   189         UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"];
   195         UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"];