mirror of
https://github.com/love2d/love.git
synced 2026-08-20 20:49:54 +02:00
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
This commit is contained in:
+21
-12
@@ -384,19 +384,31 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
/* Copy the arguments into a global variable */
|
/* Copy the arguments into a global variable */
|
||||||
/* This is passed if we are launched by double-clicking */
|
/* 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 = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||||
gArgv[0] = argv[0];
|
gArgv[0] = argv[0];
|
||||||
gArgv[1] = NULL;
|
gArgv[1] = NULL;
|
||||||
gArgc = 1;
|
gArgc = 1;
|
||||||
gFinderLaunch = YES;
|
gFinderLaunch = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
gArgc = argc;
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||||
|
for (i = 0; i <= argc; i++)
|
||||||
|
gArgv[i] = argv[i];
|
||||||
|
gFinderLaunch = NO;
|
||||||
|
}
|
||||||
|
|
||||||
/* check to see if there are any .love files in Resources - props to stevejohnson/diordna */
|
/* check to see if there are any .love files in Resources - props to stevejohnson/diordna */
|
||||||
NSArray *lovePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"love" inDirectory:nil];
|
NSArray *lovePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"love" inDirectory:nil];
|
||||||
if ([lovePaths count] > 0) { /* there are, load the first one we found and run it */
|
|
||||||
|
if ([lovePaths count] > 0) /* there are, load the first one we found and run it */
|
||||||
|
{
|
||||||
NSString *firstLovePath = [lovePaths objectAtIndex:0];
|
NSString *firstLovePath = [lovePaths objectAtIndex:0];
|
||||||
gCalledAppMainline = YES;
|
gCalledAppMainline = YES;
|
||||||
//NSLog(firstLovePath);
|
|
||||||
|
|
||||||
const char *temparg;
|
const char *temparg;
|
||||||
size_t arglen;
|
size_t arglen;
|
||||||
@@ -405,27 +417,24 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
temparg = [firstLovePath UTF8String];
|
temparg = [firstLovePath UTF8String];
|
||||||
arglen = SDL_strlen(temparg) + 1;
|
arglen = SDL_strlen(temparg) + 1;
|
||||||
|
|
||||||
arg = (char *)SDL_malloc(arglen);
|
arg = (char *)SDL_malloc(arglen);
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
newargv = (char **)realloc(gArgv, sizeof(char *) * (gArgc + 2));
|
newargv = (char **)realloc(gArgv, sizeof(char *) * (gArgc + 2));
|
||||||
if (newargv == NULL) {
|
if (newargv == NULL)
|
||||||
|
{
|
||||||
SDL_free(arg);
|
SDL_free(arg);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gArgv = newargv;
|
gArgv = newargv;
|
||||||
SDL_strlcpy(arg, temparg, arglen);
|
SDL_strlcpy(arg, temparg, arglen);
|
||||||
gArgv[gArgc++] = arg;
|
gArgv[gArgc++] = arg;
|
||||||
|
gArgv[gArgc++] = "--fused"; // run in pseudo-fused mode
|
||||||
gArgv[gArgc] = NULL;
|
gArgv[gArgc] = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
int i;
|
|
||||||
gArgc = argc;
|
|
||||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
|
||||||
for (i = 0; i <= argc; i++)
|
|
||||||
gArgv[i] = argv[i];
|
|
||||||
gFinderLaunch = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SDL_USE_NIB_FILE
|
#if SDL_USE_NIB_FILE
|
||||||
[SDLApplication poseAsClass:[NSApplication class]];
|
[SDLApplication poseAsClass:[NSApplication class]];
|
||||||
|
|||||||
Reference in New Issue
Block a user