project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
changeset 3668 3f7a95234d8a
parent 3667 9359a70df013
child 3697 d5b30d6373fc
equal deleted inserted replaced
3667:9359a70df013 3668:3f7a95234d8a
    24     // Releases the view if it doesn't have a superview.
    24     // Releases the view if it doesn't have a superview.
    25     [super didReceiveMemoryWarning];
    25     [super didReceiveMemoryWarning];
    26 }
    26 }
    27 
    27 
    28 -(void) viewDidLoad {
    28 -(void) viewDidLoad {
    29     isPaused = NO;
       
    30 
       
    31     NSArray *array = [[NSArray alloc] initWithObjects:
    29     NSArray *array = [[NSArray alloc] initWithObjects:
    32                       NSLocalizedString(@"Pause Game", @""),
    30                       NSLocalizedString(@"Return to Game", @""),
    33                       NSLocalizedString(@"Chat", @""),
    31                       NSLocalizedString(@"Chat", @""),
    34                       NSLocalizedString(@"End Game", @""),
    32                       NSLocalizedString(@"End Game", @""),
    35                       nil];
    33                       nil];
    36     self.menuList = array;
    34     self.menuList = array;
    37     [array release];
    35     [array release];
    98         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    96         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    99                                        reuseIdentifier:cellIdentifier] autorelease];
    97                                        reuseIdentifier:cellIdentifier] autorelease];
   100     }
    98     }
   101     cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
    99     cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
   102     
   100     
       
   101     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
       
   102         cell.textLabel.textAlignment = UITextAlignmentCenter;
       
   103     
   103     return cell;
   104     return cell;
   104 }
   105 }
   105 
   106 
   106 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   107 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   107     UIActionSheet *actionSheet;
   108     UIActionSheet *actionSheet;
   108     
   109     
   109     switch ([indexPath row]) {
   110     switch ([indexPath row]) {
   110         case 0:
   111         case 0:
   111             HW_pause();
   112             HW_pause();
   112             isPaused = !isPaused;
       
   113             break;
   113             break;
   114         case 1:
   114         case 1:
   115             if (SDL_iPhoneKeyboardIsShown(sdlwindow))
   115             if (SDL_iPhoneKeyboardIsShown(sdlwindow))
   116                 [self removeChat];
   116                 [self removeChat];
   117             else {
   117             else {
   135                                         destructiveButtonTitle:NSLocalizedString(@"Of course!", @"")
   135                                         destructiveButtonTitle:NSLocalizedString(@"Of course!", @"")
   136                                              otherButtonTitles:nil];
   136                                              otherButtonTitles:nil];
   137             [actionSheet showInView:self.view];
   137             [actionSheet showInView:self.view];
   138             [actionSheet release];
   138             [actionSheet release];
   139             
   139             
   140             if (!isPaused) 
       
   141                 HW_pause();
       
   142             break;
   140             break;
   143         default:
   141         default:
   144             DLog(@"Warning: unset case value in section!");
   142             DLog(@"Warning: unset case value in section!");
   145             break;
   143             break;
   146     }
   144     }
   165         self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
   163         self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
   166         [UIView commitAnimations];
   164         [UIView commitAnimations];
   167     }
   165     }
   168     
   166     
   169     if ([actionSheet cancelButtonIndex] != buttonIndex)
   167     if ([actionSheet cancelButtonIndex] != buttonIndex)
   170         HW_terminate(NO);
   168         HW_terminate(NO);     
   171     else
       
   172         if (!isPaused) 
       
   173             HW_pause();     
       
   174 }
   169 }
   175 
   170 
   176 @end
   171 @end