project_files/HedgewarsMobile/Classes/GameConfigViewController.m
changeset 3996 eb549fd864a5
parent 3984 d92509c2f255
child 4144 cda2685feeb4
equal deleted inserted replaced
3995:360332f8785f 3996:eb549fd864a5
    38 }
    38 }
    39 
    39 
    40 -(IBAction) buttonPressed:(id) sender {
    40 -(IBAction) buttonPressed:(id) sender {
    41     // works even if it's not actually a button
    41     // works even if it's not actually a button
    42     UIButton *theButton;
    42     UIButton *theButton;
    43     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    43     if (IS_IPAD())
    44         theButton = [[(NSNotification *)sender userInfo] objectForKey:@"sender"];
    44         theButton = [[(NSNotification *)sender userInfo] objectForKey:@"sender"];
    45     else
    45     else
    46         theButton = (UIButton *)sender;
    46         theButton = (UIButton *)sender;
    47 
    47 
    48     switch (theButton.tag) {
    48     switch (theButton.tag) {
   222         DLog(@"gameconfig data not complete!!");
   222         DLog(@"gameconfig data not complete!!");
   223         [self.parentViewController dismissModalViewControllerAnimated:YES];
   223         [self.parentViewController dismissModalViewControllerAnimated:YES];
   224 
   224 
   225         // present an alert to the user, with an image on the ipad (too big for the iphone)
   225         // present an alert to the user, with an image on the ipad (too big for the iphone)
   226         NSString *msg = NSLocalizedString(@"Something went wrong with your configuration. Please try again.",@"");
   226         NSString *msg = NSLocalizedString(@"Something went wrong with your configuration. Please try again.",@"");
   227         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   227         if (IS_IPAD())
   228             msg = [msg stringByAppendingString:@"\n\n\n\n\n\n\n\n"];    // this makes space for the image
   228             msg = [msg stringByAppendingString:@"\n\n\n\n\n\n\n\n"];    // this makes space for the image
   229 
   229 
   230         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops"
   230         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops"
   231                                                         message:msg
   231                                                         message:msg
   232                                                        delegate:nil
   232                                                        delegate:nil
   233                                               cancelButtonTitle:@"Ok"
   233                                               cancelButtonTitle:@"Ok"
   234                                               otherButtonTitles:nil];
   234                                               otherButtonTitles:nil];
   235 
   235 
   236         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   236         if (IS_IPAD()) {
   237             UIImageView *deniedImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"denied.png"]];
   237             UIImageView *deniedImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"denied.png"]];
   238             deniedImg.frame = CGRectMake(25, 80, 240, 160);
   238             deniedImg.frame = CGRectMake(25, 80, 240, 160);
   239             [alert addSubview:deniedImg];
   239             [alert addSubview:deniedImg];
   240             [deniedImg release];
   240             [deniedImg release];
   241         }
   241         }
   283     self.view.backgroundColor = [UIColor blackColor];
   283     self.view.backgroundColor = [UIColor blackColor];
   284 
   284 
   285     CGRect screen = [[UIScreen mainScreen] bounds];
   285     CGRect screen = [[UIScreen mainScreen] bounds];
   286     self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
   286     self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
   287 
   287 
   288     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   288     if (IS_IPAD()) {
   289         [[NSNotificationCenter defaultCenter] addObserver:self
   289         [[NSNotificationCenter defaultCenter] addObserver:self
   290                                                  selector:@selector(buttonPressed:)
   290                                                  selector:@selector(buttonPressed:)
   291                                                      name:@"buttonPressed"
   291                                                      name:@"buttonPressed"
   292                                                    object:nil];
   292                                                    object:nil];
   293         srandom(time(NULL));
   293         srandom(time(NULL));
   344 
   344 
   345     [super viewDidLoad];
   345     [super viewDidLoad];
   346 }
   346 }
   347 
   347 
   348 -(void) viewWillAppear:(BOOL)animated {
   348 -(void) viewWillAppear:(BOOL)animated {
   349     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   349     if (IS_IPAD())
   350         [NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil];
   350         [NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil];
   351 
   351 
   352     [self.mapConfigViewController viewWillAppear:animated];
   352     [self.mapConfigViewController viewWillAppear:animated];
   353     [self.teamConfigViewController viewWillAppear:animated];
   353     [self.teamConfigViewController viewWillAppear:animated];
   354     [self.schemeWeaponConfigViewController viewWillAppear:animated];
   354     [self.schemeWeaponConfigViewController viewWillAppear:animated];