author | sheepluva |
Sun, 30 Oct 2011 08:01:26 +0100 | |
changeset 6240 | 5d8e478916b4 |
parent 6078 | 8c0cc07731e5 |
child 6247 | 6dfad55fd71c |
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" |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
24 |
#import "AmmoMenuViewController.h" |
4028 | 25 |
|
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
|
26 |
|
4028 | 27 |
// actual game started (controls should be enabled) |
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
|
28 |
static BOOL gameRunning; |
4028 | 29 |
// black screen present |
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
|
30 |
static BOOL savedGame; |
4028 | 31 |
// 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
|
32 |
static NSInteger grenadeTime; |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
33 |
// 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
|
34 |
static OverlayViewController *overlay_instance; |
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
35 |
|
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
|
36 |
@implementation ObjcExports |
4028 | 37 |
|
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
|
38 |
+(void) initialize { |
6018
3b86826f6665
add a class method for getting the overlay (and fix a silly mistake while at it) and use it
koda
parents:
5994
diff
changeset
|
39 |
overlay_instance = [OverlayViewController mainOverlay]; |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
40 |
gameRunning = NO; |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
41 |
savedGame = NO; |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
42 |
grenadeTime = 2; |
4028 | 43 |
} |
44 |
||
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
|
45 |
@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
|
46 |
|
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
|
47 |
#pragma mark - |
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
|
48 |
#pragma mark functions called by objc code |
4028 | 49 |
BOOL inline isGameRunning() { |
50 |
return gameRunning; |
|
51 |
} |
|
52 |
||
53 |
void inline setGameRunning(BOOL value) { |
|
54 |
gameRunning = value; |
|
55 |
} |
|
56 |
||
57 |
NSInteger cachedGrenadeTime() { |
|
58 |
return grenadeTime; |
|
59 |
} |
|
60 |
||
61 |
void inline setGrenadeTime(NSInteger value) { |
|
62 |
grenadeTime = value; |
|
63 |
} |
|
64 |
||
65 |
#pragma mark - |
|
66 |
#pragma mark functions called by pascal code |
|
5994 | 67 |
BOOL inline isApplePhone() { |
68 |
return (IS_IPAD() == NO); |
|
69 |
} |
|
70 |
||
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
71 |
void startSpinningProgress() { |
4028 | 72 |
gameRunning = NO; |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
73 |
overlay_instance.lowerIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
74 |
|
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
75 |
CGPoint center = overlay_instance.view.center; |
5662
99083392cd4f
FREE AT LAST!!! SDL came around a (mostly) sane way for implementing rotation events, so we can scrap all the workaround code that has been added to workaround it!! Also this allows us to use proper (internal) multitasking handling and can simplify optional settings and other yet unexplored features. Yay!
koda
parents:
5194
diff
changeset
|
76 |
overlay_instance.lowerIndicator.center = (IS_DUALHEAD() ? center : CGPointMake(center.x, center.y * 5/3)); |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
77 |
|
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
78 |
[overlay_instance.lowerIndicator startAnimating]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
79 |
[overlay_instance.view addSubview:overlay_instance.lowerIndicator]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
80 |
[overlay_instance.lowerIndicator release]; |
4028 | 81 |
} |
82 |
||
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
83 |
void stopSpinningProgress() { |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
84 |
[overlay_instance.lowerIndicator stopAnimating]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
85 |
[overlay_instance.lowerIndicator removeFromSuperview]; |
4028 | 86 |
HW_zoomSet(1.7); |
87 |
if (savedGame == NO) |
|
88 |
gameRunning = YES; |
|
89 |
} |
|
90 |
||
91 |
void clearView() { |
|
4504
8906b2409d97
add the appirater class for getting more positive reviews
koda
parents:
4488
diff
changeset
|
92 |
// don't use any engine calls here as this function is called every time the ammomenu is opened |
4028 | 93 |
[UIView beginAnimations:@"remove button" context:NULL]; |
94 |
[UIView setAnimationDuration:ANIMATION_DURATION]; |
|
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
95 |
overlay_instance.confirmButton.alpha = 0; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
96 |
overlay_instance.grenadeTimeSegment.alpha = 0; |
4028 | 97 |
[UIView commitAnimations]; |
98 |
||
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
99 |
if (overlay_instance.confirmButton) |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
100 |
[overlay_instance.confirmButton performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION]; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
101 |
if (overlay_instance.grenadeTimeSegment) { |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
102 |
[overlay_instance.grenadeTimeSegment performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION]; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
103 |
overlay_instance.grenadeTimeSegment.tag = 0; |
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
104 |
} |
4028 | 105 |
grenadeTime = 2; |
106 |
} |
|
107 |
||
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
108 |
void saveBeganSynching() { |
5194 | 109 |
savedGame = YES; |
110 |
stopSpinningProgress(); |
|
5992
a311b8461ec9
prevent screen locking while synching saves (can take some time)
koda
parents:
5662
diff
changeset
|
111 |
[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; |
5194 | 112 |
|
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
113 |
overlay_instance.view.backgroundColor = [UIColor blackColor]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
114 |
overlay_instance.view.alpha = 0.75; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
115 |
overlay_instance.view.userInteractionEnabled = NO; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
116 |
|
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
117 |
overlay_instance.savesIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
4028 | 118 |
|
5662
99083392cd4f
FREE AT LAST!!! SDL came around a (mostly) sane way for implementing rotation events, so we can scrap all the workaround code that has been added to workaround it!! Also this allows us to use proper (internal) multitasking handling and can simplify optional settings and other yet unexplored features. Yay!
koda
parents:
5194
diff
changeset
|
119 |
overlay_instance.savesIndicator.center = overlay_instance.view.center; |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
120 |
overlay_instance.savesIndicator.hidesWhenStopped = YES; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
121 |
|
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
122 |
[overlay_instance.savesIndicator startAnimating]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
123 |
[overlay_instance.view addSubview:overlay_instance.savesIndicator]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
124 |
[overlay_instance.savesIndicator release]; |
4028 | 125 |
} |
126 |
||
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
127 |
void saveFinishedSynching() { |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
128 |
[UIView beginAnimations:@"fading from save synch" context:NULL]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
129 |
[UIView setAnimationDuration:1]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
130 |
overlay_instance.view.backgroundColor = [UIColor clearColor]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
131 |
overlay_instance.view.alpha = 1; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
132 |
overlay_instance.view.userInteractionEnabled = YES; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
133 |
[UIView commitAnimations]; |
4028 | 134 |
|
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
135 |
[overlay_instance.savesIndicator stopAnimating]; |
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
136 |
[overlay_instance.savesIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
4028 | 137 |
|
5992
a311b8461ec9
prevent screen locking while synching saves (can take some time)
koda
parents:
5662
diff
changeset
|
138 |
[[UIApplication sharedApplication] setIdleTimerDisabled:NO]; |
4028 | 139 |
gameRunning = YES; |
140 |
} |
|
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
141 |
|
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
142 |
void updateVisualsNewTurn(void) { |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
143 |
[overlay_instance.amvc updateAmmoVisuals]; |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
144 |
} |
5106
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
145 |
|
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
146 |
// dummy function to prevent linkage fail |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
147 |
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
|
148 |
return 0; |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
149 |
} |