mirror of
https://github.com/love2d/love.git
synced 2026-08-20 12:40:20 +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:
+39
-30
@@ -384,41 +384,16 @@ 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;
|
||||||
|
}
|
||||||
/* check to see if there are any .love files in Resources - props to stevejohnson/diordna */
|
else
|
||||||
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 {
|
|
||||||
int i;
|
int i;
|
||||||
gArgc = argc;
|
gArgc = argc;
|
||||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||||
@@ -427,6 +402,40 @@ int main (int argc, char **argv)
|
|||||||
gFinderLaunch = NO;
|
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
|
#if SDL_USE_NIB_FILE
|
||||||
[SDLApplication poseAsClass:[NSApplication class]];
|
[SDLApplication poseAsClass:[NSApplication class]];
|
||||||
NSApplicationMain (argc, argv);
|
NSApplicationMain (argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user