3090
|
1 |
//
|
|
2 |
// popupMenuViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 25/03/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "popupMenuViewController.h"
|
|
10 |
#import "PascalImports.h"
|
|
11 |
|
|
12 |
@implementation popupMenuViewController
|
3091
|
13 |
@synthesize menuTable, menuList;
|
3090
|
14 |
|
|
15 |
/*
|
|
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 {
|
|
18 |
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
|
|
19 |
// Custom initialization
|
|
20 |
}
|
|
21 |
return self;
|
|
22 |
}
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
|
27 |
- (void)viewDidLoad {
|
|
28 |
[super viewDidLoad];
|
|
29 |
}
|
|
30 |
*/
|
|
31 |
|
|
32 |
|
3091
|
33 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
3090
|
34 |
// Overriden to allow any orientation.
|
|
35 |
return YES;
|
|
36 |
}
|
|
37 |
|
|
38 |
|
3091
|
39 |
-(void) didReceiveMemoryWarning {
|
3090
|
40 |
// Releases the view if it doesn't have a superview.
|
|
41 |
[super didReceiveMemoryWarning];
|
|
42 |
|
|
43 |
// Release any cached data, images, etc that aren't in use.
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
-(void) viewDidLoad {
|
|
48 |
isPaused = NO;
|
|
49 |
menuTable.allowsSelection = YES;
|
3091
|
50 |
menuList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"Pause Game", @""), NSLocalizedString(@"Chat", @""), NSLocalizedString(@"End Game", @""),nil];
|
3090
|
51 |
[super viewDidLoad];
|
|
52 |
}
|
|
53 |
|
|
54 |
|
3091
|
55 |
-(void) dealloc {
|
|
56 |
[menuList release];
|
3090
|
57 |
[menuTable release];
|
|
58 |
[super dealloc];
|
|
59 |
}
|
|
60 |
|
|
61 |
#pragma mark -
|
|
62 |
#pragma mark TableView Methods
|
|
63 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
64 |
return 1;
|
|
65 |
}
|
|
66 |
|
|
67 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
68 |
return 3;
|
|
69 |
}
|
|
70 |
|
|
71 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
72 |
static NSString *cellIdentifier = @"CellIdentifier";
|
|
73 |
|
|
74 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
|
75 |
if (nil == cell) {
|
|
76 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
77 |
reuseIdentifier:cellIdentifier] autorelease];
|
3091
|
78 |
cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
|
3090
|
79 |
}
|
|
80 |
|
|
81 |
return cell;
|
|
82 |
}
|
|
83 |
|
3091
|
84 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3090
|
85 |
UIActionSheet *actionSheet;
|
|
86 |
|
|
87 |
switch ([indexPath row]) {
|
|
88 |
case 0:
|
|
89 |
HW_pause();
|
|
90 |
isPaused = !isPaused;
|
|
91 |
break;
|
|
92 |
case 1:
|
|
93 |
HW_chat();
|
|
94 |
break;
|
|
95 |
case 2:
|
|
96 |
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
|
|
97 |
delegate:self
|
|
98 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
|
|
99 |
destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"")
|
|
100 |
otherButtonTitles:nil];
|
|
101 |
[actionSheet showInView:self.view];
|
|
102 |
[actionSheet release];
|
|
103 |
|
|
104 |
if (!isPaused)
|
|
105 |
HW_pause();
|
|
106 |
break;
|
|
107 |
default:
|
|
108 |
NSLog(@"Warning: unset case value in section!");
|
|
109 |
break;
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
3091
|
113 |
-(void) tableView:(UITableView *)aTableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3090
|
114 |
[aTableView deselectRowAtIndexPath: indexPath animated:YES];
|
|
115 |
}
|
|
116 |
|
|
117 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
|
|
118 |
if ([actionSheet cancelButtonIndex] != buttonIndex)
|
|
119 |
HW_terminate(NO);
|
|
120 |
else
|
|
121 |
if (!isPaused)
|
|
122 |
HW_pause();
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
@end
|