project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m
changeset 6624 e049b5bb0ad1
parent 6362 ceacd1b61833
child 6700 e04da46ee43c
equal deleted inserted replaced
6623:6bf169f1e97c 6624:e049b5bb0ad1
    32 }
    32 }
    33 
    33 
    34 @end
    34 @end
    35 
    35 
    36 @implementation HedgewarsAppDelegate
    36 @implementation HedgewarsAppDelegate
    37 @synthesize mainViewController, uiwindow, secondWindow;
    37 @synthesize mainViewController, uiwindow;
    38 
    38 
    39 #pragma mark -
    39 #pragma mark -
    40 #pragma mark AppDelegate methods
    40 #pragma mark AppDelegate methods
    41 -(id) init {
    41 -(id) init {
    42     if (self = [super init]){
    42     if (self = [super init]){
    43         mainViewController = nil;
    43         mainViewController = nil;
    44         uiwindow = nil;
    44         uiwindow = nil;
    45         secondWindow = nil;
       
    46     }
    45     }
    47     return self;
    46     return self;
    48 }
    47 }
    49 
    48 
    50 -(void) dealloc {
    49 -(void) dealloc {
    51     [mainViewController release];
    50     [mainViewController release];
    52     [uiwindow release];
    51     [uiwindow release];
    53     [secondWindow release];
       
    54     [super dealloc];
    52     [super dealloc];
    55 }
    53 }
    56 
    54 
    57 // override the direct execution of SDL_main to allow us to implement our own frontend
    55 // override the direct execution of SDL_main to allow us to implement our own frontend
    58 -(void) postFinishLaunch {
    56 -(void) postFinishLaunch {
    65 
    63 
    66     [self.uiwindow addSubview:self.mainViewController.view];
    64     [self.uiwindow addSubview:self.mainViewController.view];
    67     [self.mainViewController release];
    65     [self.mainViewController release];
    68     self.uiwindow.backgroundColor = [UIColor blackColor];
    66     self.uiwindow.backgroundColor = [UIColor blackColor];
    69     [self.uiwindow makeKeyAndVisible];
    67     [self.uiwindow makeKeyAndVisible];
    70 
       
    71     // check for dual monitor support
       
    72     if (IS_DUALHEAD()) {
       
    73         DLog(@"Dualhead mode");
       
    74         self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]];
       
    75         self.secondWindow.backgroundColor = [UIColor blackColor];
       
    76         self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1];
       
    77         UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"];
       
    78         UIImageView *titleView = [[UIImageView alloc] initWithImage:titleImage];
       
    79         titleView.center = self.secondWindow.center;
       
    80         [self.secondWindow addSubview:titleView];
       
    81         [titleView release];
       
    82         [self.secondWindow makeKeyAndVisible];
       
    83     }
       
    84 }
    68 }
    85 
    69 
    86 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
    70 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
    87     [HWUtils releaseCache];
    71     [HWUtils releaseCache];
    88     // don't stop music if it is playing
    72     // don't stop music if it is playing