author | koda |
Sat, 05 Feb 2011 22:22:16 +0100 | |
changeset 4924 | 616b618814b5 |
parent 4920 | bc3c077e15a2 |
child 4935 | 27fb500dd6b1 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 25/03/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
22 |
#import "SDL_uikitappdelegate.h" |
|
3647
0d0df215fb52
making chat work... (keyboard support is heavily broken in sdl upstream)
koda
parents:
3598
diff
changeset
|
23 |
#import "InGameMenuViewController.h" |
3547 | 24 |
#import "PascalImports.h" |
25 |
#import "CommodityFunctions.h" |
|
26 |
#import "SDL_sysvideo.h" |
|
3922
44804043b691
iPad Video Out support (+less warnings +code update for latest SDL)
koda
parents:
3829
diff
changeset
|
27 |
#import "SDL_uikitkeyboard.h" |
3547 | 28 |
|
3647
0d0df215fb52
making chat work... (keyboard support is heavily broken in sdl upstream)
koda
parents:
3598
diff
changeset
|
29 |
@implementation InGameMenuViewController |
3547 | 30 |
@synthesize menuList; |
31 |
||
32 |
||
33 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
34 |
return rotationManager(interfaceOrientation); |
|
35 |
} |
|
36 |
||
37 |
-(void) didReceiveMemoryWarning { |
|
3971 | 38 |
self.menuList = nil; |
3547 | 39 |
[super didReceiveMemoryWarning]; |
40 |
} |
|
41 |
||
42 |
-(void) viewDidLoad { |
|
43 |
NSArray *array = [[NSArray alloc] initWithObjects: |
|
3701 | 44 |
NSLocalizedString(@"Show Help", @""), |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3701
diff
changeset
|
45 |
NSLocalizedString(@"Tag", @""), |
3547 | 46 |
NSLocalizedString(@"End Game", @""), |
47 |
nil]; |
|
48 |
self.menuList = array; |
|
49 |
[array release]; |
|
3697 | 50 |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3924
diff
changeset
|
51 |
[super viewDidLoad]; |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3924
diff
changeset
|
52 |
} |
3697 | 53 |
|
3547 | 54 |
-(void) viewDidUnload { |
55 |
self.menuList = nil; |
|
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3660
diff
changeset
|
56 |
MSG_DIDUNLOAD(); |
3547 | 57 |
[super viewDidUnload]; |
58 |
} |
|
59 |
||
60 |
-(void) dealloc { |
|
61 |
[menuList release]; |
|
62 |
[super dealloc]; |
|
63 |
} |
|
64 |
||
65 |
#pragma mark - |
|
3648 | 66 |
#pragma mark animating |
67 |
-(void) present { |
|
68 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
|
69 |
self.view.backgroundColor = [UIColor clearColor]; |
|
70 |
self.view.frame = CGRectMake(screen.size.height, 0, 200, 170); |
|
3697 | 71 |
|
3648 | 72 |
[UIView beginAnimations:@"showing popover" context:NULL]; |
73 |
[UIView setAnimationDuration:0.35]; |
|
74 |
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170); |
|
75 |
[UIView commitAnimations]; |
|
76 |
} |
|
77 |
||
78 |
-(void) dismiss { |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
79 |
if (IS_IPAD() == NO) { |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
80 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
81 |
[UIView beginAnimations:@"hiding popover" context:NULL]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
82 |
[UIView setAnimationDuration:0.35]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
83 |
self.view.frame = CGRectMake(screen.size.height, 0, 200, 170); |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
84 |
[UIView commitAnimations]; |
4924 | 85 |
[self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35]; |
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
86 |
} |
3697 | 87 |
|
4920 | 88 |
HW_chatEnd(); |
89 |
SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow()); |
|
3648 | 90 |
} |
91 |
||
92 |
#pragma mark - |
|
3547 | 93 |
#pragma mark tableView methods |
94 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
95 |
return 1; |
|
96 |
} |
|
97 |
||
98 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
99 |
return 3; |
|
100 |
} |
|
101 |
||
102 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
103 |
static NSString *cellIdentifier = @"CellIdentifier"; |
|
3697 | 104 |
|
3547 | 105 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier]; |
106 |
if (nil == cell) { |
|
107 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
108 |
reuseIdentifier:cellIdentifier] autorelease]; |
|
109 |
} |
|
4920 | 110 |
cell.textLabel.text = [self.menuList objectAtIndex:[indexPath row]]; |
3697 | 111 |
|
3996 | 112 |
if (IS_IPAD()) |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3667
diff
changeset
|
113 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
3697 | 114 |
|
3547 | 115 |
return cell; |
116 |
} |
|
117 |
||
118 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
119 |
UIActionSheet *actionSheet; |
|
3697 | 120 |
|
3547 | 121 |
switch ([indexPath row]) { |
122 |
case 0: |
|
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3737
diff
changeset
|
123 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"show help ingame" object:nil]; |
3547 | 124 |
break; |
125 |
case 1: |
|
4920 | 126 |
HW_chat(); |
127 |
SDL_iPhoneKeyboardShow((SDL_Window *)HW_getSDLWindow()); |
|
3547 | 128 |
break; |
129 |
case 2: |
|
130 |
// expand the view (and table) so that the actionsheet can be selected on the iPhone |
|
4008
d87619de120d
fix an annoying bug that didn't allow returning to the ifrontend
koda
parents:
3996
diff
changeset
|
131 |
if (IS_IPAD() == NO) { |
3648 | 132 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
3547 | 133 |
[self.tableView deselectRowAtIndexPath:indexPath animated:NO]; |
134 |
[UIView beginAnimations:@"table width more" context:NULL]; |
|
135 |
[UIView setAnimationDuration:0.2]; |
|
3648 | 136 |
self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width); |
3547 | 137 |
[UIView commitAnimations]; |
138 |
} |
|
139 |
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") |
|
140 |
delegate:self |
|
141 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") |
|
142 |
destructiveButtonTitle:NSLocalizedString(@"Of course!", @"") |
|
143 |
otherButtonTitles:nil]; |
|
144 |
[actionSheet showInView:self.view]; |
|
145 |
[actionSheet release]; |
|
3697 | 146 |
|
3547 | 147 |
break; |
148 |
default: |
|
3660 | 149 |
DLog(@"Warning: unset case value in section!"); |
3547 | 150 |
break; |
151 |
} |
|
3697 | 152 |
|
3547 | 153 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
154 |
} |
|
155 |
||
156 |
#pragma mark - |
|
157 |
#pragma mark actionSheet methods |
|
158 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
159 |
if (IS_IPAD() == NO) { |
3649 | 160 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
3547 | 161 |
[UIView beginAnimations:@"table width less" context:NULL]; |
162 |
[UIView setAnimationDuration:0.2]; |
|
3649 | 163 |
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170); |
3547 | 164 |
[UIView commitAnimations]; |
165 |
} |
|
3697 | 166 |
|
4924 | 167 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
168 |
if (IS_DUALHEAD()) |
|
169 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"remove overlay" object:nil]; |
|
4861
91f889289a47
(ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents:
4358
diff
changeset
|
170 |
HW_terminate(NO); |
4924 | 171 |
} |
3547 | 172 |
} |
173 |
||
174 |
@end |