equal
deleted
inserted
replaced
15 #import "PopoverMenuViewController.h" |
15 #import "PopoverMenuViewController.h" |
16 #import "CommodityFunctions.h" |
16 #import "CommodityFunctions.h" |
17 |
17 |
18 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7] |
18 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7] |
19 #define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000] |
19 #define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000] |
20 |
20 #define doDim() [dimTimer setFireDate:HIDING_TIME_DEFAULT] |
|
21 #define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER] |
|
22 |
|
23 #define CONFIRMATION_TAG 5959 |
|
24 #define ANIMATION_DURATION 0.25 |
|
25 #define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview]; |
21 |
26 |
22 @implementation OverlayViewController |
27 @implementation OverlayViewController |
23 @synthesize popoverController, popupMenu; |
28 @synthesize popoverController, popupMenu; |
24 |
29 |
25 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
187 } |
192 } |
188 |
193 |
189 // set the overlay visible and put off the timer for enough time |
194 // set the overlay visible and put off the timer for enough time |
190 -(void) activateOverlay { |
195 -(void) activateOverlay { |
191 self.view.alpha = 1; |
196 self.view.alpha = 1; |
192 [dimTimer setFireDate:HIDING_TIME_NEVER]; |
197 doNotDim(); |
193 } |
198 } |
194 |
199 |
195 // dim the overlay when there's no more input for a certain amount of time |
200 // dim the overlay when there's no more input for a certain amount of time |
196 -(IBAction) buttonReleased:(id) sender { |
201 -(IBAction) buttonReleased:(id) sender { |
197 if (!isGameRunning) |
202 if (!isGameRunning) |
214 default: |
219 default: |
215 NSLog(@"Nope"); |
220 NSLog(@"Nope"); |
216 break; |
221 break; |
217 } |
222 } |
218 |
223 |
219 [dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
224 doDim(); |
220 } |
225 } |
221 |
226 |
222 // issue certain action based on the tag of the button |
227 // issue certain action based on the tag of the button |
223 -(IBAction) buttonPressed:(id) sender { |
228 -(IBAction) buttonPressed:(id) sender { |
224 [self activateOverlay]; |
229 [self activateOverlay]; |
349 if (writeChatTextField) { |
354 if (writeChatTextField) { |
350 [self.writeChatTextField resignFirstResponder]; |
355 [self.writeChatTextField resignFirstResponder]; |
351 [dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
356 [dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
352 } |
357 } |
353 */ |
358 */ |
|
359 |
|
360 // reset default dimming |
|
361 doDim(); |
354 |
362 |
355 switch ([allTouches count]) { |
363 switch ([allTouches count]) { |
356 case 1: |
364 case 1: |
357 removeConfirmationInput(); |
365 removeConfirmationInput(); |
358 if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount]) |
366 if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount]) |
401 // animation ftw! |
409 // animation ftw! |
402 [UIView beginAnimations:@"inserting button" context:NULL]; |
410 [UIView beginAnimations:@"inserting button" context:NULL]; |
403 [UIView setAnimationDuration:ANIMATION_DURATION]; |
411 [UIView setAnimationDuration:ANIMATION_DURATION]; |
404 [self.view viewWithTag:CONFIRMATION_TAG].alpha = 1; |
412 [self.view viewWithTag:CONFIRMATION_TAG].alpha = 1; |
405 [UIView commitAnimations]; |
413 [UIView commitAnimations]; |
|
414 |
|
415 // keep the overlay active, or the button will fade |
|
416 doNotDim(); |
406 } |
417 } |
407 break; |
418 break; |
408 case 2: |
419 case 2: |
409 HW_allKeysUp(); |
420 HW_allKeysUp(); |
410 break; |
421 break; |
417 } |
428 } |
418 |
429 |
419 -(void) sendHWClick { |
430 -(void) sendHWClick { |
420 HW_click(); |
431 HW_click(); |
421 removeConfirmationInput(); |
432 removeConfirmationInput(); |
|
433 doDim(); |
422 } |
434 } |
423 |
435 |
424 -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
436 -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
425 [self touchesEnded:touches withEvent:event]; |
437 [self touchesEnded:touches withEvent:event]; |
426 } |
438 } |