equal
deleted
inserted
replaced
22 @implementation OverlayViewController |
22 @implementation OverlayViewController |
23 @synthesize popoverController, popupMenu, writeChatTextField, spinningWheel; |
23 @synthesize popoverController, popupMenu, writeChatTextField, spinningWheel; |
24 |
24 |
25 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
25 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
26 return rotationManager(interfaceOrientation); |
26 return rotationManager(interfaceOrientation); |
27 } |
|
28 |
|
29 |
|
30 -(void) didReceiveMemoryWarning { |
|
31 // Releases the view if it doesn't have a superview. |
|
32 [super didReceiveMemoryWarning]; |
|
33 // Release any cached data, images, etc that aren't in use. |
|
34 if (popupMenu.view.superview == nil) |
|
35 popupMenu = nil; |
|
36 MSG_MEMCLEAN(); |
|
37 } |
27 } |
38 |
28 |
39 -(void) didRotate:(NSNotification *)notification { |
29 -(void) didRotate:(NSNotification *)notification { |
40 UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
30 UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
41 CGRect rect = [[UIScreen mainScreen] bounds]; |
31 CGRect rect = [[UIScreen mainScreen] bounds]; |
146 |
136 |
147 // set initial orientation |
137 // set initial orientation |
148 [self didRotate:[NSNotification notificationWithName:UIDeviceOrientationDidChangeNotification object:nil]]; |
138 [self didRotate:[NSNotification notificationWithName:UIDeviceOrientationDidChangeNotification object:nil]]; |
149 } |
139 } |
150 |
140 |
|
141 /* these are causing problems at reloading so let's remove 'em |
151 -(void) viewDidUnload { |
142 -(void) viewDidUnload { |
152 [popoverController dismissPopoverAnimated:NO]; |
143 [popoverController dismissPopoverAnimated:NO]; |
153 [dimTimer invalidate]; |
144 [dimTimer invalidate]; |
154 self.writeChatTextField = nil; |
145 self.writeChatTextField = nil; |
155 self.popoverController = nil; |
146 self.popoverController = nil; |
157 self.spinningWheel = nil; |
148 self.spinningWheel = nil; |
158 [super viewDidUnload]; |
149 [super viewDidUnload]; |
159 MSG_DIDUNLOAD(); |
150 MSG_DIDUNLOAD(); |
160 } |
151 } |
161 |
152 |
|
153 -(void) didReceiveMemoryWarning { |
|
154 // Releases the view if it doesn't have a superview. |
|
155 [super didReceiveMemoryWarning]; |
|
156 // Release any cached data, images, etc that aren't in use. |
|
157 if (popupMenu.view.superview == nil) |
|
158 popupMenu = nil; |
|
159 MSG_MEMCLEAN(); |
|
160 } |
|
161 */ |
|
162 |
162 -(void) dealloc { |
163 -(void) dealloc { |
163 [writeChatTextField release]; |
164 [writeChatTextField release]; |
164 [popupMenu release]; |
165 [popupMenu release]; |
165 [popoverController release]; |
166 [popoverController release]; |
166 // dimTimer is autoreleased |
167 // dimTimer is autoreleased |
168 [super dealloc]; |
169 [super dealloc]; |
169 } |
170 } |
170 |
171 |
171 #pragma mark - |
172 #pragma mark - |
172 #pragma mark Overlay actions and members |
173 #pragma mark Overlay actions and members |
173 // dim the overlay when there's no more input for a certain amount of time |
|
174 -(IBAction) buttonReleased:(id) sender { |
|
175 HW_allKeysUp(); |
|
176 [dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
|
177 } |
|
178 |
|
179 // nice transition for dimming, should be called only by the timer himself |
174 // nice transition for dimming, should be called only by the timer himself |
180 -(void) dimOverlay { |
175 -(void) dimOverlay { |
181 if (canDim) { |
176 if (canDim) { |
182 [UIView beginAnimations:@"overlay dim" context:NULL]; |
177 [UIView beginAnimations:@"overlay dim" context:NULL]; |
183 [UIView setAnimationDuration:0.6]; |
178 [UIView setAnimationDuration:0.6]; |
190 -(void) activateOverlay { |
185 -(void) activateOverlay { |
191 self.view.alpha = 1; |
186 self.view.alpha = 1; |
192 [dimTimer setFireDate:HIDING_TIME_NEVER]; |
187 [dimTimer setFireDate:HIDING_TIME_NEVER]; |
193 } |
188 } |
194 |
189 |
|
190 // dim the overlay when there's no more input for a certain amount of time |
|
191 -(IBAction) buttonReleased:(id) sender { |
|
192 UIButton *theButton = (UIButton *)sender; |
|
193 |
|
194 switch (theButton.tag) { |
|
195 case 0: |
|
196 case 1: |
|
197 case 2: |
|
198 case 3: |
|
199 HW_walkingKeysUp(); |
|
200 break; |
|
201 case 4: |
|
202 case 5: |
|
203 case 6: |
|
204 HW_otherKeysUp(); |
|
205 break; |
|
206 default: |
|
207 NSLog(@"Nope"); |
|
208 break; |
|
209 } |
|
210 |
|
211 [dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
|
212 } |
|
213 |
195 // issue certain action based on the tag of the button |
214 // issue certain action based on the tag of the button |
196 -(IBAction) buttonPressed:(id) sender { |
215 -(IBAction) buttonPressed:(id) sender { |
197 [self activateOverlay]; |
216 [self activateOverlay]; |
198 if (isPopoverVisible) { |
217 if (isPopoverVisible) { |
199 [self dismissPopover]; |
218 [self dismissPopover]; |
230 break; |
249 break; |
231 case 11: |
250 case 11: |
232 HW_ammoMenu(); |
251 HW_ammoMenu(); |
233 break; |
252 break; |
234 default: |
253 default: |
235 NSLog(@"Nope"); |
254 DLog(@"Nope"); |
236 break; |
255 break; |
237 } |
256 } |
238 } |
257 } |
239 |
258 |
240 // present a further check before closing game |
259 // present a further check before closing game |