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