project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
changeset 3648 2477029463ed
parent 3647 0d0df215fb52
child 3649 bc35f8fee587
equal deleted inserted replaced
3647:0d0df215fb52 3648:2477029463ed
    38     
    38     
    39     // save the sdl window (!= uikit window) for future reference
    39     // save the sdl window (!= uikit window) for future reference
    40     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    40     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    41     SDL_VideoDisplay *display = &_this->displays[0];
    41     SDL_VideoDisplay *display = &_this->displays[0];
    42     sdlwindow = display->windows;
    42     sdlwindow = display->windows;
    43     
    43         
    44     [super viewDidLoad];
    44     [super viewDidLoad];
    45 }
    45 }
    46 
    46 
    47 -(void) viewDidUnload {
    47 -(void) viewDidUnload {
    48     self.menuList = nil;
    48     self.menuList = nil;
    51 }
    51 }
    52 
    52 
    53 -(void) dealloc {
    53 -(void) dealloc {
    54     [menuList release];
    54     [menuList release];
    55     [super dealloc];
    55     [super dealloc];
       
    56 }
       
    57 
       
    58 #pragma mark -
       
    59 #pragma mark animating
       
    60 -(void) present {
       
    61     CGRect screen = [[UIScreen mainScreen] bounds];
       
    62     self.view.backgroundColor = [UIColor clearColor];
       
    63     self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
       
    64     
       
    65     [UIView beginAnimations:@"showing popover" context:NULL];
       
    66     [UIView setAnimationDuration:0.35];
       
    67     self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
       
    68     [UIView commitAnimations];
       
    69 }
       
    70 
       
    71 -(void) dismiss {
       
    72     CGRect screen = [[UIScreen mainScreen] bounds];
       
    73     [UIView beginAnimations:@"hiding popover" context:NULL];
       
    74     [UIView setAnimationDuration:0.35];
       
    75     self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
       
    76     [UIView commitAnimations];
       
    77         
       
    78     [self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
       
    79     
       
    80     [self removeChat];
    56 }
    81 }
    57 
    82 
    58 #pragma mark -
    83 #pragma mark -
    59 #pragma mark tableView methods
    84 #pragma mark tableView methods
    60 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    85 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    85         case 0:
   110         case 0:
    86             HW_pause();
   111             HW_pause();
    87             isPaused = !isPaused;
   112             isPaused = !isPaused;
    88             break;
   113             break;
    89         case 1:
   114         case 1:
    90             HW_chat();
   115             if (SDL_iPhoneKeyboardIsShown(sdlwindow))
    91             SDL_iPhoneKeyboardShow(sdlwindow);
   116                 [self removeChat];
       
   117             else {
       
   118                 HW_chat();
       
   119                 SDL_iPhoneKeyboardShow(sdlwindow);
       
   120             }
    92             break;
   121             break;
    93         case 2:
   122         case 2:
    94             // expand the view (and table) so that the actionsheet can be selected on the iPhone
   123             // expand the view (and table) so that the actionsheet can be selected on the iPhone
    95             if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
   124             if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
       
   125                 CGRect screen = [[UIScreen mainScreen] bounds];
    96                 [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
   126                 [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
    97                 [UIView beginAnimations:@"table width more" context:NULL];
   127                 [UIView beginAnimations:@"table width more" context:NULL];
    98                 [UIView setAnimationDuration:0.2];
   128                 [UIView setAnimationDuration:0.2];
    99                 self.view.frame = CGRectMake(0, 0, 480, 320);
   129                 self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
   100                 [UIView commitAnimations];
   130                 [UIView commitAnimations];
   101             }
   131             }
   102             actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
   132             actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
   103                                                       delegate:self
   133                                                       delegate:self
   104                                              cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
   134                                              cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
   116     }
   146     }
   117     
   147     
   118     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   148     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   119 }
   149 }
   120 
   150 
       
   151 -(void) removeChat {
       
   152     HW_chatEnd();
       
   153     if (SDL_iPhoneKeyboardIsShown(sdlwindow))
       
   154         SDL_iPhoneKeyboardHide(sdlwindow);
       
   155 }
       
   156 
   121 #pragma mark -
   157 #pragma mark -
   122 #pragma mark actionSheet methods
   158 #pragma mark actionSheet methods
   123 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   159 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   124     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
   160     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
   125         [UIView beginAnimations:@"table width less" context:NULL];
   161         [UIView beginAnimations:@"table width less" context:NULL];