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