76 [mainViewController release]; |
76 [mainViewController release]; |
77 [super dealloc]; |
77 [super dealloc]; |
78 } |
78 } |
79 |
79 |
80 // main routine for calling the actual game engine |
80 // main routine for calling the actual game engine |
81 -(IBAction) startSDLgame: (NSDictionary *)gameDictionary { |
81 -(void) startSDLgame:(NSDictionary *)gameDictionary { |
|
82 UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)]; |
|
83 blackView.opaque = YES; |
|
84 blackView.backgroundColor = [UIColor blackColor]; |
|
85 [self.view addSubview:blackView]; |
|
86 |
82 // pull out useful configuration info from various files |
87 // pull out useful configuration info from various files |
83 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
88 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
84 |
89 NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"]; |
85 [setup startThread:@"engineProtocol"]; |
90 |
86 const char **gameArgs = [setup getSettings]; |
91 if ([isNetGameNum boolValue] == NO) |
|
92 [setup startThread:@"engineProtocol"]; |
|
93 const char **gameArgs = [setup getSettings:[gameDictionary objectForKey:@"savefile"]]; |
87 [setup release]; |
94 [setup release]; |
88 |
95 |
89 // since the sdlwindow is not yet created, we add the overlayController with a delay |
96 // since the sdlwindow is not yet created, we add the overlayController with a delay |
90 [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.1]; |
97 [self performSelector:@selector(displayOverlayLater:) withObject:isNetGameNum afterDelay:0.1]; |
91 |
98 |
92 // this is the pascal fuction that starts the game (wrapped around isInGame) |
99 // this is the pascal fuction that starts the game (wrapped around isInGame) |
93 isInGame = YES; |
100 isInGame = YES; |
94 Game(gameArgs); |
101 Game(gameArgs); |
95 isInGame = NO; |
102 isInGame = NO; |
96 free(gameArgs); |
103 free(gameArgs); |
97 |
104 |
98 // bring the uiwindow below in front |
105 UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; [aWin makeKeyAndVisible]; |
99 UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; |
106 [UIView beginAnimations:@"fading in from ingame" context:NULL]; |
100 [aWin makeKeyAndVisible]; |
107 [UIView setAnimationDuration:1]; |
101 |
108 blackView.alpha = 0; |
102 // notice that in the simulator this reports 2 windows |
109 [UIView commitAnimations]; |
103 DLog(@"%@",[[UIApplication sharedApplication] windows]); |
110 [blackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
|
111 [blackView performSelector:@selector(release) withObject:nil afterDelay:1]; |
104 } |
112 } |
105 |
113 |
106 -(void) displayOverlayLater { |
114 -(void) displayOverlayLater:(NSNumber *)isNetGame { |
107 // overlay with controls, become visible later, with a transparency effect |
115 // overlay with controls, become visible later, with a transparency effect |
108 OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
116 OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil]; |
109 |
117 |
110 // keyWindow is the frontmost window |
118 // keyWindow is the frontmost window |
111 [[[UIApplication sharedApplication] keyWindow] addSubview:overlayController.view]; |
119 [[[UIApplication sharedApplication] keyWindow] addSubview:overlayController.view]; |