116 [UIView commitAnimations]; |
116 [UIView commitAnimations]; |
117 [secondBlackView release]; |
117 [secondBlackView release]; |
118 } |
118 } |
119 [blackView release]; |
119 [blackView release]; |
120 |
120 |
|
121 |
121 // pull out useful configuration info from various files |
122 // pull out useful configuration info from various files |
122 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
123 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
123 NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"]; |
124 NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"]; |
124 |
125 |
125 [NSThread detachNewThreadSelector:@selector(engineProtocol) |
126 [NSThread detachNewThreadSelector:@selector(engineProtocol) |
126 toTarget:setup |
127 toTarget:setup |
127 withObject:nil]; |
128 withObject:nil]; |
128 |
129 |
129 const char **gameArgs = [setup getSettings:[gameDictionary objectForKey:@"savefile"]]; |
|
130 NSNumber *menuStyle = [NSNumber numberWithBool:setup.menuStyle]; |
130 NSNumber *menuStyle = [NSNumber numberWithBool:setup.menuStyle]; |
131 [setup release]; |
131 NSNumber *orientation = [[gameDictionary objectForKey:@"game_dictionary"] objectForKey:@"orientation"]; |
132 |
|
133 // since the sdlwindow is not yet created, we add the overlayController with a delay |
|
134 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: |
132 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: |
135 isNetGameNum,@"net", |
133 isNetGameNum,@"net", |
136 menuStyle,@"menu", |
134 menuStyle,@"menu", |
137 [[gameDictionary objectForKey:@"game_dictionary"] objectForKey:@"orientation"],@"orientation", |
135 orientation,@"orientation", |
138 nil]; |
136 nil]; |
139 [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1]; |
137 [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1]; |
140 |
138 |
141 // this is the pascal fuction that starts the game (wrapped around isInGame) |
139 // need to set again [gameDictionary objectForKey:@"savefile"] because if it's empty it means it's a normal game |
|
140 const char **gameArgs = [setup getGameSettings:[gameDictionary objectForKey:@"savefile"]]; |
142 self.isInGame = YES; |
141 self.isInGame = YES; |
|
142 // this is the pascal fuction that starts the game |
143 Game(gameArgs); |
143 Game(gameArgs); |
144 self.isInGame = NO; |
144 self.isInGame = NO; |
145 free(gameArgs); |
145 free(gameArgs); |
|
146 |
|
147 NSDictionary *stat = setup.statsDictionary; |
|
148 [setup release]; |
|
149 |
146 |
150 |
147 [self.uiwindow makeKeyAndVisible]; |
151 [self.uiwindow makeKeyAndVisible]; |
148 [self.uiwindow bringSubviewToFront:self.mainViewController.view]; |
152 [self.uiwindow bringSubviewToFront:self.mainViewController.view]; |
149 |
153 |
150 UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG]; |
154 UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG]; |
154 refBlackView.alpha = 0; |
158 refBlackView.alpha = 0; |
155 refSecondBlackView.alpha = 0; |
159 refSecondBlackView.alpha = 0; |
156 [UIView commitAnimations]; |
160 [UIView commitAnimations]; |
157 [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
161 [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
158 [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2]; |
162 [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2]; |
159 } |
163 |
160 |
164 DLog(@"%@",stat); |
161 // overlay with controls, become visible later, with a transparency effect |
165 } |
|
166 |
|
167 // overlay with controls, become visible later, with a transparency effect since the sdlwindow is not yet created |
162 -(void) displayOverlayLater:(id) object { |
168 -(void) displayOverlayLater:(id) object { |
163 NSDictionary *dict = (NSDictionary *)object; |
169 NSDictionary *dict = (NSDictionary *)object; |
164 self.overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
170 self.overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
165 self.overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue]; |
171 self.overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue]; |
166 self.overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue]; |
172 self.overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue]; |