116 NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"]; |
116 NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"]; |
117 |
117 |
118 if ([isNetGameNum boolValue] == NO) |
118 if ([isNetGameNum boolValue] == NO) |
119 [setup startThread:@"engineProtocol"]; |
119 [setup startThread:@"engineProtocol"]; |
120 const char **gameArgs = [setup getSettings:[gameDictionary objectForKey:@"savefile"]]; |
120 const char **gameArgs = [setup getSettings:[gameDictionary objectForKey:@"savefile"]]; |
|
121 NSNumber *menuStyle = [NSNumber numberWithBool:setup.menuStyle]; |
121 [setup release]; |
122 [setup release]; |
122 |
123 |
123 // since the sdlwindow is not yet created, we add the overlayController with a delay |
124 // since the sdlwindow is not yet created, we add the overlayController with a delay |
124 [self performSelector:@selector(displayOverlayLater:) withObject:isNetGameNum afterDelay:0.1]; |
125 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:isNetGameNum,@"net",menuStyle,@"menu",nil]; |
|
126 [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:0.1]; |
125 |
127 |
126 // this is the pascal fuction that starts the game (wrapped around isInGame) |
128 // this is the pascal fuction that starts the game (wrapped around isInGame) |
127 isInGame = YES; |
129 isInGame = YES; |
128 Game(gameArgs); |
130 Game(gameArgs); |
129 isInGame = NO; |
131 isInGame = NO; |
130 free(gameArgs); |
132 free(gameArgs); |
131 |
133 |
132 [uiwindow makeKeyAndVisible]; |
134 [self.uiwindow makeKeyAndVisible]; |
|
135 [self.uiwindow bringSubviewToFront:self.mainViewController.view]; |
133 |
136 |
134 UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG]; |
137 UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG]; |
135 UIView *refSecondBlackView = [self.uiwindow viewWithTag:SECONDBLACKVIEW_TAG]; |
138 UIView *refSecondBlackView = [self.uiwindow viewWithTag:SECONDBLACKVIEW_TAG]; |
136 [UIView beginAnimations:@"fading in from ingame" context:NULL]; |
139 [UIView beginAnimations:@"fading in from ingame" context:NULL]; |
137 [UIView setAnimationDuration:1]; |
140 [UIView setAnimationDuration:1]; |
141 [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
144 [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
142 [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
145 [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
143 } |
146 } |
144 |
147 |
145 // overlay with controls, become visible later, with a transparency effect |
148 // overlay with controls, become visible later, with a transparency effect |
146 -(void) displayOverlayLater:(NSNumber *)isNetGame { |
149 -(void) displayOverlayLater:(id) object { |
|
150 NSDictionary *dict = (NSDictionary *)object; |
147 OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
151 OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
148 |
152 overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue]; |
|
153 overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue]; |
|
154 |
149 UIWindow *gameWindow; |
155 UIWindow *gameWindow; |
150 if ([[UIScreen screens] count] > 1) |
156 if ([[UIScreen screens] count] > 1) |
151 gameWindow = self.uiwindow; |
157 gameWindow = self.uiwindow; |
152 else |
158 else |
153 gameWindow = [[UIApplication sharedApplication] keyWindow]; |
159 gameWindow = [[UIApplication sharedApplication] keyWindow]; |
169 [self.uiwindow addSubview:self.mainViewController.view]; |
175 [self.uiwindow addSubview:self.mainViewController.view]; |
170 [self.mainViewController release]; |
176 [self.mainViewController release]; |
171 self.uiwindow.backgroundColor = [UIColor blackColor]; |
177 self.uiwindow.backgroundColor = [UIColor blackColor]; |
172 [self.uiwindow makeKeyAndVisible]; |
178 [self.uiwindow makeKeyAndVisible]; |
173 |
179 |
174 if ([[UIScreen screens]count] > 1) { |
180 // set working directory to resource path |
175 /* |
181 [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]]; |
176 CGSize maxSize = CGSizeZero; |
182 |
177 UIScreenMode *screenMode = nil; |
183 // check for dual monitor support |
178 for (UIScreenMode *mode in [[[UIScreen screens] objectAtIndex:1] availableModes]) { |
184 if ([[UIScreen screens] count] > 1) { |
179 if (mode.size.width > maxSize.width) { |
|
180 maxSize = mode.size; |
|
181 screenMode = mode; |
|
182 } |
|
183 } |
|
184 */ |
|
185 DLog(@"dual head mode ftw"); |
185 DLog(@"dual head mode ftw"); |
186 self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]]; |
186 self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]]; |
187 self.secondWindow.backgroundColor = [UIColor blackColor]; |
187 self.secondWindow.backgroundColor = [UIColor blackColor]; |
188 self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1]; |
188 self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1]; |
189 UIImage *titleImage = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"title.png"]]; |
189 UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"]; |
190 UIImageView *titleView = [[UIImageView alloc] initWithImage:titleImage]; |
190 UIImageView *titleView = [[UIImageView alloc] initWithImage:titleImage]; |
191 titleView.center = self.secondWindow.center; |
191 titleView.center = self.secondWindow.center; |
192 [self.secondWindow addSubview:titleView]; |
192 [self.secondWindow addSubview:titleView]; |
193 [titleView release]; |
193 [titleView release]; |
194 [self.secondWindow makeKeyAndVisible]; |
194 [self.secondWindow makeKeyAndVisible]; |
195 } |
195 } |
196 |
|
197 // set working directory to resource path |
|
198 [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]]; |
|
199 } |
196 } |
200 |
197 |
201 -(void) applicationWillTerminate:(UIApplication *)application { |
198 -(void) applicationWillTerminate:(UIApplication *)application { |
202 SDL_SendQuit(); |
199 SDL_SendQuit(); |
203 |
200 |