cocoaTouch/iPad/PopupMenuViewController.m
changeset 3250 d5cd1a617123
parent 3122 e005359efc59
child 3253 b0b1b1310b7e
equal deleted inserted replaced
3249:74a506c9d71b 3250:d5cd1a617123
     9 #import "SDL_uikitappdelegate.h"
     9 #import "SDL_uikitappdelegate.h"
    10 #import "PopupMenuViewController.h"
    10 #import "PopupMenuViewController.h"
    11 #import "PascalImports.h"
    11 #import "PascalImports.h"
    12 
    12 
    13 @implementation PopupMenuViewController
    13 @implementation PopupMenuViewController
    14 @synthesize menuTable, menuList;
    14 @synthesize menuList;
    15 
       
    16 /*
       
    17  // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
       
    18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
       
    19     if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
       
    20         // Custom initialization
       
    21     }
       
    22     return self;
       
    23 }
       
    24 */
       
    25 
       
    26 /*
       
    27 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
       
    28 - (void)viewDidLoad {
       
    29     [super viewDidLoad];
       
    30 }
       
    31 */
       
    32 
    15 
    33 
    16 
    34 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    17 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    35     // Overriden to allow any orientation.
    18     // Overriden to allow any orientation.
    36     return YES;
    19     return YES;
    37 }
    20 }
    38 
       
    39 
    21 
    40 -(void) didReceiveMemoryWarning {
    22 -(void) didReceiveMemoryWarning {
    41     // Releases the view if it doesn't have a superview.
    23     // Releases the view if it doesn't have a superview.
    42     [super didReceiveMemoryWarning];
    24     [super didReceiveMemoryWarning];
    43     
    25     
    44     // Release any cached data, images, etc that aren't in use.
    26     // Release any cached data, images, etc that aren't in use.
    45 }
    27 }
    46 
    28 
    47 
       
    48 -(void) viewDidLoad {
    29 -(void) viewDidLoad {
    49     isPaused = NO;
    30     isPaused = NO;
    50     menuTable.allowsSelection = YES;
    31     self.tableView.allowsSelection = YES;
       
    32     self.tableView.alwaysBounceVertical = YES;
       
    33     self.tableView.delaysContentTouches = NO;
    51     menuList = [[NSArray alloc] initWithObjects:
    34     menuList = [[NSArray alloc] initWithObjects:
    52                 NSLocalizedString(@"Pause Game", @""),
    35                 NSLocalizedString(@"Pause Game", @""),
    53                 NSLocalizedString(@"Chat", @""),
    36                 NSLocalizedString(@"Chat", @""),
    54                 NSLocalizedString(@"End Game", @""),
    37                 NSLocalizedString(@"End Game", @""),
    55                 nil];
    38                 nil];
    57 }
    40 }
    58 
    41 
    59 
    42 
    60 -(void) dealloc {
    43 -(void) dealloc {
    61     [menuList release];
    44     [menuList release];
    62     [menuTable release];
       
    63     [super dealloc];
    45     [super dealloc];
    64 }
    46 }
    65 
    47 
    66 #pragma mark -
    48 #pragma mark -
    67 #pragma mark TableView Methods
    49 #pragma mark tableView methods
    68 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    50 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    69 	return 1;
    51 	return 1;
    70 }
    52 }
    71 
    53 
    72 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    54 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    78 	
    60 	
    79 	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    61 	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    80     if (nil == cell) {
    62     if (nil == cell) {
    81 		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    63 		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    82                                        reuseIdentifier:cellIdentifier] autorelease];
    64                                        reuseIdentifier:cellIdentifier] autorelease];
    83         cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
       
    84 	}
    65 	}
       
    66     cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
    85 	
    67 	
    86 	return cell;
    68 	return cell;
    87 }
    69 }
    88 
    70 
    89 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    71 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   100             break;
    82             break;
   101         case 2:
    83         case 2:
   102 			actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
    84 			actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
   103                                                       delegate:self
    85                                                       delegate:self
   104                                              cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
    86                                              cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
   105                                         destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"")
    87                                         destructiveButtonTitle:NSLocalizedString(@"Of course!", @"")
   106                                              otherButtonTitles:nil];
    88                                              otherButtonTitles:nil];
   107             [actionSheet showInView:self.view];
    89             [actionSheet showInView:self.view];
   108             [actionSheet release];
    90             [actionSheet release];
   109             
    91             
   110             if (!isPaused) 
    92             if (!isPaused) 
   118 
   100 
   119 -(void) tableView:(UITableView *)aTableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
   101 -(void) tableView:(UITableView *)aTableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
   120     [aTableView deselectRowAtIndexPath: indexPath animated:YES];
   102     [aTableView deselectRowAtIndexPath: indexPath animated:YES];
   121 }
   103 }
   122 
   104 
       
   105 #pragma mark -
       
   106 #pragma mark actionSheet methods
   123 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   107 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   124 	if ([actionSheet cancelButtonIndex] != buttonIndex) {
   108 	if ([actionSheet cancelButtonIndex] != buttonIndex) {
   125         [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissPopover"  object:nil];
   109         [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissPopover"  object:nil];
   126         HW_terminate(NO);
   110         HW_terminate(NO);
   127     }
   111     }