22 #import "ObjcExports.h" |
22 #import "ObjcExports.h" |
23 #import "OverlayViewController.h" |
23 #import "OverlayViewController.h" |
24 #import "AmmoMenuViewController.h" |
24 #import "AmmoMenuViewController.h" |
25 |
25 |
26 |
26 |
27 // actual game started (controls should be enabled) |
|
28 static BOOL gameRunning; |
|
29 // black screen present |
|
30 static BOOL savedGame; |
|
31 // cache the grenade time |
27 // cache the grenade time |
32 static NSInteger grenadeTime; |
28 static NSInteger grenadeTime; |
33 // the reference to the newMenu instance |
29 // the reference to the newMenu instance |
34 static OverlayViewController *overlay_instance; |
30 static OverlayViewController *overlay_instance; |
35 |
31 |
36 @implementation ObjcExports |
32 @implementation ObjcExports |
37 |
33 |
38 +(void) initialize { |
34 +(void) setGrenadeTime:(NSInteger) value { |
39 overlay_instance = [OverlayViewController mainOverlay]; |
35 grenadeTime = value; |
40 gameRunning = NO; |
36 } |
41 savedGame = NO; |
37 |
42 grenadeTime = 2; |
38 +(NSInteger) grenadeTime { |
|
39 return grenadeTime; |
43 } |
40 } |
44 |
41 |
45 @end |
42 @end |
46 |
43 |
47 #pragma mark - |
|
48 #pragma mark functions called by objc code |
|
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 |
44 |
65 #pragma mark - |
45 #pragma mark - |
66 #pragma mark functions called by pascal code |
46 #pragma mark functions called by pascal code |
67 BOOL inline isApplePhone() { |
47 BOOL inline isApplePhone() { |
68 return (IS_IPAD() == NO); |
48 return (IS_IPAD() == NO); |
69 } |
49 } |
70 |
50 |
71 void startSpinningProgress() { |
51 void startLoadingIndicator() { |
72 gameRunning = NO; |
52 // this is the first ojbc function called by engine, so we have to initialize some variables here |
73 overlay_instance.lowerIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
53 overlay_instance = [OverlayViewController mainOverlay]; |
|
54 grenadeTime = 2; |
74 |
55 |
|
56 if ([HWUtils gameType] == gtSave) { |
|
57 [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; |
|
58 |
|
59 overlay_instance.view.backgroundColor = [UIColor blackColor]; |
|
60 overlay_instance.view.alpha = 0.75; |
|
61 overlay_instance.view.userInteractionEnabled = NO; |
|
62 } |
75 CGPoint center = overlay_instance.view.center; |
63 CGPoint center = overlay_instance.view.center; |
76 overlay_instance.lowerIndicator.center = (IS_DUALHEAD() ? center : CGPointMake(center.x, center.y * 5/3)); |
64 CGPoint loaderCenter = ((IS_DUALHEAD() || [HWUtils gameType] == gtSave) ? center : CGPointMake(center.x, center.y * 5/3)); |
77 |
65 |
78 [overlay_instance.lowerIndicator startAnimating]; |
66 overlay_instance.loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
79 [overlay_instance.view addSubview:overlay_instance.lowerIndicator]; |
67 overlay_instance.loadingIndicator.hidesWhenStopped = YES; |
80 [overlay_instance.lowerIndicator release]; |
68 overlay_instance.loadingIndicator.center = loaderCenter; |
|
69 [overlay_instance.loadingIndicator startAnimating]; |
|
70 [overlay_instance.view addSubview:overlay_instance.loadingIndicator]; |
|
71 [overlay_instance.loadingIndicator release]; |
81 } |
72 } |
82 |
73 |
83 void stopSpinningProgress() { |
74 void stopLoadingIndicator() { |
84 [overlay_instance.lowerIndicator stopAnimating]; |
|
85 [overlay_instance.lowerIndicator removeFromSuperview]; |
|
86 HW_zoomSet(1.7); |
75 HW_zoomSet(1.7); |
87 if (savedGame == NO) |
76 if ([HWUtils gameType] != gtSave) { |
88 gameRunning = YES; |
77 [overlay_instance.loadingIndicator stopAnimating]; |
|
78 [overlay_instance.loadingIndicator removeFromSuperview]; |
|
79 [HWUtils setGameStatus:gsInGame]; |
|
80 } |
|
81 } |
|
82 |
|
83 void saveFinishedSynching() { |
|
84 [UIView beginAnimations:@"fading from save synch" context:NULL]; |
|
85 [UIView setAnimationDuration:1]; |
|
86 overlay_instance.view.backgroundColor = [UIColor clearColor]; |
|
87 overlay_instance.view.alpha = 1; |
|
88 overlay_instance.view.userInteractionEnabled = YES; |
|
89 [UIView commitAnimations]; |
|
90 |
|
91 [overlay_instance.loadingIndicator stopAnimating]; |
|
92 [overlay_instance.loadingIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
|
93 |
|
94 [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; |
|
95 [HWUtils setGameStatus:gsInGame]; |
89 } |
96 } |
90 |
97 |
91 void clearView() { |
98 void clearView() { |
92 // don't use any engine calls here as this function is called every time the ammomenu is opened |
99 // don't use any engine calls here as this function is called every time the ammomenu is opened |
93 [UIView beginAnimations:@"remove button" context:NULL]; |
100 [UIView beginAnimations:@"remove button" context:NULL]; |
103 overlay_instance.grenadeTimeSegment.tag = 0; |
110 overlay_instance.grenadeTimeSegment.tag = 0; |
104 } |
111 } |
105 grenadeTime = 2; |
112 grenadeTime = 2; |
106 } |
113 } |
107 |
114 |
108 void saveBeganSynching() { |
|
109 savedGame = YES; |
|
110 stopSpinningProgress(); |
|
111 [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; |
|
112 |
|
113 overlay_instance.view.backgroundColor = [UIColor blackColor]; |
|
114 overlay_instance.view.alpha = 0.75; |
|
115 overlay_instance.view.userInteractionEnabled = NO; |
|
116 |
|
117 overlay_instance.savesIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
|
118 |
|
119 overlay_instance.savesIndicator.center = overlay_instance.view.center; |
|
120 overlay_instance.savesIndicator.hidesWhenStopped = YES; |
|
121 |
|
122 [overlay_instance.savesIndicator startAnimating]; |
|
123 [overlay_instance.view addSubview:overlay_instance.savesIndicator]; |
|
124 [overlay_instance.savesIndicator release]; |
|
125 } |
|
126 |
|
127 void saveFinishedSynching() { |
|
128 [UIView beginAnimations:@"fading from save synch" context:NULL]; |
|
129 [UIView setAnimationDuration:1]; |
|
130 overlay_instance.view.backgroundColor = [UIColor clearColor]; |
|
131 overlay_instance.view.alpha = 1; |
|
132 overlay_instance.view.userInteractionEnabled = YES; |
|
133 [UIView commitAnimations]; |
|
134 |
|
135 [overlay_instance.savesIndicator stopAnimating]; |
|
136 [overlay_instance.savesIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
|
137 |
|
138 [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; |
|
139 gameRunning = YES; |
|
140 } |
|
141 |
|
142 void updateVisualsNewTurn(void) { |
115 void updateVisualsNewTurn(void) { |
143 [overlay_instance.amvc updateAmmoVisuals]; |
116 [overlay_instance.amvc updateAmmoVisuals]; |
144 } |
117 } |
145 |
118 |
146 // dummy function to prevent linkage fail |
119 // dummy function to prevent linkage fail |