diff --git a/OpenRA.Game/Utilities.cs b/OpenRA.Game/Utilities.cs index 6baf5329aa..505de31cd7 100644 --- a/OpenRA.Game/Utilities.cs +++ b/OpenRA.Game/Utilities.cs @@ -30,18 +30,21 @@ namespace OpenRA void ExecuteUtility(string args, Action onComplete) { - Process p = new Process(); - p.StartInfo.FileName = Utility; - p.StartInfo.Arguments = "{0} --SupportDir \"{1}\"".F(args, Game.SupportDir); - p.StartInfo.UseShellExecute = false; - p.StartInfo.CreateNoWindow = true; - p.StartInfo.RedirectStandardOutput = true; - p.EnableRaisingEvents = true; - p.Exited += (_,e) => + try { - onComplete(p.StandardOutput.ReadToEnd().Trim()); - }; - p.Start(); + Process p = new Process(); + p.StartInfo.FileName = Utility; + p.StartInfo.Arguments = "{0} --SupportDir \"{1}\"".F(args, Game.SupportDir); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.EnableRaisingEvents = true; + p.Exited += (_,e) => + { + onComplete(p.StandardOutput.ReadToEnd().Trim()); + }; + p.Start(); + } + catch(System.ComponentModel.Win32Exception) {} // Don't crash if the process fails } } } diff --git a/OpenRA.Launcher.Mac/Controller.h b/OpenRA.Launcher.Mac/Controller.h index fa8415f821..784e429512 100644 --- a/OpenRA.Launcher.Mac/Controller.h +++ b/OpenRA.Launcher.Mac/Controller.h @@ -16,11 +16,7 @@ IBOutlet NSWindow *window; } - (void)launchFilePicker:(NSArray *)args; -- (void)extractZip:(NSArray *)args; -- (void)installRAPackages:(NSArray *)args; - (void)launch; - (BOOL)initMono; -- (void)runUtilityWithArgs:(NSArray *)arg; -- (void)utilityResponded:(NSNotification *)n; - (BOOL)shouldHideMenubar; @end diff --git a/OpenRA.Launcher.Mac/Controller.m b/OpenRA.Launcher.Mac/Controller.m index 277f107839..f22ab95e4c 100644 --- a/OpenRA.Launcher.Mac/Controller.m +++ b/OpenRA.Launcher.Mac/Controller.m @@ -40,37 +40,12 @@ extern char **environ; // Ingame requests for native dialogs if ([args containsObject:@"--display-filepicker"]) [self launchFilePicker:args]; - - // Extract a zip file - else if ([args containsObject:@"--extract-zip"]) - [self extractZip:args]; - - // Install ra packages from cd - else if ([args containsObject:@"--install-ra-packages"]) - [self installRAPackages:args]; - else [self launch]; [NSApp terminate: nil]; } -- (void)extractZip:(NSArray *)args -{ - // Todo: check if we can write to the requested dir, escalate priviledges if required. - NSMutableArray *a = [NSMutableArray arrayWithArray:args]; - [a replaceObjectAtIndex:0 withObject:@"--extract-zip-inner"]; - [self runUtilityWithArgs:a]; -} - -- (void)installRAPackages:(NSArray *)args -{ - // Todo: check if we can write to the requested dir, escalate priviledges if required. - NSMutableArray *a = [NSMutableArray arrayWithArray:args]; - [a replaceObjectAtIndex:0 withObject:@"--install-ra-packages-inner"]; - [self runUtilityWithArgs:a]; -} - - (void)launchFilePicker:(NSArray *)args { [NSApp activateIgnoringOtherApps:YES]; @@ -109,6 +84,20 @@ extern char **environ; NSFileHandle *readHandle = [pipe fileHandleForReading]; [task launch]; [task waitUntilExit]; + + if ([task terminationStatus] != 0) + { + NSAlert *alert = [NSAlert alertWithMessageText:@"Error" + defaultButton:@"Quit" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"OpenRA.Utility.exe returned an error and cannot continue."]; + + [alert runModal]; + [[NSApplication sharedApplication] terminate:self]; + + } + NSString *response = [[[NSString alloc] initWithData:[readHandle readDataToEndOfFile] encoding: NSUTF8StringEncoding] autorelease]; return ![response isEqualToString:@"Windowed\n"]; @@ -125,9 +114,8 @@ extern char **environ; [self shouldHideMenubar] ? @"--hide-menubar" : @"--no-hide-menubar", gamePath, monoPath, - [NSString stringWithFormat:@"UtilityPath=%@", [[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], + [NSString stringWithFormat:@"UtilityPath=%@", [[NSBundle mainBundle] executablePath]], [NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]], - [NSString stringWithFormat:@"SpecialPackageRoot=%@/",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]], nil]; FSRef appRef; CFURLGetFSRef((CFURLRef)[NSURL URLWithString:[[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], &appRef); @@ -200,46 +188,6 @@ extern char **environ; (major == 2 && minor == 6 && point >= 7)); } - -- (void)runUtilityWithArgs:(NSArray *)args -{ - NSTask *task = [[[NSTask alloc] init] autorelease]; - NSPipe *pipe = [NSPipe pipe]; - - NSMutableArray *taskArgs = [NSMutableArray arrayWithObject:@"OpenRA.Utility.exe"]; - [taskArgs addObjectsFromArray:args]; - - [task setCurrentDirectoryPath:gamePath]; - [task setLaunchPath:monoPath]; - [task setArguments:taskArgs]; - [task setStandardOutput:pipe]; - - NSFileHandle *readHandle = [pipe fileHandleForReading]; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self - selector:@selector(utilityResponded:) - name:NSFileHandleReadCompletionNotification - object:readHandle]; - [task launch]; - [readHandle readInBackgroundAndNotify]; - [task waitUntilExit]; - - [nc removeObserver:self name:NSFileHandleReadCompletionNotification object:[[task standardOutput] fileHandleForReading]]; - [nc removeObserver:self name:NSTaskDidTerminateNotification object:task]; -} - -- (void)utilityResponded:(NSNotification *)n -{ - NSData *data = [[n userInfo] valueForKey:NSFileHandleNotificationDataItem]; - NSString *response = [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]; - printf("%s", [response UTF8String]); - - // Keep reading - if ([n object] != nil) - [[n object] readInBackgroundAndNotify]; -} - - - (void)dealloc { [monoPath release]; monoPath = nil; diff --git a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Info.plist b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Info.plist index e87e49f3a1..e32afd19eb 100644 --- a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Info.plist +++ b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Info.plist @@ -2,6 +2,8 @@ + BuildMachineOSBuild + 10J869 CFBundleDevelopmentRegion English CFBundleDisplayName @@ -24,6 +26,20 @@ ???? CFBundleVersion 1 + DTCompiler + + DTPlatformBuild + 4A304a + DTPlatformVersion + GM + DTSDKBuild + 4A304a + DTSDKName + macosx10.6 + DTXcode + 0400 + DTXcodeBuild + 4A304a LSMinimumSystemVersion 10.5 NSMainNibFile 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 769bc2a49b..c115daf3d3 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/InfoPlist.strings b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/InfoPlist.strings index dea12de4ca..5e45963c38 100644 Binary files a/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/InfoPlist.strings and b/OpenRA.Launcher.Mac/build/Release/OpenRA.app/Contents/Resources/English.lproj/InfoPlist.strings 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 3e4a9fc259..41c42be51f 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 8987557928..0c84cb1c01 100644 --- a/OpenRA.Launcher.Mac/main.m +++ b/OpenRA.Launcher.Mac/main.m @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /* When launching a mod, the arguments are of the form * --launch */ - if (argc >= 8 && strcmp(argv[1], "--launch") == 0) + if (argc >= 7 && strcmp(argv[1], "--launch") == 0) { /* Change into the game dir */ chdir(argv[3]); @@ -25,7 +25,6 @@ int main(int argc, char *argv[]) "OpenRA.Game.exe", argv[5], argv[6], - argv[7], NULL }; @@ -52,7 +51,6 @@ int main(int argc, char *argv[]) /* Exec mono */ execve(args[0], args, environ); } - - /* Else, start the launcher */ - return NSApplicationMain(argc, (const char **) argv); + else /* Else, start the launcher */ + return NSApplicationMain(argc, (const char **) argv); }