Browse Source

OS X: fixed fused release mode when the .love file is in love.app/Contents/Resources, fixed auto-detection of .love file in Contents/Resources when the love executable binary is run directly

Alex Szpakowski 12 years ago
parent
commit
c730906c26
1 changed files with 39 additions and 30 deletions
  1. 39 30
      platform/macosx/SDLMain.m

+ 39 - 30
platform/macosx/SDLMain.m

@@ -384,41 +384,16 @@ int main (int argc, char **argv)
 {
     /* Copy the arguments into a global variable */
     /* This is passed if we are launched by double-clicking */
-    if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
+    if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0)
+	{
         gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
         gArgv[0] = argv[0];
         gArgv[1] = NULL;
         gArgc = 1;
         gFinderLaunch = YES;
-		
-		/* check to see if there are any .love files in Resources - props to stevejohnson/diordna */
-		NSArray *lovePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"love" inDirectory:nil];
-		if ([lovePaths count] > 0) { /* there are, load the first one we found and run it */
-			NSString *firstLovePath = [lovePaths objectAtIndex:0];
-			gCalledAppMainline = YES;
-			//NSLog(firstLovePath);
-			
-			const char *temparg;
-			size_t arglen;
-			char *arg;
-			char **newargv;
-			
-			temparg = [firstLovePath UTF8String];
-			arglen = SDL_strlen(temparg) + 1;
-			arg = (char *)SDL_malloc(arglen);
-			if (arg == NULL)
-				return FALSE;
-			newargv = (char **)realloc(gArgv, sizeof(char *) * (gArgc + 2));
-			if (newargv == NULL) {
-				SDL_free(arg);
-				return FALSE;
-			}
-			gArgv = newargv;
-			SDL_strlcpy(arg, temparg, arglen);
-			gArgv[gArgc++] = arg;
-			gArgv[gArgc] = NULL;
-		}
-    } else {
+    }
+	else
+	{
         int i;
         gArgc = argc;
         gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
@@ -427,6 +402,40 @@ int main (int argc, char **argv)
         gFinderLaunch = NO;
     }
 
+	/* check to see if there are any .love files in Resources - props to stevejohnson/diordna */
+	NSArray *lovePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"love" inDirectory:nil];
+
+	if ([lovePaths count] > 0) /* there are, load the first one we found and run it */
+	{
+		NSString *firstLovePath = [lovePaths objectAtIndex:0];
+		gCalledAppMainline = YES;
+
+		const char *temparg;
+		size_t arglen;
+		char *arg;
+		char **newargv;
+
+		temparg = [firstLovePath UTF8String];
+		arglen = SDL_strlen(temparg) + 1;
+
+		arg = (char *)SDL_malloc(arglen);
+		if (arg == NULL)
+			return FALSE;
+
+		newargv = (char **)realloc(gArgv, sizeof(char *) * (gArgc + 2));
+		if (newargv == NULL)
+		{
+			SDL_free(arg);
+			return FALSE;
+		}
+
+		gArgv = newargv;
+		SDL_strlcpy(arg, temparg, arglen);
+		gArgv[gArgc++] = arg;
+		gArgv[gArgc++] = "--fused"; // run in pseudo-fused mode
+		gArgv[gArgc] = NULL;
+	}
+
 #if SDL_USE_NIB_FILE
     [SDLApplication poseAsClass:[NSApplication class]];
     NSApplicationMain (argc, argv);