Mercurial > sdl-ios-xcode
annotate src/main/macosx/SDLMain.m @ 390:19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
From: Darrell Walisser <dwaliss1@purdue.edu>
Subject: mac patch
In this patch:
- yuv code
- links to QuickTime
- tabs -> 4 spaces
- mouse events fix
- SDLMain path parsing fix
- BUGS updates
- some miscellaneous docs/comments/code cleanup
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 01 Jun 2002 23:05:05 +0000 |
parents | ca655a7a9d80 |
children | a7129c0083f4 |
rev | line source |
---|---|
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* SDLMain.m - main entry point for our Cocoa-ized SDL app |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
2 Initial Version: Darrell Walisser <dwaliss1@purdue.edu> |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
3 Non-NIB-Code & other changes: Max Horn <max@quendi.de> |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 Feel free to customize this file to suit your needs |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #import "SDL.h" |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 #import "SDLMain.h" |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #import <sys/param.h> /* for MAXPATHLEN */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 #import <unistd.h> |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
13 /* Use this flag to determine whether we use SDLMain.nib or not */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
14 #define SDL_USE_NIB_FILE 0 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
15 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
16 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 static int gArgc; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 static char **gArgv; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 static BOOL gFinderLaunch; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
21 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
22 /* A helper category for NSString */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 @interface NSString (ReplaceSubString) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 @end |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
26 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
27 /* An internal Apple class used to setup Apple menus */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
28 @interface NSAppleMenuController:NSObject {} |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
29 - (void)controlMenu:(NSMenu *)aMenu; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
30 @end |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
31 #endif |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
32 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
33 @interface SDLApplication : NSApplication |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
34 @end |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
35 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
36 @implementation SDLApplication |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
37 /* Invoked from the Quit menu item */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
38 - (void)terminate:(id)sender |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
39 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
40 /* Post a SDL_QUIT event */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
41 SDL_Event event; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
42 event.type = SDL_QUIT; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
43 SDL_PushEvent(&event); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
44 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
45 @end |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 /* The main class of the application, the application's delegate */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 @implementation SDLMain |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 /* Set the working directory to the .app's parent directory */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 - (void) setupWorkingDirectory:(BOOL)shouldChdir |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 { |
389
ca655a7a9d80
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
388
diff
changeset
|
54 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 if (shouldChdir) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
57 char parentdir[MAXPATHLEN]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
58 char *c; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
59 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
60 strncpy ( parentdir, gArgv[0], sizeof(parentdir) ); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
61 c = (char*) parentdir; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
62 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
63 while (*c != '\0') /* go to end */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
64 c++; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
65 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
66 while (*c != '/') /* back up to parent */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
67 c--; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
68 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
69 *c++ = '\0'; /* cut off last part (binary name) */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
70 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
71 assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
72 assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
76 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
77 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 /* Fix menu to contain the real app name instead of "SDL App" */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
79 - (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 NSRange aRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 NSEnumerator *enumerator; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 NSMenuItem *menuItem; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 aRange = [[aMenu title] rangeOfString:@"SDL App"]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 if (aRange.length != 0) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
87 [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 enumerator = [[aMenu itemArray] objectEnumerator]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 while ((menuItem = [enumerator nextObject])) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 aRange = [[menuItem title] rangeOfString:@"SDL App"]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 if (aRange.length != 0) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
94 [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 if ([menuItem hasSubmenu]) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
96 [self fixMenu:[menuItem submenu] withAppName:appName]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 [ aMenu sizeToFit ]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
101 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
102 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
103 void setupAppleMenu(void) |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
104 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
105 /* warning: this code is very odd */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
106 NSAppleMenuController *appleMenuController; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
107 NSMenu *appleMenu; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
108 NSMenuItem *appleMenuItem; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
109 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
110 appleMenuController = [[NSAppleMenuController alloc] init]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
111 appleMenu = [[NSMenu alloc] initWithTitle:@""]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
112 appleMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
113 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
114 [appleMenuItem setSubmenu:appleMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
115 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
116 /* yes, we do need to add it and then remove it -- |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
117 if you don't add it, it doesn't get displayed |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
118 if you don't remove it, you have an extra, titleless item in the menubar |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
119 when you remove it, it appears to stick around |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
120 very, very odd */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
121 [[NSApp mainMenu] addItem:appleMenuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
122 [appleMenuController controlMenu:appleMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
123 [[NSApp mainMenu] removeItem:appleMenuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
124 [appleMenu release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
125 [appleMenuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
126 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
127 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
128 /* Create a window menu */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
129 void setupWindowMenu(void) |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
130 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
131 NSMenu *windowMenu; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
132 NSMenuItem *windowMenuItem; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
133 NSMenuItem *menuItem; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
134 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
135 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
136 windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
137 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
138 /* "Minimize" item */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
139 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
140 [windowMenu addItem:menuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
141 [menuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
142 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
143 /* Put menu into the menubar */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
144 windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
145 [windowMenuItem setSubmenu:windowMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
146 [[NSApp mainMenu] addItem:windowMenuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
147 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
148 /* Tell the application object that this is now the window menu */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
149 [NSApp setWindowsMenu:windowMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
150 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
151 /* Finally give up our references to the objects */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
152 [windowMenu release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
153 [windowMenuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
154 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
155 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
156 /* Replacement for NSApplicationMain */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
157 void CustomApplicationMain (argc, argv) |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
158 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
159 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
160 SDLMain *sdlMain; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
161 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
162 /* Ensure the application object is initialised */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
163 [SDLApplication sharedApplication]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
164 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
165 /* Set up the menubar */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
166 [NSApp setMainMenu:[[NSMenu alloc] init]]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
167 setupAppleMenu(); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
168 setupWindowMenu(); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
169 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
170 /* Create SDLMain and make it the app delegate */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
171 sdlMain = [[SDLMain alloc] init]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
172 [NSApp setDelegate:sdlMain]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
173 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
174 /* Start the main event loop */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
175 [NSApp run]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
176 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
177 [sdlMain release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
178 [pool release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
179 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
180 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
181 #endif |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
182 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 /* Called when the internal event loop has just started running */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 - (void) applicationDidFinishLaunching: (NSNotification *) note |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 int status; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 /* Set the working directory to the .app's parent directory */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
189 [self setupWorkingDirectory:gFinderLaunch]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
191 #if SDL_USE_NIB_FILE |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 /* Set the main menu to contain the real app name instead of "SDL App" */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
193 [self fixMenu:[NSApp mainMenu] withAppName:[[NSProcessInfo processInfo] processName]]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
194 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 /* Hand off to main application code */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 status = SDL_main (gArgc, gArgv); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 /* We're done, thank you for playing */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 exit(status); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 @end |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 @implementation NSString (ReplaceSubString) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 unsigned int bufferSize; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 unsigned int selfLen = [self length]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 unsigned int aStringLen = [aString length]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 unichar *buffer; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 NSRange localRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 NSString *result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 bufferSize = selfLen + aStringLen - aRange.length; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
219 /* Get first part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 localRange.length = aRange.location; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 [self getCharacters:buffer range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
224 /* Get middle part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 localRange.length = aStringLen; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 [aString getCharacters:(buffer+aRange.location) range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
229 /* Get last part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 localRange.location = aRange.location + aRange.length; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 localRange.length = selfLen - localRange.location; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
234 /* Build output string */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 result = [NSString stringWithCharacters:buffer length:bufferSize]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 NSDeallocateMemoryPages(buffer, bufferSize); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 return result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 @end |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
245 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 #ifdef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 # undef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 #endif |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
250 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
251 /* Main entry point to executable - should *not* be SDL_main! */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
252 int main (int argc, char **argv) |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
253 { |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 /* Copy the arguments into a global variable */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 int i; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 /* This is passed if we are launched by double-clicking */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 gArgc = 1; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 gFinderLaunch = YES; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 } else { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 gArgc = argc; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 gFinderLaunch = NO; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1)); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 assert (gArgv != NULL); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
268 for (i = 0; i < gArgc; i++) |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 gArgv[i] = argv[i]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 gArgv[i] = NULL; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
272 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
273 [SDLApplication poseAsClass:[NSApplication class]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 NSApplicationMain (argc, argv); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
275 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
276 CustomApplicationMain (argc, argv); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
277 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 return 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } |