cocoaTouch/popupMenuViewController.m
changeset 3091 9d05c8000ed4
parent 3090 51629e69da51
child 3113 2829ea0dd47c
equal deleted inserted replaced
3090:51629e69da51 3091:9d05c8000ed4
     8 
     8 
     9 #import "popupMenuViewController.h"
     9 #import "popupMenuViewController.h"
    10 #import "PascalImports.h"
    10 #import "PascalImports.h"
    11 
    11 
    12 @implementation popupMenuViewController
    12 @implementation popupMenuViewController
    13 @synthesize menuTable;
    13 @synthesize menuTable, menuList;
    14 
    14 
    15 /*
    15 /*
    16  // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    16  // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    17 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    17 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    18     if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
    18     if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
    28     [super viewDidLoad];
    28     [super viewDidLoad];
    29 }
    29 }
    30 */
    30 */
    31 
    31 
    32 
    32 
    33 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    33 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    34     // Overriden to allow any orientation.
    34     // Overriden to allow any orientation.
    35     return YES;
    35     return YES;
    36 }
    36 }
    37 
    37 
    38 
    38 
    39 - (void)didReceiveMemoryWarning {
    39 -(void) didReceiveMemoryWarning {
    40     // Releases the view if it doesn't have a superview.
    40     // Releases the view if it doesn't have a superview.
    41     [super didReceiveMemoryWarning];
    41     [super didReceiveMemoryWarning];
    42     
    42     
    43     // Release any cached data, images, etc that aren't in use.
    43     // Release any cached data, images, etc that aren't in use.
    44 }
    44 }
    45 
    45 
    46 
    46 
    47 -(void) viewDidLoad {
    47 -(void) viewDidLoad {
    48     isPaused = NO;
    48     isPaused = NO;
    49     menuTable.allowsSelection = YES;
    49     menuTable.allowsSelection = YES;
       
    50     menuList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"Pause Game", @""), NSLocalizedString(@"Chat", @""), NSLocalizedString(@"End Game", @""),nil];
    50     [super viewDidLoad];
    51     [super viewDidLoad];
    51 }
    52 }
    52 
    53 
    53 
    54 
    54 - (void)dealloc {
    55 -(void) dealloc {
       
    56     [menuList release];
    55     [menuTable release];
    57     [menuTable release];
    56     [super dealloc];
    58     [super dealloc];
    57 }
    59 }
    58 
    60 
    59 #pragma mark -
    61 #pragma mark -
    71 	
    73 	
    72 	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    74 	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    73     if (nil == cell) {
    75     if (nil == cell) {
    74 		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    76 		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    75                                        reuseIdentifier:cellIdentifier] autorelease];
    77                                        reuseIdentifier:cellIdentifier] autorelease];
       
    78         cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
    76 	}
    79 	}
    77 	
       
    78 	switch ([indexPath row]) {
       
    79 		case 0:
       
    80             cell.textLabel.text = NSLocalizedString(@"Pause Game", @"");
       
    81             //cell.accessoryView = username;
       
    82             break;
       
    83         case 1:
       
    84 			cell.textLabel.text = NSLocalizedString(@"Chat", @"");
       
    85             //cell.accessoryView = password;
       
    86             break;
       
    87         case 2:
       
    88 			cell.textLabel.text = NSLocalizedString(@"End Game", @"");
       
    89             break;
       
    90         default:
       
    91 			NSLog(@"Warning: unset case value in kNetworkFields section!");
       
    92 			break;
       
    93     }
       
    94 	
    80 	
    95 	return cell;
    81 	return cell;
    96 }
    82 }
    97 
    83 
    98 - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    84 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    99     UIActionSheet *actionSheet;
    85     UIActionSheet *actionSheet;
   100     
    86     
   101     switch ([indexPath row]) {
    87     switch ([indexPath row]) {
   102 		case 0:
    88 		case 0:
   103             HW_pause();
    89             HW_pause();
   122 			NSLog(@"Warning: unset case value in section!");
   108 			NSLog(@"Warning: unset case value in section!");
   123 			break;
   109 			break;
   124     }
   110     }
   125 }
   111 }
   126 
   112 
   127 - (void)tableView:(UITableView *)aTableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
   113 -(void) tableView:(UITableView *)aTableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
   128     [aTableView deselectRowAtIndexPath: indexPath animated:YES];
   114     [aTableView deselectRowAtIndexPath: indexPath animated:YES];
   129 }
   115 }
   130 
   116 
   131 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   117 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   132 	if ([actionSheet cancelButtonIndex] != buttonIndex)
   118 	if ([actionSheet cancelButtonIndex] != buttonIndex)