equal
deleted
inserted
replaced
21 |
21 |
22 #import "GameInterfaceBridge.h" |
22 #import "GameInterfaceBridge.h" |
23 #import "PascalImports.h" |
23 #import "PascalImports.h" |
24 #import "EngineProtocolNetwork.h" |
24 #import "EngineProtocolNetwork.h" |
25 #import "OverlayViewController.h" |
25 #import "OverlayViewController.h" |
|
26 #import "StatsPageViewController.h" |
26 |
27 |
27 @implementation GameInterfaceBridge |
28 @implementation GameInterfaceBridge |
28 @synthesize parentController, systemSettings, savePath, overlayController, engineProtocol, ipcPort, gameType; |
29 @synthesize parentController, systemSettings, savePath, overlayController, engineProtocol, ipcPort, gameType; |
29 |
30 |
30 -(id) initWithController:(id) viewController { |
31 -(id) initWithController:(id) viewController { |
169 [blackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
170 [blackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
170 [blackView release]; |
171 [blackView release]; |
171 |
172 |
172 // the overlay is not needed any more and can be removed |
173 // the overlay is not needed any more and can be removed |
173 [self.overlayController removeOverlay]; |
174 [self.overlayController removeOverlay]; |
|
175 |
|
176 // warn our host that it's going to be visible again |
|
177 [self.parentController viewWillAppear:YES]; |
174 } |
178 } |
175 |
179 |
176 // set up variables for a local game |
180 // set up variables for a local game |
177 -(void) startLocalGame:(NSDictionary *)withDictionary { |
181 -(void) startLocalGame:(NSDictionary *)withDictionary { |
178 self.gameType = gtLocal; |
182 self.gameType = gtLocal; |
181 [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"]; |
185 [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"]; |
182 NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]]; |
186 NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]]; |
183 self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString]; |
187 self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString]; |
184 [outputFormatter release]; |
188 [outputFormatter release]; |
185 |
189 |
|
190 // in the rare case in which a savefile with the same name exists the older one must be removed (or it gets corrupted) |
|
191 if ([[NSFileManager defaultManager] fileExistsAtPath:self.savePath]) |
|
192 [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil]; |
|
193 |
186 [self.engineProtocol spawnThread:self.savePath withOptions:withDictionary]; |
194 [self.engineProtocol spawnThread:self.savePath withOptions:withDictionary]; |
187 [self prepareEngineLaunch]; |
195 [self prepareEngineLaunch]; |
188 } |
196 } |
189 |
197 |
190 // set up variables for a save game |
198 // set up variables for a save game |
195 [self.engineProtocol spawnThread:self.savePath]; |
203 [self.engineProtocol spawnThread:self.savePath]; |
196 [self prepareEngineLaunch]; |
204 [self prepareEngineLaunch]; |
197 } |
205 } |
198 |
206 |
199 -(void) gameHasEndedWithStats:(NSArray *)stats { |
207 -(void) gameHasEndedWithStats:(NSArray *)stats { |
200 DLog(@"%@",stats); |
208 // display stats page |
|
209 if (stats != nil) { |
|
210 StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
211 statsPage.statsArray = stats; |
|
212 statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical; |
|
213 if ([statsPage respondsToSelector:@selector(setModalPresentationStyle:)]) |
|
214 statsPage.modalPresentationStyle = UIModalPresentationPageSheet; |
|
215 |
|
216 [self.parentController presentModalViewController:statsPage animated:YES]; |
|
217 [statsPage release]; |
|
218 } |
201 |
219 |
202 // can remove the savefile if the replay has ended |
220 // can remove the savefile if the replay has ended |
203 if (self.gameType == gtSave) |
221 if (self.gameType == gtSave) |
204 [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil]; |
222 [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil]; |
205 } |
223 } |