53 } |
53 } |
54 |
54 |
55 #pragma mark - |
55 #pragma mark - |
56 // overlay with controls, become visible later, with a transparency effect since the sdlwindow is not yet created |
56 // overlay with controls, become visible later, with a transparency effect since the sdlwindow is not yet created |
57 -(void) displayOverlayLater:(id) object { |
57 -(void) displayOverlayLater:(id) object { |
58 [self.overlayController setInitialOrientation:self.parentController.interfaceOrientation]; |
58 // in order to get rotation events we have to insert the view inside the first view of the second window |
59 |
59 // when multihead we have to make sure that overlay is displayed in the touch-enabled window |
60 UIWindow *gameWindow = (IS_DUALHEAD() ? [HedgewarsAppDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow]); |
60 UIView *injected = (IS_DUALHEAD() ? self.parentController.view : UIVIEW_HW_SDLVIEW); |
61 [gameWindow addSubview:self.overlayController.view]; |
61 [injected addSubview:self.overlayController.view]; |
62 } |
62 } |
63 |
63 |
64 // main routine for calling the actual game engine |
64 // main routine for calling the actual game engine |
65 -(void) startGameEngine { |
65 -(void) startGameEngine { |
66 const char *gameArgs[11]; |
66 const char *gameArgs[11]; |
67 NSInteger width, height, orientation; |
67 NSInteger width, height; |
68 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", self.ipcPort]; |
68 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", self.ipcPort]; |
69 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
69 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
70 NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
70 NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
71 |
71 |
72 if (IS_DUALHEAD()) { |
72 if (IS_DUALHEAD()) { |
73 CGRect screenBounds = [[[UIScreen screens] objectAtIndex:1] bounds]; |
73 CGRect screenBounds = [[[UIScreen screens] objectAtIndex:1] bounds]; |
74 width = (int) screenBounds.size.width; |
74 width = (int) screenBounds.size.width; |
75 height = (int) screenBounds.size.height; |
75 height = (int) screenBounds.size.height; |
76 orientation = 0; |
|
77 } else { |
76 } else { |
78 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
77 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
79 width = (int) screenBounds.size.height; |
78 width = (int) screenBounds.size.height; |
80 height = (int) screenBounds.size.width; |
79 height = (int) screenBounds.size.width; |
81 orientation = (self.parentController.interfaceOrientation == UIDeviceOrientationLandscapeLeft) ? -90 : 90; |
|
82 } |
80 } |
83 |
81 |
84 NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width]; |
82 NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width]; |
85 NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height]; |
83 NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height]; |
86 NSString *rotation = [[NSString alloc] initWithFormat:@"%d", orientation]; |
84 NSString *rotation = [[NSString alloc] initWithString:@"0"]; |
87 BOOL enhanced = [[settings objectForKey:@"enhanced"] boolValue]; |
85 BOOL enhanced = [[settings objectForKey:@"enhanced"] boolValue]; |
88 |
86 |
89 NSString *modelId = getModelType(); |
87 NSString *modelId = getModelType(); |
90 NSInteger tmpQuality; |
88 NSInteger tmpQuality; |
91 if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G |
89 if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G |