64 [viewController release]; |
64 [viewController release]; |
65 [uiwindow release]; |
65 [uiwindow release]; |
66 [super dealloc]; |
66 [super dealloc]; |
67 } |
67 } |
68 |
68 |
69 #pragma mark - |
69 // main routine for calling the actual game engine |
70 #pragma mark Custom stuff |
|
71 -(IBAction) startSDLgame { |
70 -(IBAction) startSDLgame { |
|
71 [viewController disappear]; |
|
72 |
|
73 // pull out useful configuration info from various files |
72 GameSetup *setup = [[GameSetup alloc] init]; |
74 GameSetup *setup = [[GameSetup alloc] init]; |
73 [setup startThread:@"engineProtocol"]; |
75 [setup startThread:@"engineProtocol"]; |
74 |
|
75 [viewController disappear]; |
|
76 [viewController.view removeFromSuperview]; |
|
77 |
|
78 const char **gameArgs = [setup getSettings]; |
76 const char **gameArgs = [setup getSettings]; |
79 [setup release]; |
77 [setup release]; |
80 |
78 |
81 // overlay with controls, become visible after 2 seconds |
79 // overlay with controls, become visible after 2 seconds |
82 overlayController = [[overlayViewController alloc] initWithNibName:@"overlayViewController" bundle:nil]; |
80 overlayController = [[overlayViewController alloc] initWithNibName:@"overlayViewController" bundle:nil]; |
83 [uiwindow addSubview:overlayController.view]; |
81 [uiwindow addSubview:overlayController.view]; |
84 [NSTimer scheduledTimerWithTimeInterval:2 target:overlayController selector:@selector(showMenuAfterwards) userInfo:nil repeats:NO]; |
|
85 |
82 |
86 Game(gameArgs); // this is the pascal fuction that starts the game |
83 Game(gameArgs); // this is the pascal fuction that starts the game |
87 |
84 |
88 // let's clean memory |
85 free(gameArgs); |
89 free(gameArgs); |
|
90 [overlayController.view removeFromSuperview]; |
86 [overlayController.view removeFromSuperview]; |
91 [overlayController release]; |
87 [overlayController release]; |
92 |
88 |
93 [uiwindow addSubview:viewController.view]; |
|
94 [uiwindow makeKeyAndVisible]; |
|
95 |
|
96 [viewController appear]; |
89 [viewController appear]; |
97 } |
90 } |
98 |
91 |
99 -(NSString *)dataFilePath: (NSString *)fileName { |
92 // get a path-to-file string |
|
93 -(NSString *)dataFilePath:(NSString *)fileName { |
100 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
94 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
101 NSString *documentsDirectory = [paths objectAtIndex:0]; |
95 NSString *documentsDirectory = [paths objectAtIndex:0]; |
102 return [documentsDirectory stringByAppendingPathComponent:fileName]; |
96 return [documentsDirectory stringByAppendingPathComponent:fileName]; |
103 } |
97 } |
104 |
98 |
105 #pragma mark - |
|
106 #pragma mark SDLUIKitDelegate methods |
|
107 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) |
99 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) |
108 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
100 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
109 [application setStatusBarHidden:YES animated:NO]; |
101 [application setStatusBarHidden:YES animated:NO]; |
110 [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; |
102 [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; |
111 |
103 |
127 // hack to prevent automatic termination. See SDL_uikitevents.m for details |
119 // hack to prevent automatic termination. See SDL_uikitevents.m for details |
128 // have to remove this otherwise game goes on when pushing the home button |
120 // have to remove this otherwise game goes on when pushing the home button |
129 //longjmp(*(jump_env()), 1); |
121 //longjmp(*(jump_env()), 1); |
130 } |
122 } |
131 |
123 |
132 -(void) applicationWillResignActive:(UIApplication*)application { |
124 -(void) applicationWillResignActive:(UIApplication *)application { |
133 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
125 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
134 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); |
126 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); |
135 } |
127 } |
136 |
128 |
137 -(void) applicationDidBecomeActive:(UIApplication*)application { |
129 -(void) applicationDidBecomeActive:(UIApplication *)application { |
138 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
130 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
139 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0); |
131 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0); |
140 } |
132 } |
141 |
133 |
142 @end |
134 @end |