59 [UIView setAnimationDuration:0.8f]; |
59 [UIView setAnimationDuration:0.8f]; |
60 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; |
60 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; |
61 switch (orientation) { |
61 switch (orientation) { |
62 case UIDeviceOrientationLandscapeLeft: |
62 case UIDeviceOrientationLandscapeLeft: |
63 if (IS_DUALHEAD() == NO) |
63 if (IS_DUALHEAD() == NO) |
64 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
64 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
65 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); |
65 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); |
66 break; |
66 break; |
67 case UIDeviceOrientationLandscapeRight: |
67 case UIDeviceOrientationLandscapeRight: |
68 if (IS_DUALHEAD() == NO) |
68 if (IS_DUALHEAD() == NO) |
69 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
69 sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
70 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); |
70 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); |
|
71 break; |
|
72 case UIDeviceOrientationPortrait: |
|
73 if (IS_DUALHEAD()) |
|
74 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
|
75 break; |
|
76 case UIDeviceOrientationPortraitUpsideDown: |
|
77 if (IS_DUALHEAD()) |
|
78 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
71 break; |
79 break; |
72 default: |
80 default: |
73 // a debug log would spam too much |
81 // a debug log would spam too much |
74 break; |
82 break; |
75 } |
83 } |
|
84 if (self.amvc.isVisible) |
|
85 [self.amvc appearInView:self.view]; |
76 self.view.frame = usefulRect; |
86 self.view.frame = usefulRect; |
77 //sdlView.frame = usefulRect; |
|
78 [UIView commitAnimations]; |
87 [UIView commitAnimations]; |
|
88 |
|
89 // for single screens only landscape mode is supported |
|
90 // for dual screen mode the sdlview is not modified, but you can rotate the pad in any direction |
79 } |
91 } |
80 |
92 |
81 #pragma mark - |
93 #pragma mark - |
82 #pragma mark View Management |
94 #pragma mark View Management |
83 -(void) viewDidLoad { |
95 -(void) viewDidLoad { |
91 self.view.alpha = 0; |
103 self.view.alpha = 0; |
92 self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); |
104 self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); |
93 |
105 |
94 initialScreenCount = [[UIScreen screens] count]; |
106 initialScreenCount = [[UIScreen screens] count]; |
95 |
107 |
|
108 if (IS_DUALHEAD()) { |
|
109 // set initial orientation wrt the controller orientation |
|
110 switch (self.interfaceOrientation) { |
|
111 case UIDeviceOrientationLandscapeLeft: |
|
112 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); |
|
113 break; |
|
114 case UIDeviceOrientationLandscapeRight: |
|
115 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); |
|
116 break; |
|
117 case UIDeviceOrientationPortrait: |
|
118 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); |
|
119 break; |
|
120 case UIDeviceOrientationPortraitUpsideDown: |
|
121 self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); |
|
122 break; |
|
123 default: |
|
124 DLog(@"Nope"); |
|
125 break; |
|
126 } |
|
127 } |
96 CGRect screenRect = [[UIScreen mainScreen] bounds]; |
128 CGRect screenRect = [[UIScreen mainScreen] bounds]; |
97 self.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height); |
129 self.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height); |
98 |
130 |
99 dimTimer = [[NSTimer alloc] initWithFireDate:(IS_DUALHEAD()) ? HIDING_TIME_NEVER : [NSDate dateWithTimeIntervalSinceNow:6] |
131 dimTimer = [[NSTimer alloc] initWithFireDate:(IS_DUALHEAD()) ? HIDING_TIME_NEVER : [NSDate dateWithTimeIntervalSinceNow:6] |
100 interval:1000 |
132 interval:1000 |
101 target:self |
133 target:self |
102 selector:@selector(dimOverlay) |
134 selector:@selector(dimOverlay) |
103 userInfo:nil |
135 userInfo:nil |
104 repeats:YES]; |
136 repeats:YES]; |
105 |
137 |
106 // add timer too runloop, otherwise it doesn't work |
138 // add timer to runloop, otherwise it doesn't work |
107 [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode]; |
139 [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode]; |
108 |
140 |
109 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; |
141 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; |
110 [[NSNotificationCenter defaultCenter] addObserver:self |
142 [[NSNotificationCenter defaultCenter] addObserver:self |
111 selector:@selector(didRotate:) |
143 selector:@selector(didRotate:) |
321 removeConfirmationInput(); |
353 removeConfirmationInput(); |
322 |
354 |
323 if (IS_DUALHEAD() || self.useClassicMenu == NO) { |
355 if (IS_DUALHEAD() || self.useClassicMenu == NO) { |
324 if (self.amvc == nil) |
356 if (self.amvc == nil) |
325 self.amvc = [[AmmoMenuViewController alloc] init]; |
357 self.amvc = [[AmmoMenuViewController alloc] init]; |
326 |
358 |
327 if (self.amvc.isVisible) { |
359 if (self.amvc.isVisible) { |
328 doDim(); |
360 doDim(); |
329 [self.amvc disappear]; |
361 [self.amvc disappear]; |
330 } else { |
362 } else { |
331 doNotDim(); |
363 if (HW_isAmmoMenuNotAllowed() == NO) { |
332 [self.amvc appearInView:self.view]; |
364 doNotDim(); |
|
365 [self.amvc appearInView:self.view]; |
|
366 } |
333 } |
367 } |
334 } else { |
368 } else { |
335 HW_ammoMenu(); |
369 HW_ammoMenu(); |
336 } |
370 } |
337 break; |
371 break; |
450 return; |
484 return; |
451 |
485 |
452 switch ([allTouches count]) { |
486 switch ([allTouches count]) { |
453 case 1: |
487 case 1: |
454 // if we're in the menu we just click in the point |
488 // if we're in the menu we just click in the point |
455 if (HW_isAmmoOpen()) { |
489 if (HW_isAmmoMenuOpen()) { |
456 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); |
490 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); |
457 // this click doesn't need any wrapping because the ammoMenu already limits the cursor |
491 // this click doesn't need any wrapping because the ammoMenu already limits the cursor |
458 HW_click(); |
492 HW_click(); |
459 } else |
493 } else |
460 // if weapon requires a further click, ask for tapping again |
494 // if weapon requires a further click, ask for tapping again |
558 switch ([allTouches count]) { |
592 switch ([allTouches count]) { |
559 case 1: |
593 case 1: |
560 touch = [[allTouches allObjects] objectAtIndex:0]; |
594 touch = [[allTouches allObjects] objectAtIndex:0]; |
561 CGPoint currentPosition = [touch locationInView:self.view]; |
595 CGPoint currentPosition = [touch locationInView:self.view]; |
562 |
596 |
563 if (HW_isAmmoOpen()) { |
597 if (HW_isAmmoMenuOpen()) { |
564 // no zoom consideration for this |
598 // no zoom consideration for this |
565 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); |
599 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); |
566 } else |
600 } else |
567 if (HW_isWeaponRequiringClick()) { |
601 if (HW_isWeaponRequiringClick()) { |
568 // moves the cursor around wrt zoom |
602 // moves the cursor around wrt zoom |