diff src/main/macosx/SDLMain.m @ 168:e92aa316c517

Added Max's patches for building MacOS X apps on command line
author Sam Lantinga <slouken@libsdl.org>
date Tue, 04 Sep 2001 23:18:45 +0000
parents 4382c38dfbee
children
line wrap: on
line diff
--- a/src/main/macosx/SDLMain.m	Tue Sep 04 22:53:46 2001 +0000
+++ b/src/main/macosx/SDLMain.m	Tue Sep 04 23:18:45 2001 +0000
@@ -12,6 +12,7 @@
 static int    gArgc;
 static char  **gArgv;
 static NSString *gAppName = 0;
+static BOOL   gFinderLaunch;
 
 @interface NSString (ReplaceSubString)
 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
@@ -29,15 +30,21 @@
     SDL_PushEvent(&event);
 }
 
+/* Invoked from the Make Full-Screen menu item */
+- (void) makeFullscreen:(id)sender
+{
+    /* TODO */
+}
+
 /* Set the working directory to the .app's parent directory */
-- (void) setupWorkingDirectory
+- (void) setupWorkingDirectory:(BOOL)shouldChdir
 {
     char parentdir[MAXPATHLEN];
     char *c;
     
     strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
     c = (char*) parentdir;
-    
+
     while (*c != '\0')     /* go to end */
         c++;
     
@@ -45,11 +52,13 @@
         c--;
     
     *c++ = '\0';             /* cut off last part (binary name) */
-    
-    assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
-    assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
-    
-    gAppName = [ NSString stringWithCString: c ];
+  
+    if (shouldChdir)
+    {
+      assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
+      assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
+    }
+    /* gAppName = [ NSString stringWithCString: c ]; */
 }
 
 /* Fix menu to contain the real app name instead of "SDL App" */
@@ -81,9 +90,10 @@
     int status;
 
     /* Set the working directory to the .app's parent directory */
-    [ self setupWorkingDirectory ];
+    [ self setupWorkingDirectory: gFinderLaunch ];
 
     /* Set the main menu to contain the real app name instead of "SDL App" */
+    gAppName = [ [ NSBundle mainBundle ] bundleIdentifier ];
     [ self fixMenu: [ NSApp mainMenu ] ];
 
     /* Hand off to main application code */
@@ -148,8 +158,10 @@
     /* This is passed if we are launched by double-clicking */
     if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
         gArgc = 1;
+	gFinderLaunch = YES;
     } else {
         gArgc = argc;
+	gFinderLaunch = NO;
     }
     gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
     assert (gArgv != NULL);