author | koda |
Sun, 12 Feb 2012 18:08:34 +0100 | |
changeset 6678 | beab48f963d5 |
parent 6624 | e049b5bb0ad1 |
child 6700 | e04da46ee43c |
permissions | -rw-r--r-- |
4028 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
4028 | 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 30/10/2010. |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
#import "ObjcExports.h" |
|
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
23 |
#import "OverlayViewController.h" |
4028 | 24 |
|
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:
6018
diff
changeset
|
25 |
|
4028 | 26 |
// cache the grenade time |
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:
6018
diff
changeset
|
27 |
static NSInteger grenadeTime; |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
28 |
// the reference to the newMenu instance |
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:
6018
diff
changeset
|
29 |
static OverlayViewController *overlay_instance; |
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
30 |
|
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:
6018
diff
changeset
|
31 |
@implementation ObjcExports |
4028 | 32 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
33 |
+(void) setGrenadeTime:(NSInteger) value { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
34 |
grenadeTime = value; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
35 |
} |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
36 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
37 |
+(NSInteger) grenadeTime { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
38 |
return grenadeTime; |
4028 | 39 |
} |
40 |
||
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:
6018
diff
changeset
|
41 |
@end |
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:
6018
diff
changeset
|
42 |
|
4028 | 43 |
|
44 |
#pragma mark - |
|
45 |
#pragma mark functions called by pascal code |
|
5994 | 46 |
BOOL inline isApplePhone() { |
47 |
return (IS_IPAD() == NO); |
|
48 |
} |
|
49 |
||
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
50 |
void startLoadingIndicator() { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
51 |
// this is the first ojbc function called by engine, so we have to initialize some variables here |
6259
02765411a912
move objc overlay creation after sdlwindow has been created
koda
parents:
6247
diff
changeset
|
52 |
overlay_instance = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
02765411a912
move objc overlay creation after sdlwindow has been created
koda
parents:
6247
diff
changeset
|
53 |
// in order to get rotation events we have to insert the view inside the first view of the second window |
02765411a912
move objc overlay creation after sdlwindow has been created
koda
parents:
6247
diff
changeset
|
54 |
//TODO: when multihead make sure that overlay is displayed in the touch-enabled window |
6409 | 55 |
[[HWUtils mainSDLViewInstance] addSubview:overlay_instance.view]; |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
56 |
grenadeTime = 2; |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
57 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
58 |
if ([HWUtils gameType] == gtSave) { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
59 |
[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
60 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
61 |
overlay_instance.view.backgroundColor = [UIColor blackColor]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
62 |
overlay_instance.view.alpha = 0.75; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
63 |
overlay_instance.view.userInteractionEnabled = NO; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
64 |
} |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
65 |
CGPoint center = overlay_instance.view.center; |
6624
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6615
diff
changeset
|
66 |
CGPoint loaderCenter = ([HWUtils gameType] == gtSave) ? center : CGPointMake(center.x, center.y * 5/3); |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
67 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
68 |
overlay_instance.loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
69 |
overlay_instance.loadingIndicator.hidesWhenStopped = YES; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
70 |
overlay_instance.loadingIndicator.center = loaderCenter; |
6615 | 71 |
overlay_instance.loadingIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | |
72 |
UIViewAutoresizingFlexibleRightMargin | |
|
73 |
UIViewAutoresizingFlexibleTopMargin | |
|
74 |
UIViewAutoresizingFlexibleBottomMargin; |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
75 |
[overlay_instance.loadingIndicator startAnimating]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
76 |
[overlay_instance.view addSubview:overlay_instance.loadingIndicator]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
77 |
[overlay_instance.loadingIndicator release]; |
4028 | 78 |
} |
79 |
||
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
80 |
void stopLoadingIndicator() { |
4028 | 81 |
HW_zoomSet(1.7); |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
82 |
if ([HWUtils gameType] != gtSave) { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
83 |
[overlay_instance.loadingIndicator stopAnimating]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
84 |
[overlay_instance.loadingIndicator removeFromSuperview]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
85 |
[HWUtils setGameStatus:gsInGame]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
86 |
} |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
87 |
} |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
88 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
89 |
void saveFinishedSynching() { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
90 |
[UIView beginAnimations:@"fading from save synch" context:NULL]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
91 |
[UIView setAnimationDuration:1]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
92 |
overlay_instance.view.backgroundColor = [UIColor clearColor]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
93 |
overlay_instance.view.alpha = 1; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
94 |
overlay_instance.view.userInteractionEnabled = YES; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
95 |
[UIView commitAnimations]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
96 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
97 |
[overlay_instance.loadingIndicator stopAnimating]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
98 |
[overlay_instance.loadingIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
99 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
100 |
[[UIApplication sharedApplication] setIdleTimerDisabled:NO]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
101 |
[HWUtils setGameStatus:gsInGame]; |
4028 | 102 |
} |
103 |
||
104 |
void clearView() { |
|
4504
8906b2409d97
add the appirater class for getting more positive reviews
koda
parents:
4488
diff
changeset
|
105 |
// don't use any engine calls here as this function is called every time the ammomenu is opened |
4028 | 106 |
[UIView beginAnimations:@"remove button" context:NULL]; |
107 |
[UIView setAnimationDuration:ANIMATION_DURATION]; |
|
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
108 |
overlay_instance.confirmButton.alpha = 0; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
109 |
overlay_instance.grenadeTimeSegment.alpha = 0; |
4028 | 110 |
[UIView commitAnimations]; |
111 |
||
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
112 |
if (overlay_instance.confirmButton) |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
113 |
[overlay_instance.confirmButton performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION]; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
114 |
if (overlay_instance.grenadeTimeSegment) { |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
115 |
[overlay_instance.grenadeTimeSegment performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION]; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
116 |
overlay_instance.grenadeTimeSegment.tag = 0; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
117 |
} |
4028 | 118 |
grenadeTime = 2; |
119 |
} |
|
120 |
||
5106
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
121 |
// dummy function to prevent linkage fail |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
122 |
int SDL_main(int argc, char **argv) { |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
123 |
return 0; |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
124 |
} |