author | koda |
Sat, 12 Nov 2011 18:38:21 +0100 | |
branch | hedgeroid |
changeset 6341 | ccc0a58e123d |
parent 6269 | 57523ab57218 |
child 6409 | ca93f38a1aab |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 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 |
|
3647
0d0df215fb52
making chat work... (keyboard support is heavily broken in sdl upstream)
koda
parents:
3598
diff
changeset
|
22 |
#import "InGameMenuViewController.h" |
3547 | 23 |
#import "SDL_sysvideo.h" |
3922
44804043b691
iPad Video Out support (+less warnings +code update for latest SDL)
koda
parents:
3829
diff
changeset
|
24 |
#import "SDL_uikitkeyboard.h" |
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6076
diff
changeset
|
25 |
|
6260 | 26 |
//FIXME: add a proper #import when this is exposed in SDL |
27 |
extern UIView *SDL_getUikitView(void *); |
|
4935 | 28 |
|
29 |
#define VIEW_HEIGHT 200 |
|
3547 | 30 |
|
3647
0d0df215fb52
making chat work... (keyboard support is heavily broken in sdl upstream)
koda
parents:
3598
diff
changeset
|
31 |
@implementation InGameMenuViewController |
3547 | 32 |
|
33 |
||
34 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
35 |
return rotationManager(interfaceOrientation); |
|
36 |
} |
|
37 |
||
38 |
#pragma mark - |
|
3648 | 39 |
#pragma mark animating |
40 |
-(void) present { |
|
41 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
|
42 |
self.view.backgroundColor = [UIColor clearColor]; |
|
4935 | 43 |
self.view.frame = CGRectMake(screen.size.height, 0, 200, VIEW_HEIGHT); |
3697 | 44 |
|
3648 | 45 |
[UIView beginAnimations:@"showing popover" context:NULL]; |
46 |
[UIView setAnimationDuration:0.35]; |
|
4935 | 47 |
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, VIEW_HEIGHT); |
3648 | 48 |
[UIView commitAnimations]; |
49 |
} |
|
50 |
||
51 |
-(void) dismiss { |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
52 |
if (IS_IPAD() == NO) { |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
53 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
54 |
[UIView beginAnimations:@"hiding popover" context:NULL]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
55 |
[UIView setAnimationDuration:0.35]; |
4935 | 56 |
self.view.frame = CGRectMake(screen.size.height, 0, 200, VIEW_HEIGHT); |
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
57 |
[UIView commitAnimations]; |
4924 | 58 |
[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
|
59 |
} |
3697 | 60 |
|
5166
d1eb1560b4d5
and now for something completely different, overlay refactoring!
koda
parents:
5156
diff
changeset
|
61 |
SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow()); |
3648 | 62 |
} |
63 |
||
64 |
#pragma mark - |
|
3547 | 65 |
#pragma mark tableView methods |
66 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
67 |
return 1; |
|
68 |
} |
|
69 |
||
70 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
5711 | 71 |
return 3; |
3547 | 72 |
} |
73 |
||
74 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
75 |
static NSString *cellIdentifier = @"CellIdentifier"; |
|
3697 | 76 |
|
6269 | 77 |
NSInteger row = [indexPath row]; |
78 |
NSString *cellTitle; |
|
79 |
if (row == 0) |
|
80 |
cellTitle = NSLocalizedString(@"Show Help", @""); |
|
81 |
else if (row == 1) |
|
82 |
cellTitle = NSLocalizedString(@"Tag", @""); |
|
83 |
else |
|
84 |
cellTitle = NSLocalizedString(@"End Game", @""); |
|
85 |
||
3547 | 86 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier]; |
87 |
if (nil == cell) { |
|
88 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
89 |
reuseIdentifier:cellIdentifier] autorelease]; |
|
90 |
} |
|
6269 | 91 |
cell.textLabel.text = cellTitle; |
3697 | 92 |
|
3996 | 93 |
if (IS_IPAD()) |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3667
diff
changeset
|
94 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
3697 | 95 |
|
3547 | 96 |
return cell; |
97 |
} |
|
98 |
||
99 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
100 |
UIActionSheet *actionSheet; |
|
3697 | 101 |
|
3547 | 102 |
switch ([indexPath row]) { |
103 |
case 0: |
|
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3737
diff
changeset
|
104 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"show help ingame" object:nil]; |
4935 | 105 |
|
3547 | 106 |
break; |
107 |
case 1: |
|
4920 | 108 |
HW_chat(); |
109 |
SDL_iPhoneKeyboardShow((SDL_Window *)HW_getSDLWindow()); |
|
4935 | 110 |
|
3547 | 111 |
break; |
112 |
case 2: |
|
113 |
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") |
|
114 |
delegate:self |
|
115 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") |
|
116 |
destructiveButtonTitle:NSLocalizedString(@"Of course!", @"") |
|
117 |
otherButtonTitles:nil]; |
|
6260 | 118 |
[actionSheet showInView:(IS_IPAD() ? self.view : SDL_getUikitView(HW_getSDLWindow()))]; |
3547 | 119 |
[actionSheet release]; |
3697 | 120 |
|
3547 | 121 |
break; |
122 |
default: |
|
3660 | 123 |
DLog(@"Warning: unset case value in section!"); |
3547 | 124 |
break; |
125 |
} |
|
3697 | 126 |
|
3547 | 127 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
128 |
} |
|
129 |
||
130 |
#pragma mark - |
|
131 |
#pragma mark actionSheet methods |
|
132 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
4924 | 133 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
5166
d1eb1560b4d5
and now for something completely different, overlay refactoring!
koda
parents:
5156
diff
changeset
|
134 |
SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow()); |
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
|
135 |
HW_terminate(NO); |
4924 | 136 |
} |
3547 | 137 |
} |
138 |
||
139 |
@end |