diff --git a/OpenRA.Launcher.Mac/Controller.h b/OpenRA.Launcher.Mac/Controller.h index 62c135e9f4..dad2656956 100644 --- a/OpenRA.Launcher.Mac/Controller.h +++ b/OpenRA.Launcher.Mac/Controller.h @@ -21,6 +21,7 @@ NSMutableArray *httpRequests; NSMutableDictionary *downloads; BOOL hasMono; + NSString *monoPath; IBOutlet NSWindow *window; IBOutlet NSOutlineView *outlineView; @@ -37,5 +38,5 @@ - (void)fetchURL:(NSString *)url withCallback:(NSString *)cb; - (BOOL)registerDownload:(NSString *)key withURL:(NSString *)url filePath:(NSString *)path; - (Download *)downloadWithKey:(NSString *)key; -- (BOOL)hasSupportedMono; +- (BOOL)initMono; @end diff --git a/OpenRA.Launcher.Mac/Controller.m b/OpenRA.Launcher.Mac/Controller.m index 4eb831ccea..04aa5455a9 100644 --- a/OpenRA.Launcher.Mac/Controller.m +++ b/OpenRA.Launcher.Mac/Controller.m @@ -30,13 +30,16 @@ { NSString *gamePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"gamepath"]; - game = [[GameInstall alloc] initWithPath:gamePath]; - [[JSBridge sharedInstance] setController:self]; - downloads = [[NSMutableDictionary alloc] init]; - httpRequests = [[NSMutableArray alloc] init]; - hasMono = [self hasSupportedMono]; + hasMono = [self initMono]; + + NSLog(@"%d, %@",hasMono, monoPath); if (hasMono) { + game = [[GameInstall alloc] initWithGamePath:gamePath monoPath:monoPath]; + [[JSBridge sharedInstance] setController:self]; + downloads = [[NSMutableDictionary alloc] init]; + httpRequests = [[NSMutableArray alloc] init]; + NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"]; ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease]; [col setDataCell:imageAndTextCell]; @@ -88,15 +91,13 @@ [[NSApplication sharedApplication] terminate:self]; } -- (BOOL)hasSupportedMono +- (BOOL)initMono { - if (![[NSFileManager defaultManager] fileExistsAtPath:@"/Library/Frameworks/Mono.framework/Commands/mono"]) - return NO; - + // Find the users mono NSPipe *outPipe = [NSPipe pipe]; NSTask *task = [[NSTask alloc] init]; - [task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"]; - [task setArguments:[NSMutableArray arrayWithObject:@"--version"]]; + [task setLaunchPath:@"/usr/bin/which"]; + [task setArguments:[NSMutableArray arrayWithObject:@"mono"]]; [task setStandardOutput:outPipe]; [task setStandardError:[task standardOutput]]; [task launch]; @@ -105,6 +106,27 @@ [task waitUntilExit]; [task release]; + NSString *temp = [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]; + // Remove whitespace and resolve symlinks + monoPath = [[[temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] + stringByResolvingSymlinksInPath] retain]; + + if (![monoPath length]) + return NO; + + // Find the mono version + outPipe = [NSPipe pipe]; + task = [[NSTask alloc] init]; + [task setLaunchPath:monoPath]; + [task setArguments:[NSMutableArray arrayWithObject:@"--version"]]; + [task setStandardOutput:outPipe]; + [task setStandardError:[task standardOutput]]; + [task launch]; + + data = [[outPipe fileHandleForReading] readDataToEndOfFile]; + [task waitUntilExit]; + [task release]; + NSString *ret = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; int major = 0; @@ -112,6 +134,7 @@ int point = 0; sscanf([ret UTF8String], "Mono JIT compiler version %d.%d.%d", &major, &minor, &point); [ret release]; + NSLog(@"mono %d.%d.%d: %@",major,minor,point,monoPath); return (major > 2 || (major == 2 && minor > 6) || @@ -123,6 +146,7 @@ [sidebarItems release]; sidebarItems = nil; [downloads release]; downloads = nil; [httpRequests release]; httpRequests = nil; + [monoPath release]; monoPath = nil; [super dealloc]; } diff --git a/OpenRA.Launcher.Mac/GameInstall.h b/OpenRA.Launcher.Mac/GameInstall.h index d5ecae003f..94b922f5d3 100644 --- a/OpenRA.Launcher.Mac/GameInstall.h +++ b/OpenRA.Launcher.Mac/GameInstall.h @@ -12,12 +12,12 @@ @class Controller; @interface GameInstall : NSObject { NSString *gamePath; - Controller *controller; + NSString *monoPath; NSMutableDictionary *downloadTasks; } @property(readonly) NSString *gamePath; --(id)initWithPath:(NSString *)path; +-(id)initWithGamePath:(NSString *)gamepath monoPath:(NSString *)monopath; -(void)launchMod:(NSString *)mod; - (NSString *)runUtilityQuery:(NSString *)arg; - (NSArray *)installedMods; diff --git a/OpenRA.Launcher.Mac/GameInstall.m b/OpenRA.Launcher.Mac/GameInstall.m index 039b15f624..ba052da0f0 100644 --- a/OpenRA.Launcher.Mac/GameInstall.m +++ b/OpenRA.Launcher.Mac/GameInstall.m @@ -13,12 +13,13 @@ @implementation GameInstall @synthesize gamePath; --(id)initWithPath:(NSString *)path +-(id)initWithGamePath:(NSString *)gamepath monoPath:(NSString *)monopath { self = [super init]; if (self != nil) { - gamePath = [path retain]; + gamePath = [gamepath retain]; + monoPath = [monopath retain]; downloadTasks = [[NSMutableDictionary alloc] init]; } return self; @@ -27,6 +28,7 @@ - (void)dealloc { [gamePath release]; gamePath = nil; + [monoPath release]; monoPath = nil; [downloadTasks release]; downloadTasks = nil; [super dealloc]; } @@ -98,7 +100,7 @@ // First argument is the directory to run in // Second...Nth arguments are passed to OpenRA.Game.exe // Launcher wrapper sets mono --debug, gl renderer and support dir. - NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath, + NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath, monoPath, [NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]], [NSString stringWithFormat:@"Game.Mods=%@",mod], nil]; @@ -132,7 +134,7 @@ NSTask *task = [[NSTask alloc] init]; [task setCurrentDirectoryPath:gamePath]; - [task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"]; + [task setLaunchPath:monoPath]; [task setArguments:taskArgs]; [task setStandardOutput:outPipe]; [task setStandardError:[task standardOutput]]; @@ -156,7 +158,7 @@ [taskArgs addObject:arg]; [task setCurrentDirectoryPath:gamePath]; - [task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"]; + [task setLaunchPath:monoPath]; [task setArguments:taskArgs]; [task setStandardOutput:pipe]; diff --git a/OpenRA.Launcher.Mac/OpenRA b/OpenRA.Launcher.Mac/OpenRA deleted file mode 100755 index dd5cbc97c9..0000000000 Binary files a/OpenRA.Launcher.Mac/OpenRA and /dev/null differ diff --git a/OpenRA.Launcher.Mac/OpenRA.app/Contents/Info.plist b/OpenRA.Launcher.Mac/OpenRA.app/Contents/Info.plist deleted file mode 100755 index 5b8182b3f7..0000000000 --- a/OpenRA.Launcher.Mac/OpenRA.app/Contents/Info.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - CFBundleIdentifier - OpenRA - CFBundleExecutable - OpenRA - CFBundleIconFile - OpenRA.icns - - diff --git a/OpenRA.Launcher.Mac/OpenRA.app/Contents/MacOS/OpenRA b/OpenRA.Launcher.Mac/OpenRA.app/Contents/MacOS/OpenRA deleted file mode 100755 index ba2bea6897..0000000000 --- a/OpenRA.Launcher.Mac/OpenRA.app/Contents/MacOS/OpenRA +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Copyright 2007-2010 The OpenRA Developers (see AUTHORS) -# This file is part of OpenRA, which is free software. It is made -# available to you under the terms of the GNU General Public License -# as published by the Free Software Foundation. For more information, -# see LICENSE. - -export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH" -echo "Launching OpenRA from $1" -cd $1 -mono --debug OpenRA.Game.exe SupportDir=~/Library/"Application Support"/OpenRA ${@:2} \ No newline at end of file diff --git a/OpenRA.Launcher.Mac/OpenRA.app/Contents/Resources/OpenRA.icns b/OpenRA.Launcher.Mac/OpenRA.app/Contents/Resources/OpenRA.icns deleted file mode 120000 index 5b28bc3de3..0000000000 --- a/OpenRA.Launcher.Mac/OpenRA.app/Contents/Resources/OpenRA.icns +++ /dev/null @@ -1 +0,0 @@ -../../../OpenRA.icns \ No newline at end of file diff --git a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/MacOS/OpenRA b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/MacOS/OpenRA index 0a8ad609c0..2bdc0e6fc9 100755 Binary files a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/MacOS/OpenRA and b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/MacOS/OpenRA differ diff --git a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/MainMenu.nib b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/MainMenu.nib index b2340f1712..3adb03f1ea 100644 Binary files a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/MainMenu.nib and b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/MainMenu.nib differ diff --git a/OpenRA.Launcher.Mac/main.m b/OpenRA.Launcher.Mac/main.m index 1c2635aeee..854be1b519 100644 --- a/OpenRA.Launcher.Mac/main.m +++ b/OpenRA.Launcher.Mac/main.m @@ -20,11 +20,11 @@ int main(int argc, char *argv[]) /* Command line args for mono */ char *args[] = { - "/Library/Frameworks/Mono.framework/Commands/mono", + argv[3], "--debug", "OpenRA.Game.exe", - argv[3], argv[4], + argv[5], NULL };