Feel free to customize this file to suit your needs
*/
-#include "SDL/SDL.h"
+#include "SDL.h"
#include "SDLMain.h"
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
{
const NSDictionary *dict;
NSString *appName = 0;
-
+
/* Determine the application name */
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict)
if (![appName length])
appName = [[NSProcessInfo processInfo] processName];
-
+
return appName;
}
NSRange aRange;
NSEnumerator *enumerator;
NSMenuItem *menuItem;
-
+
aRange = [[aMenu title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
-
+
enumerator = [[aMenu itemArray] objectEnumerator];
while ((menuItem = [enumerator nextObject]))
{
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
-
+
[appleMenu addItem:[NSMenuItem separatorItem]];
-
+
title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
+
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
-
+
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
+
[appleMenu addItem:[NSMenuItem separatorItem]];
-
+
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
+
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
[[NSApp mainMenu] addItem:menuItem];
-
+
/* Tell the application object that this is now the application menu */
[NSApp setAppleMenu:appleMenu];
-
+
/* Finally give up our references to the objects */
[appleMenu release];
[menuItem release];
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
-
+
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
-
+
/* Finally give up our references to the objects */
[windowMenu release];
[windowMenuItem release];
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDLMain *sdlMain;
-
+
/* Ensure the application object is initialised */
[NSApplication sharedApplication];
[NSApplication sharedApplication];
}
#endif /* SDL_USE_CPS */
-
+
/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
setApplicationMenu();
setupWindowMenu();
-
+
/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
size_t arglen;
char *arg;
char **newargv;
-
+
if (!gFinderLaunch) /* MacOS is passing command line args. */
return FALSE;
-
+
if (gCalledAppMainline) /* app has started, ignore this document. */
return FALSE;
-
+
temparg = [filename 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)
{
return FALSE;
}
gArgv = newargv;
-
+
SDL_strlcpy(arg, temparg, arglen);
gArgv[gArgc++] = arg;
gArgv[gArgc] = NULL;
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
int status;
-
+
/* Set the working directory to the .app's parent directory */
[self setupWorkingDirectory:gFinderLaunch];
-
+
#if SDL_USE_NIB_FILE
/* Set the main menu to contain the real app name instead of "SDL App" */
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
#endif
-
+
/* Hand off to main application code */
gCalledAppMainline = TRUE;
status = SDL_main (gArgc, gArgv);
-
+
/* We're done, thank you for playing */
exit(status);
}
unichar *buffer;
NSRange localRange;
NSString *result;
-
+
bufferSize = selfLen + aStringLen - aRange.length;
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
localRange.location = 0;
localRange.length = aStringLen;
[aString getCharacters:(buffer+aRange.location) range:localRange];
-
+
/* Get last part into buffer */
localRange.location = aRange.location + aRange.length;
localRange.length = selfLen - localRange.location;
gArgv[i] = argv[i];
gFinderLaunch = NO;
}
-
+
#if SDL_USE_NIB_FILE
NSApplicationMain (argc, argv);
#else