author | koda |
Mon, 01 Nov 2010 18:51:38 +0100 | |
changeset 4082 | bfe14b38dad1 |
parent 4034 | 634a8c8682de |
child 4362 | 8dae325dc625 |
permissions | -rw-r--r-- |
4028 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
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" |
|
23 |
||
24 |
#pragma mark - |
|
25 |
#pragma mark internal variables |
|
26 |
// actual game started (controls should be enabled) |
|
27 |
BOOL gameRunning; |
|
28 |
// black screen present |
|
29 |
BOOL savedGame; |
|
30 |
// cache the grenade time |
|
31 |
NSInteger grenadeTime; |
|
32 |
||
33 |
#pragma mark - |
|
34 |
#pragma mark functions called like oop |
|
35 |
void objcExportsInit() { |
|
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
36 |
gameRunning = NO; |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
37 |
savedGame = NO; |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
38 |
grenadeTime = 2; |
4028 | 39 |
} |
40 |
||
41 |
BOOL inline isGameRunning() { |
|
42 |
return gameRunning; |
|
43 |
} |
|
44 |
||
45 |
void inline setGameRunning(BOOL value) { |
|
46 |
gameRunning = value; |
|
47 |
} |
|
48 |
||
49 |
NSInteger cachedGrenadeTime() { |
|
50 |
return grenadeTime; |
|
51 |
} |
|
52 |
||
53 |
void inline setGrenadeTime(NSInteger value) { |
|
54 |
grenadeTime = value; |
|
55 |
} |
|
56 |
||
57 |
#pragma mark - |
|
58 |
#pragma mark functions called by pascal code |
|
59 |
void startSpinning() { |
|
60 |
gameRunning = NO; |
|
61 |
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
|
62 |
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
|
63 |
indicator.tag = ACTIVITYINDICATOR_TAG; |
|
64 |
int offset; |
|
65 |
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) |
|
66 |
offset = -120; |
|
67 |
else |
|
68 |
offset = 120; |
|
69 |
if (IS_DUALHEAD()) |
|
70 |
indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + offset); |
|
71 |
else |
|
72 |
indicator.center = CGPointMake(theWindow.frame.size.width/2 + offset, theWindow.frame.size.height/2); |
|
73 |
indicator.hidesWhenStopped = YES; |
|
74 |
[indicator startAnimating]; |
|
75 |
[theWindow addSubview:indicator]; |
|
76 |
[indicator release]; |
|
77 |
} |
|
78 |
||
79 |
void stopSpinning() { |
|
80 |
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
|
81 |
UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG]; |
|
82 |
[indicator stopAnimating]; |
|
83 |
HW_zoomSet(1.7); |
|
84 |
if (savedGame == NO) |
|
85 |
gameRunning = YES; |
|
86 |
} |
|
87 |
||
88 |
void clearView() { |
|
89 |
UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow]; |
|
90 |
UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG]; |
|
91 |
UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG]; |
|
92 |
||
93 |
[UIView beginAnimations:@"remove button" context:NULL]; |
|
94 |
[UIView setAnimationDuration:ANIMATION_DURATION]; |
|
95 |
theButton.alpha = 0; |
|
96 |
theSegment.alpha = 0; |
|
97 |
[UIView commitAnimations]; |
|
98 |
||
99 |
if (theButton) |
|
100 |
[theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:ANIMATION_DURATION]; |
|
101 |
if (theSegment) |
|
102 |
[theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION]; |
|
103 |
||
104 |
grenadeTime = 2; |
|
105 |
} |
|
106 |
||
107 |
void replayBegan() { |
|
108 |
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
|
109 |
UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame]; |
|
110 |
blackView.backgroundColor = [UIColor blackColor]; |
|
111 |
blackView.alpha = 0.6; |
|
112 |
blackView.tag = REPLAYBLACKVIEW_TAG; |
|
113 |
blackView.exclusiveTouch = NO; |
|
114 |
blackView.multipleTouchEnabled = NO; |
|
115 |
blackView.userInteractionEnabled = NO; |
|
116 |
||
117 |
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
|
118 |
indicator.center = theWindow.center; |
|
119 |
[indicator startAnimating]; |
|
120 |
[blackView addSubview:indicator]; |
|
121 |
[indicator release]; |
|
122 |
[theWindow addSubview:blackView]; |
|
123 |
[blackView release]; |
|
124 |
||
125 |
savedGame = YES; |
|
126 |
stopSpinning(); |
|
127 |
} |
|
128 |
||
129 |
void replayFinished() { |
|
130 |
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
|
131 |
UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG]; |
|
132 |
||
133 |
[UIView beginAnimations:@"removing black" context:NULL]; |
|
134 |
[UIView setAnimationDuration:1]; |
|
135 |
blackView.alpha = 0; |
|
136 |
[UIView commitAnimations]; |
|
137 |
[theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1]; |
|
138 |
||
139 |
gameRunning = YES; |
|
140 |
savedGame = NO; |
|
141 |
} |
|
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
142 |
|
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
143 |
void updateVisualsNewTurn(void) { |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
144 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateAmmoVisuals" object:nil]; |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4028
diff
changeset
|
145 |
} |