資源簡介
robocup rescue server
代碼片段和文件信息
/*???SDLMain.m?-?main?entry?point?for?our?Cocoa-ized?SDL?app
???????Initial?Version:?Darrell?Walisser?
???????Non-NIB-Code?&?other?changes:?Max?Horn?
????Feel?free?to?customize?this?file?to?suit?your?needs
*/
#import?“SDL.h“
#import?“SDLMain.h“
#import??/*?for?MAXPATHLEN?*/
#import?
/*?For?some?reaon?Apple?removed?setAppleMenu?from?the?headers?in?10.4
?but?the?method?still?is?there?and?works.?To?avoid?warnings?we?declare
?it?ourselves?here.?*/
@interface?NSApplication(SDL_Missing_Methods)
-?(void)setAppleMenu:(NSMenu?*)menu;
@end
/*?Use?this?flag?to?determine?whether?we?use?SDLMain.nib?or?not?*/
#define SDL_USE_NIB_FILE 0
/*?Use?this?flag?to?determine?whether?we?use?CPS?(docking)?or?not?*/
#define SDL_USE_CPS 1
#ifdef?SDL_USE_CPS
/*?Portions?of?CPS.h?*/
typedef?struct?CPSProcessSerNum
{
UInt32 lo;
UInt32 hi;
}?CPSProcessSerNum;
extern?OSErr CPSGetCurrentProcess(?CPSProcessSerNum?*psn);
extern?OSErr? CPSEnableForegroundOperation(?CPSProcessSerNum?*psn?UInt32?_arg2?UInt32?_arg3?UInt32?_arg4?UInt32?_arg5);
extern?OSErr CPSSetFrontProcess(?CPSProcessSerNum?*psn);
#endif?/*?SDL_USE_CPS?*/
static?int????gArgc;
static?char??**gArgv;
static?BOOL???gFinderLaunch;
static?BOOL???gCalledAppMainline?=?FALSE;
static?NSString?*getApplicationName(void)
{
????NSDictionary?*dict;
????NSString?*appName?=?0;
????/*?Determine?the?application?name?*/
????dict?=?(NSDictionary?*)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
????if?(dict)
????????appName?=?[dict?objectForKey:?@“CFBundleName“];
????
????if?(![appName?length])
????????appName?=?[[NSProcessInfo?processInfo]?processName];
????return?appName;
}
#if?SDL_USE_NIB_FILE
/*?A?helper?category?for?NSString?*/
@interface?NSString?(ReplaceSubString)
-?(NSString?*)stringByReplacingRange:(NSRange)aRange?with:(NSString?*)aString;
@end
#endif
@interface?SDLApplication?:?NSApplication
@end
@implementation?SDLApplication
/*?Invoked?from?the?Quit?menu?item?*/
-?(void)terminate:(id)sender
{
????/*?Post?a?SDL_QUIT?event?*/
????SDL_Event?event;
????event.type?=?SDL_QUIT;
????SDL_PushEvent(&event);
}
@end
/*?The?main?class?of?the?application?the?application‘s?delegate?*/
@implementation?SDLMain
/*?Set?the?working?directory?to?the?.app‘s?parent?directory?*/
-?(void)?setupWorkingDirectory:(BOOL)shouldChdir
{
????if?(shouldChdir)
????{
????????char?parentdir[MAXPATHLEN];
CFURLRef?url?=?CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLRef?url2?=?CFURLCreateCopyDeletingLastPathComponent(0?url);
if?(CFURLGetFileSystemRepresentation(url2?true?(UInt8?*)parentdir?MAXPATHLEN))?{
????????assert?(?chdir?(parentdir)?==?0?);???/*?chdir?to?the?binary?app‘s?parent?*/
}
CFRelease(url);
CFRelease(url2);
}
}
#if?SDL_USE_NIB_FILE
/*?Fix?menu?to?contain?the?real?app?name?instead?of?“SDL?App“?*/
-?(void)fixMenu:(NSMenu?*)aMenu?withAppName:(NSString?*)appName
{
????NSRange?aRange;
????NSEnumerator?*enumerator;
????NSMenuItem?*menuIte
評論
共有 條評論