69 HW_setLandscape(NO); |
69 HW_setLandscape(NO); |
70 } |
70 } |
71 break; |
71 break; |
72 */ |
72 */ |
73 default: |
73 default: |
|
74 // a debug log would spam too much |
74 break; |
75 break; |
75 } |
76 } |
76 self.view.frame = usefulRect; |
77 self.view.frame = usefulRect; |
77 //sdlView.frame = usefulRect; |
78 //sdlView.frame = usefulRect; |
78 [UIView commitAnimations]; |
79 [UIView commitAnimations]; |
79 } |
80 } |
80 |
81 |
81 #pragma mark - |
82 #pragma mark - |
82 #pragma mark View Management |
83 #pragma mark View Management |
83 -(void) viewDidLoad { |
84 -(void) viewDidLoad { |
|
85 isAttacking = NO; |
|
86 |
|
87 // i called it a popover even on the iphone |
84 isPopoverVisible = NO; |
88 isPopoverVisible = NO; |
85 self.view.alpha = 0; |
89 self.view.alpha = 0; |
86 self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); |
90 self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); |
87 |
91 |
88 // set initial orientation |
92 // set initial orientation wrt the controller orientation |
89 UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
93 UIDeviceOrientation orientation = self.interfaceOrientation; |
90 UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG]; |
94 UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG]; |
91 switch (orientation) { |
95 switch (orientation) { |
92 case UIDeviceOrientationLandscapeLeft: |
96 case UIDeviceOrientationLandscapeLeft: |
93 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
97 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
94 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); |
98 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); |
96 case UIDeviceOrientationLandscapeRight: |
100 case UIDeviceOrientationLandscapeRight: |
97 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
101 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
98 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); |
102 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); |
99 break; |
103 break; |
100 default: |
104 default: |
|
105 DLog(@"unknown orientation"); |
101 break; |
106 break; |
102 } |
107 } |
103 CGRect rect = [[UIScreen mainScreen] bounds]; |
108 CGRect rect = [[UIScreen mainScreen] bounds]; |
104 self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height); |
109 self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height); |
105 |
110 |
216 |
222 |
217 UIButton *theButton = (UIButton *)sender; |
223 UIButton *theButton = (UIButton *)sender; |
218 |
224 |
219 switch (theButton.tag) { |
225 switch (theButton.tag) { |
220 case 0: |
226 case 0: |
221 HW_walkLeft(); |
227 if (isAttacking == NO) |
|
228 HW_walkLeft(); |
222 break; |
229 break; |
223 case 1: |
230 case 1: |
224 HW_walkRight(); |
231 if (isAttacking == NO) |
|
232 HW_walkRight(); |
225 break; |
233 break; |
226 case 2: |
234 case 2: |
227 [self performSelector:@selector(unsetPreciseStatus) withObject:nil afterDelay:0.8]; |
235 [self performSelector:@selector(unsetPreciseStatus) withObject:nil afterDelay:0.8]; |
228 HW_preciseSet(YES); |
236 HW_preciseSet(!HW_isWeaponRope()); |
229 HW_aimUp(); |
237 HW_aimUp(); |
230 break; |
238 break; |
231 case 3: |
239 case 3: |
232 [self performSelector:@selector(unsetPreciseStatus) withObject:nil afterDelay:0.8]; |
240 [self performSelector:@selector(unsetPreciseStatus) withObject:nil afterDelay:0.8]; |
233 HW_preciseSet(YES); |
241 HW_preciseSet(!HW_isWeaponRope()); |
234 HW_aimDown(); |
242 HW_aimDown(); |
235 break; |
243 break; |
236 case 4: |
244 case 4: |
237 HW_shoot(); |
245 HW_shoot(); |
|
246 isAttacking = YES; |
238 break; |
247 break; |
239 case 5: |
248 case 5: |
240 HW_jump(); |
249 HW_jump(); |
241 break; |
250 break; |
242 case 6: |
251 case 6: |
243 HW_backjump(); |
252 HW_backjump(); |
244 break; |
|
245 case 7: |
|
246 HW_tab(); |
|
247 break; |
253 break; |
248 case 10: |
254 case 10: |
249 HW_pause(); |
255 HW_pause(); |
250 removeConfirmationInput(); |
256 removeConfirmationInput(); |
251 [self showPopover]; |
257 [self showPopover]; |
526 |
532 |
527 void stopSpinning() { |
533 void stopSpinning() { |
528 UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[[[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG] viewWithTag:987654]; |
534 UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[[[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG] viewWithTag:987654]; |
529 [indicator stopAnimating]; |
535 [indicator stopAnimating]; |
530 isGameRunning = YES; |
536 isGameRunning = YES; |
|
537 HW_zoomSet(1.7); |
531 } |
538 } |
532 |
539 |
533 void clearView() { |
540 void clearView() { |
534 UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
541 UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow]; |
535 UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG]; |
542 UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG]; |