1 /* |
1 /* |
2 SDL - Simple DirectMedia Layer |
2 SDL - Simple DirectMedia Layer |
3 Copyright (C) 1997-2009 Sam Lantinga |
3 Copyright (C) 1997-2009 Sam Lantinga |
4 |
4 |
5 This library is free software; you can redistribute it and/or |
5 This library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Lesser General Public |
6 modify it under the terms of the GNU Lesser General Public |
7 License as published by the Free Software Foundation; either |
7 License as published by the Free Software Foundation; either |
8 version 2.1 of the License, or (at your option) any later version. |
8 version 2.1 of the License, or (at your option) any later version. |
9 |
9 |
10 This library is distributed in the hope that it will be useful, |
10 This library is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 Lesser General Public License for more details. |
13 Lesser General Public License for more details. |
14 |
14 |
15 You should have received a copy of the GNU Lesser General Public |
15 You should have received a copy of the GNU Lesser General Public |
16 License along with this library; if not, write to the Free Software |
16 License along with this library; if not, write to the Free Software |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 |
18 |
19 Sam Lantinga, mods for Hedgewars by Vittorio Giovara |
19 Sam Lantinga, mods for Hedgewars by Vittorio Giovara |
20 slouken@libsdl.org, vittorio.giovara@gmail.com |
20 slouken@libsdl.org, vittorio.giovara@gmail.com |
21 */ |
21 */ |
22 |
22 |
23 #import "SDL_uikitappdelegate.h" |
23 #import "SDL_uikitappdelegate.h" |
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 -(IBAction) startSDLgame: (NSDictionary *)gameDictionary { |
82 // pull out useful configuration info from various files |
82 // pull out useful configuration info from various files |
83 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
83 GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary]; |
84 |
84 |
85 [setup startThread:@"engineProtocol"]; |
85 [setup startThread:@"engineProtocol"]; |
86 const char **gameArgs = [setup getSettings]; |
86 const char **gameArgs = [setup getSettings]; |
87 [setup release]; |
87 [setup release]; |
88 |
88 |
89 // since the sdlwindow is not yet created, we add the overlayController with a delay |
89 // since the sdlwindow is not yet created, we add the overlayController with a delay |
90 [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.1]; |
90 [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.1]; |
91 |
91 |
92 // this is the pascal fuction that starts the game (wrapped around isInGame) |
92 // this is the pascal fuction that starts the game (wrapped around isInGame) |
93 isInGame = YES; |
93 isInGame = YES; |
94 Game(gameArgs); |
94 Game(gameArgs); |
95 isInGame = NO; |
95 isInGame = NO; |
96 free(gameArgs); |
96 free(gameArgs); |
97 |
97 |
98 // bring the uiwindow below in front |
98 // bring the uiwindow below in front |
99 UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; |
99 UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; |
100 [aWin makeKeyAndVisible]; |
100 [aWin makeKeyAndVisible]; |
101 |
101 |
102 // notice that in the simulator this reports 2 windows |
102 // notice that in the simulator this reports 2 windows |
103 DLog(@"%@",[[UIApplication sharedApplication] windows]); |
103 DLog(@"%@",[[UIApplication sharedApplication] windows]); |
104 } |
104 } |
105 |
105 |
106 -(void) displayOverlayLater { |
106 -(void) displayOverlayLater { |
112 [overlayController release]; |
112 [overlayController release]; |
113 } |
113 } |
114 |
114 |
115 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib) |
115 // override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib) |
116 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
116 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
117 [application setStatusBarHidden:YES]; |
117 [application setStatusBarHidden:YES]; |
118 |
118 |
119 UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
119 UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
120 |
120 |
121 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
121 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
122 self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil]; |
122 self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil]; |
123 else |
123 else |
124 self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil]; |
124 self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil]; |
125 |
125 |