cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
changeset 3316 52f0482b043f
parent 3305 91074496d5c9
child 3317 198ec44b6d92
equal deleted inserted replaced
3315:4e2813713358 3316:52f0482b043f
    33 
    33 
    34 #ifdef main
    34 #ifdef main
    35 #undef main
    35 #undef main
    36 #endif
    36 #endif
    37 
    37 
       
    38 #define VALGRIND "/opt/valgrind/bin/valgrind"
       
    39 
    38 int main (int argc, char *argv[]) {
    40 int main (int argc, char *argv[]) {
       
    41 #ifdef VALGRIND_REXEC
       
    42     // Using the valgrind build config, rexec ourself in valgrind
       
    43     // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
       
    44     if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0)) {
       
    45         execl(VALGRIND, VALGRIND, "--leak-check=full", "--show-reachable=yes", argv[0], "-valgrind", NULL);
       
    46     }
       
    47 #endif
       
    48 
    39 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    49 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    40 	int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate");
    50 	int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate");
    41 	[pool release];
    51 	[pool release];
    42 	return retVal;
    52 	return retVal;
    43 }
    53 }
    44 
    54 
    45 @implementation SDLUIKitDelegate
    55 @implementation SDLUIKitDelegate
    46 @synthesize uiwindow, window, viewController, overlayController;
    56 @synthesize uiwindow, window, viewController;
    47 
    57 
    48 // convenience method
    58 // convenience method
    49 +(SDLUIKitDelegate *)sharedAppDelegate {
    59 +(SDLUIKitDelegate *)sharedAppDelegate {
    50 	// the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    60 	// the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
    51 	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    61 	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
    54 -(id) init {
    64 -(id) init {
    55 	if (self = [super init]){
    65 	if (self = [super init]){
    56         self.uiwindow = nil;
    66         self.uiwindow = nil;
    57         self.window = NULL;
    67         self.window = NULL;
    58         self.viewController = nil;
    68         self.viewController = nil;
    59         self.overlayController = nil;
       
    60         isInGame = NO;
    69         isInGame = NO;
    61         return self;
    70         return self;
    62     } else 
    71     } else 
    63         return nil;
    72         return nil;
    64 }
    73 }
    76 	GameSetup *setup = [[GameSetup alloc] init];
    85 	GameSetup *setup = [[GameSetup alloc] init];
    77 	[setup startThread:@"engineProtocol"];
    86 	[setup startThread:@"engineProtocol"];
    78 	const char **gameArgs = [setup getSettings];
    87 	const char **gameArgs = [setup getSettings];
    79 	[setup release];
    88 	[setup release];
    80     
    89     
       
    90     OverlayViewController *overlayController;
    81     // overlay with controls, become visible after 2 seconds
    91     // overlay with controls, become visible after 2 seconds
    82     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    92     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    83         overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController-iPad" bundle:nil];
    93         overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController-iPad" bundle:nil];
    84     else
    94     else
    85         overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController-iPhone" bundle:nil];
    95         overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController-iPhone" bundle:nil];