author | koda |
Sat, 05 Feb 2011 15:45:44 +0100 | |
changeset 4920 | bc3c077e15a2 |
parent 4912 | 862b134284b2 |
child 4924 | 616b618814b5 |
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]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
85 |
} |
3697 | 86 |
|
3648 | 87 |
[self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35]; |
3697 | 88 |
|
4920 | 89 |
HW_chatEnd(); |
90 |
SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow()); |
|
3648 | 91 |
} |
92 |
||
93 |
#pragma mark - |
|
3547 | 94 |
#pragma mark tableView methods |
95 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
96 |
return 1; |
|
97 |
} |
|
98 |
||
99 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
100 |
return 3; |
|
101 |
} |
|
102 |
||
103 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
104 |
static NSString *cellIdentifier = @"CellIdentifier"; |
|
3697 | 105 |
|
3547 | 106 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier]; |
107 |
if (nil == cell) { |
|
108 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
109 |
reuseIdentifier:cellIdentifier] autorelease]; |
|
110 |
} |
|
4920 | 111 |
cell.textLabel.text = [self.menuList objectAtIndex:[indexPath row]]; |
3697 | 112 |
|
3996 | 113 |
if (IS_IPAD()) |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3667
diff
changeset
|
114 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
3697 | 115 |
|
3547 | 116 |
return cell; |
117 |
} |
|
118 |
||
119 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
120 |
UIActionSheet *actionSheet; |
|
3697 | 121 |
|
3547 | 122 |
switch ([indexPath row]) { |
123 |
case 0: |
|
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3737
diff
changeset
|
124 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"show help ingame" object:nil]; |
3547 | 125 |
break; |
126 |
case 1: |
|
4920 | 127 |
HW_chat(); |
128 |
SDL_iPhoneKeyboardShow((SDL_Window *)HW_getSDLWindow()); |
|
3547 | 129 |
break; |
130 |
case 2: |
|
131 |
// 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
|
132 |
if (IS_IPAD() == NO) { |
3648 | 133 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
3547 | 134 |
[self.tableView deselectRowAtIndexPath:indexPath animated:NO]; |
135 |
[UIView beginAnimations:@"table width more" context:NULL]; |
|
136 |
[UIView setAnimationDuration:0.2]; |
|
3648 | 137 |
self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width); |
3547 | 138 |
[UIView commitAnimations]; |
139 |
} |
|
140 |
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") |
|
141 |
delegate:self |
|
142 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") |
|
143 |
destructiveButtonTitle:NSLocalizedString(@"Of course!", @"") |
|
144 |
otherButtonTitles:nil]; |
|
145 |
[actionSheet showInView:self.view]; |
|
146 |
[actionSheet release]; |
|
3697 | 147 |
|
3547 | 148 |
break; |
149 |
default: |
|
3660 | 150 |
DLog(@"Warning: unset case value in section!"); |
3547 | 151 |
break; |
152 |
} |
|
3697 | 153 |
|
3547 | 154 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
155 |
} |
|
156 |
||
157 |
#pragma mark - |
|
158 |
#pragma mark actionSheet methods |
|
159 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
160 |
if (IS_IPAD() == NO) { |
3649 | 161 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
3547 | 162 |
[UIView beginAnimations:@"table width less" context:NULL]; |
163 |
[UIView setAnimationDuration:0.2]; |
|
3649 | 164 |
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170); |
3547 | 165 |
[UIView commitAnimations]; |
166 |
} |
|
3697 | 167 |
|
3924 | 168 |
if ([actionSheet cancelButtonIndex] != buttonIndex) |
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
|
169 |
HW_terminate(NO); |
3547 | 170 |
} |
171 |
||
172 |
@end |