annotate Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/SDLMain.m @ 3208:9bcf38f59321

Added testpower to svn:ignore
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 30 Jun 2009 06:53:17 +0000
parents d63e9f5944ae
children
rev   line source
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /* SDLMain.m - main entry point for our Cocoa-ized SDL app
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Non-NIB-Code & other changes: Max Horn <max@quendi.de>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 Feel free to customize this file to suit your needs
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #import "SDL.h"
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 #import "SDLMain.h"
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #import <sys/param.h> /* for MAXPATHLEN */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 #import <unistd.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 /* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 but the method still is there and works. To avoid warnings, we declare
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 it ourselves here. */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 @interface NSApplication(SDL_Missing_Methods)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 - (void)setAppleMenu:(NSMenu *)menu;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 /* Use this flag to determine whether we use SDLMain.nib or not */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 #define SDL_USE_NIB_FILE 1
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /* Use this flag to determine whether we use CPS (docking) or not */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #define SDL_USE_CPS 1
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #ifdef SDL_USE_CPS
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 /* Portions of CPS.h */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 typedef struct CPSProcessSerNum
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 UInt32 lo;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 UInt32 hi;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 } CPSProcessSerNum;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #endif /* SDL_USE_CPS */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 static int gArgc;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 static char **gArgv;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 static BOOL gFinderLaunch;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 static BOOL gCalledAppMainline = FALSE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 static NSString *getApplicationName(void)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 NSDictionary *dict;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 NSString *appName = 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 /* Determine the application name */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 if (dict)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 appName = [dict objectForKey: @"CFBundleName"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 if (![appName length])
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 appName = [[NSProcessInfo processInfo] processName];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 return appName;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 #if SDL_USE_NIB_FILE
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 /* A helper category for NSString */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 @interface NSString (ReplaceSubString)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 #endif
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 @interface SDLApplication : NSApplication
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 @implementation SDLApplication
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 /* Invoked from the Quit menu item */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 - (void)terminate:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 /* Post a SDL_QUIT event */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 SDL_Event event;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 event.type = SDL_QUIT;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 SDL_PushEvent(&event);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 /* The main class of the application, the application's delegate */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 @implementation SDLMain
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 - (IBAction)prefsMenu:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 printf ("prefs menu\n");
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 - (IBAction)newGame:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 printf ("new game\n");
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 NSRunAlertPanel (@"Get ready to blow up some... stuff!",
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 @"Click OK to begin total carnage. Click Cancel to prevent total carnage.", @"OK", @"Cancel", nil);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 - (IBAction)openGame:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 NSString *path = nil;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 NSOpenPanel *openPanel = [ NSOpenPanel openPanel ];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 if ( [ openPanel runModalForDirectory:nil
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 file:@"SavedGame" types:nil ] ) {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 path = [ [ openPanel filenames ] objectAtIndex:0 ];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 printf ("open game: %s\n", [ path cString ]);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 - (IBAction)saveGame:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 NSString *path = nil;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 NSSavePanel *savePanel = [ NSSavePanel savePanel ];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if ( [ savePanel runModalForDirectory:nil
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 file:@"SaveGameFile" ] ) {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 path = [ savePanel filename ];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 printf ("save game: %s\n", [ path cString ]);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 - (IBAction)saveGameAs:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 printf ("save game as\n");
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 - (IBAction)help:(id)sender
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 NSRunAlertPanel (@"Oh help, where have ye gone?",
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 @"Sorry, there is no help available.\n\nThis message brought to you by We Don't Document, Inc.\n\n", @"Rats", @"Good, I never read it anyway", nil);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 /* Set the working directory to the .app's parent directory */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 - (void) setupWorkingDirectory:(BOOL)shouldChdir
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 if (shouldChdir)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 char parentdir[MAXPATHLEN];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 CFRelease(url);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 CFRelease(url2);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 #if SDL_USE_NIB_FILE
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 /* Fix menu to contain the real app name instead of "SDL App" */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 - (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 NSRange aRange;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 NSEnumerator *enumerator;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 NSMenuItem *menuItem;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 aRange = [[aMenu title] rangeOfString:@"SDL App"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 if (aRange.length != 0)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 enumerator = [[aMenu itemArray] objectEnumerator];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 while ((menuItem = [enumerator nextObject]))
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 aRange = [[menuItem title] rangeOfString:@"SDL App"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 if (aRange.length != 0)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 if ([menuItem hasSubmenu])
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 [self fixMenu:[menuItem submenu] withAppName:appName];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 [ aMenu sizeToFit ];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 #else
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 static void setApplicationMenu(void)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 /* warning: this code is very odd */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 NSMenu *appleMenu;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 NSMenuItem *menuItem;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 NSString *title;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 NSString *appName;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 appName = getApplicationName();
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 appleMenu = [[NSMenu alloc] initWithTitle:@""];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 /* Add menu items */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 title = [@"About " stringByAppendingString:appName];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 [appleMenu addItem:[NSMenuItem separatorItem]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 title = [@"Hide " stringByAppendingString:appName];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 [appleMenu addItem:[NSMenuItem separatorItem]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 title = [@"Quit " stringByAppendingString:appName];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 /* Put menu into the menubar */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 [menuItem setSubmenu:appleMenu];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 [[NSApp mainMenu] addItem:menuItem];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 /* Tell the application object that this is now the application menu */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 [NSApp setAppleMenu:appleMenu];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 /* Finally give up our references to the objects */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 [appleMenu release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 [menuItem release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 /* Create a window menu */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 static void setupWindowMenu(void)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 NSMenu *windowMenu;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 NSMenuItem *windowMenuItem;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 NSMenuItem *menuItem;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 /* "Minimize" item */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 [windowMenu addItem:menuItem];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 [menuItem release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 /* Put menu into the menubar */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 [windowMenuItem setSubmenu:windowMenu];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 [[NSApp mainMenu] addItem:windowMenuItem];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 /* Tell the application object that this is now the window menu */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 [NSApp setWindowsMenu:windowMenu];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 /* Finally give up our references to the objects */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 [windowMenu release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 [windowMenuItem release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 /* Replacement for NSApplicationMain */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 static void CustomApplicationMain (int argc, char **argv)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 SDLMain *sdlMain;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 /* Ensure the application object is initialised */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 [SDLApplication sharedApplication];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 #ifdef SDL_USE_CPS
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 CPSProcessSerNum PSN;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 /* Tell the dock about us */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 if (!CPSGetCurrentProcess(&PSN))
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 if (!CPSSetFrontProcess(&PSN))
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 [SDLApplication sharedApplication];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 #endif /* SDL_USE_CPS */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 /* Set up the menubar */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 [NSApp setMainMenu:[[NSMenu alloc] init]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 setApplicationMenu();
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 setupWindowMenu();
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 /* Create SDLMain and make it the app delegate */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 sdlMain = [[SDLMain alloc] init];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 [NSApp setDelegate:sdlMain];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 /* Start the main event loop */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 [NSApp run];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 [sdlMain release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 [pool release];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 #endif
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 /*
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 * Catch document open requests...this lets us notice files when the app
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 * was launched by double-clicking a document, or when a document was
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 * dragged/dropped on the app's icon. You need to have a
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 * CFBundleDocumentsType section in your Info.plist to get this message,
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 * apparently.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 *
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 * Files are added to gArgv, so to the app, they'll look like command line
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 * arguments. Previously, apps launched from the finder had nothing but
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 * an argv[0].
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 *
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 * This message may be received multiple times to open several docs on launch.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 *
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 * This message is ignored once the app's mainline has been called.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 const char *temparg;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 size_t arglen;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 char *arg;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 char **newargv;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 if (!gFinderLaunch) /* MacOS is passing command line args. */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 return FALSE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 if (gCalledAppMainline) /* app has started, ignore this document. */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 return FALSE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 temparg = [filename UTF8String];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 arglen = SDL_strlen(temparg) + 1;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 arg = (char *) SDL_malloc(arglen);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 if (arg == NULL)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 return FALSE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 if (newargv == NULL)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 SDL_free(arg);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 return FALSE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 gArgv = newargv;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 SDL_strlcpy(arg, temparg, arglen);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 gArgv[gArgc++] = arg;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 gArgv[gArgc] = NULL;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 return TRUE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 /* Called when the internal event loop has just started running */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 - (void) applicationDidFinishLaunching: (NSNotification *) note
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 int status;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 /* Set the working directory to the .app's parent directory */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 [self setupWorkingDirectory:gFinderLaunch];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 #if SDL_USE_NIB_FILE
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 /* Set the main menu to contain the real app name instead of "SDL App" */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 #endif
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 /* Hand off to main application code */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 gCalledAppMainline = TRUE;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 status = SDL_main (gArgc, gArgv);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 /* We're done, thank you for playing */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 exit(status);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 @implementation NSString (ReplaceSubString)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 unsigned int bufferSize;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 unsigned int selfLen = [self length];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 unsigned int aStringLen = [aString length];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 unichar *buffer;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 NSRange localRange;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 NSString *result;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 bufferSize = selfLen + aStringLen - aRange.length;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 /* Get first part into buffer */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 localRange.location = 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 localRange.length = aRange.location;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 [self getCharacters:buffer range:localRange];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 /* Get middle part into buffer */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 localRange.location = 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 localRange.length = aStringLen;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 [aString getCharacters:(buffer+aRange.location) range:localRange];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 /* Get last part into buffer */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 localRange.location = aRange.location + aRange.length;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 localRange.length = selfLen - localRange.location;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 /* Build output string */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 result = [NSString stringWithCharacters:buffer length:bufferSize];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 NSDeallocateMemoryPages(buffer, bufferSize);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 return result;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 @end
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 #ifdef main
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 # undef main
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 #endif
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 /* Main entry point to executable - should *not* be SDL_main! */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 int main (int argc, char **argv)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 /* Copy the arguments into a global variable */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 /* This is passed if we are launched by double-clicking */
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 gArgv[0] = argv[0];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 gArgv[1] = NULL;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 gArgc = 1;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 gFinderLaunch = YES;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 } else {
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 int i;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 gArgc = argc;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 for (i = 0; i <= argc; i++)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 gArgv[i] = argv[i];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 gFinderLaunch = NO;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 #if SDL_USE_NIB_FILE
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 [SDLApplication poseAsClass:[NSApplication class]];
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 NSApplicationMain (argc, argv);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 #else
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 CustomApplicationMain (argc, argv);
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 #endif
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 return 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 }