diff --git a/OpenRA.Launcher.Mac/GameInstall.m b/OpenRA.Launcher.Mac/GameInstall.m index fefa8d5522..039b15f624 100644 --- a/OpenRA.Launcher.Mac/GameInstall.m +++ b/OpenRA.Launcher.Mac/GameInstall.m @@ -94,22 +94,22 @@ -(void)launchMod:(NSString *)mod { // Use LaunchServices because neither NSTask or NSWorkspace support Info.plist _and_ arguments pre-10.6 - NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OpenRA.app/Contents/MacOS/OpenRA"]; - + // 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:gamePath, + NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath, + [NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]], [NSString stringWithFormat:@"Game.Mods=%@",mod], nil]; FSRef appRef; - CFURLGetFSRef((CFURLRef)[NSURL URLWithString:path], &appRef); - + CFURLGetFSRef((CFURLRef)[NSURL URLWithString:[[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], &appRef); + // Set the launch parameters LSApplicationParameters params; params.version = 0; - params.flags = kLSLaunchDefaults; + params.flags = kLSLaunchDefaults | kLSLaunchNewInstance; params.application = &appRef; params.asyncLaunchRefCon = NULL; params.environment = NULL; // CFDictionaryRef of environment variables; could be useful diff --git a/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj b/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj index 099271307a..1df2076db4 100644 --- a/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj +++ b/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ DA81FB9312910A8B00C48F2F /* ImageAndTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FB9212910A8B00C48F2F /* ImageAndTextCell.m */; }; DA81FBDC12910E4900C48F2F /* OpenRA.icns in Resources */ = {isa = PBXBuildFile; fileRef = DA81FBDB12910E4900C48F2F /* OpenRA.icns */; }; DA81FC3F12911E2B00C48F2F /* GameInstall.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FC3E12911E2B00C48F2F /* GameInstall.m */; }; - DA9292C81291DF2D00EDB02E /* OpenRA.app in Resources */ = {isa = PBXBuildFile; fileRef = DA9292C71291DF2D00EDB02E /* OpenRA.app */; }; DA9295A712921DF900EDB02E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA9295A612921DF900EDB02E /* WebKit.framework */; }; DA9296901292328200EDB02E /* SidebarEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = DA92968F1292328200EDB02E /* SidebarEntry.m */; }; DAB887F5129E5D6C00C99407 /* SDL in Resources */ = {isa = PBXBuildFile; fileRef = DAB887EE129E5D6100C99407 /* SDL */; }; @@ -47,7 +46,6 @@ DA81FBDB12910E4900C48F2F /* OpenRA.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = OpenRA.icns; sourceTree = ""; }; DA81FC3D12911E2B00C48F2F /* GameInstall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameInstall.h; sourceTree = ""; }; DA81FC3E12911E2B00C48F2F /* GameInstall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameInstall.m; sourceTree = ""; }; - DA9292C71291DF2D00EDB02E /* OpenRA.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = OpenRA.app; sourceTree = ""; }; DA9295A612921DF900EDB02E /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; DA92968E1292328200EDB02E /* SidebarEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarEntry.h; sourceTree = ""; }; DA92968F1292328200EDB02E /* SidebarEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarEntry.m; sourceTree = ""; }; @@ -139,7 +137,6 @@ isa = PBXGroup; children = ( DAB887EE129E5D6100C99407 /* SDL */, - DA9292C71291DF2D00EDB02E /* OpenRA.app */, DA81FBDB12910E4900C48F2F /* OpenRA.icns */, 8D1107310486CEB800E47090 /* OpenRA-Info.plist */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, @@ -214,7 +211,6 @@ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */, DA81FBDC12910E4900C48F2F /* OpenRA.icns in Resources */, - DA9292C81291DF2D00EDB02E /* OpenRA.app in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 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 5090cf26d7..afccd909cf 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 7f736c6f47..ee744dd90a 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/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/Info.plist b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/Info.plist deleted file mode 100755 index 5b8182b3f7..0000000000 --- a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/Info.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - CFBundleIdentifier - OpenRA - CFBundleExecutable - OpenRA - CFBundleIconFile - OpenRA.icns - - diff --git a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/MacOS/OpenRA b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/MacOS/OpenRA deleted file mode 100755 index ba2bea6897..0000000000 --- a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/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/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/Resources/OpenRA.icns b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/OpenRA.app/Contents/Resources/OpenRA.icns deleted file mode 120000 index 5b28bc3de3..0000000000 --- a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/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/main.m b/OpenRA.Launcher.Mac/main.m index 6eaf818c94..1c2635aeee 100644 --- a/OpenRA.Launcher.Mac/main.m +++ b/OpenRA.Launcher.Mac/main.m @@ -8,7 +8,47 @@ #import +extern char **environ; int main(int argc, char *argv[]) { - return NSApplicationMain(argc, (const char **) argv); + /* When launching a mod, the arguments are of the form + * --launch */ + if (argc >= 5 && strcmp(argv[1], "--launch") == 0) + { + /* Change into the game dir */ + chdir(argv[2]); + + /* Command line args for mono */ + char *args[] = { + "/Library/Frameworks/Mono.framework/Commands/mono", + "--debug", + "OpenRA.Game.exe", + argv[3], + argv[4], + NULL + }; + + /* add game dir to DYLD_LIBRARY_PATH */ + char *old = getenv("DYLD_LIBRARY_PATH"); + if (old == NULL) + setenv("DYLD_LIBRARY_PATH", argv[2], 1); + else + { + char buf[512]; + int len = strlen(argv[2]) + strlen(old) + 2; + if (len > 512) + { + NSLog(@"Insufficient DYLD_LIBRARY_PATH buffer length. Wanted %d, had 512", len); + exit(1); + } + sprintf(buf,"%s:%s",argv[2], old); + setenv("DYLD_LIBRARY_PATH", buf, 1); + } + + /* Exec mono */ + execve(args[0], args, environ); + } + + /* Else, start the launcher */ + return NSApplicationMain(argc, (const char **) argv); }