author | Xeli |
Tue, 24 Jan 2012 18:11:56 +0100 | |
changeset 6597 | 814683bbd230 |
parent 6409 | ca93f38a1aab |
child 6700 | e04da46ee43c |
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 |
|
4935 | 26 |
|
27 |
#define VIEW_HEIGHT 200 |
|
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 |
|
31 |
||
32 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
33 |
return rotationManager(interfaceOrientation); |
|
34 |
} |
|
35 |
||
36 |
#pragma mark - |
|
3648 | 37 |
#pragma mark animating |
38 |
-(void) present { |
|
39 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
|
40 |
self.view.backgroundColor = [UIColor clearColor]; |
|
4935 | 41 |
self.view.frame = CGRectMake(screen.size.height, 0, 200, VIEW_HEIGHT); |
3697 | 42 |
|
3648 | 43 |
[UIView beginAnimations:@"showing popover" context:NULL]; |
44 |
[UIView setAnimationDuration:0.35]; |
|
4935 | 45 |
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, VIEW_HEIGHT); |
3648 | 46 |
[UIView commitAnimations]; |
47 |
} |
|
48 |
||
49 |
-(void) dismiss { |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
50 |
if (IS_IPAD() == NO) { |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
51 |
CGRect screen = [[UIScreen mainScreen] bounds]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
52 |
[UIView beginAnimations:@"hiding popover" context:NULL]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
53 |
[UIView setAnimationDuration:0.35]; |
4935 | 54 |
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
|
55 |
[UIView commitAnimations]; |
4924 | 56 |
[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
|
57 |
} |
3697 | 58 |
|
5166
d1eb1560b4d5
and now for something completely different, overlay refactoring!
koda
parents:
5156
diff
changeset
|
59 |
SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow()); |
3648 | 60 |
} |
61 |
||
62 |
#pragma mark - |
|
3547 | 63 |
#pragma mark tableView methods |
64 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
65 |
return 1; |
|
66 |
} |
|
67 |
||
68 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
5711 | 69 |
return 3; |
3547 | 70 |
} |
71 |
||
72 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
73 |
static NSString *cellIdentifier = @"CellIdentifier"; |
|
3697 | 74 |
|
6269 | 75 |
NSInteger row = [indexPath row]; |
76 |
NSString *cellTitle; |
|
77 |
if (row == 0) |
|
78 |
cellTitle = NSLocalizedString(@"Show Help", @""); |
|
79 |
else if (row == 1) |
|
80 |
cellTitle = NSLocalizedString(@"Tag", @""); |
|
81 |
else |
|
82 |
cellTitle = NSLocalizedString(@"End Game", @""); |
|
83 |
||
3547 | 84 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier]; |
85 |
if (nil == cell) { |
|
86 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
87 |
reuseIdentifier:cellIdentifier] autorelease]; |
|
88 |
} |
|
6269 | 89 |
cell.textLabel.text = cellTitle; |
3697 | 90 |
|
3996 | 91 |
if (IS_IPAD()) |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3667
diff
changeset
|
92 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
3697 | 93 |
|
3547 | 94 |
return cell; |
95 |
} |
|
96 |
||
97 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
98 |
UIActionSheet *actionSheet; |
|
3697 | 99 |
|
3547 | 100 |
switch ([indexPath row]) { |
101 |
case 0: |
|
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3737
diff
changeset
|
102 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"show help ingame" object:nil]; |
4935 | 103 |
|
3547 | 104 |
break; |
105 |
case 1: |
|
4920 | 106 |
HW_chat(); |
107 |
SDL_iPhoneKeyboardShow((SDL_Window *)HW_getSDLWindow()); |
|
4935 | 108 |
|
3547 | 109 |
break; |
110 |
case 2: |
|
111 |
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") |
|
112 |
delegate:self |
|
113 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") |
|
114 |
destructiveButtonTitle:NSLocalizedString(@"Of course!", @"") |
|
115 |
otherButtonTitles:nil]; |
|
6409 | 116 |
[actionSheet showInView:(IS_IPAD() ? self.view : [HWUtils mainSDLViewInstance])]; |
3547 | 117 |
[actionSheet release]; |
3697 | 118 |
|
3547 | 119 |
break; |
120 |
default: |
|
3660 | 121 |
DLog(@"Warning: unset case value in section!"); |
3547 | 122 |
break; |
123 |
} |
|
3697 | 124 |
|
3547 | 125 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
126 |
} |
|
127 |
||
128 |
#pragma mark - |
|
129 |
#pragma mark actionSheet methods |
|
130 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
4924 | 131 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
5166
d1eb1560b4d5
and now for something completely different, overlay refactoring!
koda
parents:
5156
diff
changeset
|
132 |
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
|
133 |
HW_terminate(NO); |
4924 | 134 |
} |
3547 | 135 |
} |
136 |
||
137 |
@end |