Fix osx launcher. TODO: needs testing on 10.5
This commit is contained in:
@@ -30,18 +30,21 @@ namespace OpenRA
|
|||||||
|
|
||||||
void ExecuteUtility(string args, Action<string> onComplete)
|
void ExecuteUtility(string args, Action<string> onComplete)
|
||||||
{
|
{
|
||||||
Process p = new Process();
|
try
|
||||||
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) =>
|
|
||||||
{
|
{
|
||||||
onComplete(p.StandardOutput.ReadToEnd().Trim());
|
Process p = new Process();
|
||||||
};
|
p.StartInfo.FileName = Utility;
|
||||||
p.Start();
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,7 @@
|
|||||||
IBOutlet NSWindow *window;
|
IBOutlet NSWindow *window;
|
||||||
}
|
}
|
||||||
- (void)launchFilePicker:(NSArray *)args;
|
- (void)launchFilePicker:(NSArray *)args;
|
||||||
- (void)extractZip:(NSArray *)args;
|
|
||||||
- (void)installRAPackages:(NSArray *)args;
|
|
||||||
- (void)launch;
|
- (void)launch;
|
||||||
- (BOOL)initMono;
|
- (BOOL)initMono;
|
||||||
- (void)runUtilityWithArgs:(NSArray *)arg;
|
|
||||||
- (void)utilityResponded:(NSNotification *)n;
|
|
||||||
- (BOOL)shouldHideMenubar;
|
- (BOOL)shouldHideMenubar;
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -40,37 +40,12 @@ extern char **environ;
|
|||||||
// Ingame requests for native dialogs
|
// Ingame requests for native dialogs
|
||||||
if ([args containsObject:@"--display-filepicker"])
|
if ([args containsObject:@"--display-filepicker"])
|
||||||
[self launchFilePicker:args];
|
[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
|
else
|
||||||
[self launch];
|
[self launch];
|
||||||
|
|
||||||
[NSApp terminate: nil];
|
[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
|
- (void)launchFilePicker:(NSArray *)args
|
||||||
{
|
{
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
@@ -109,6 +84,20 @@ extern char **environ;
|
|||||||
NSFileHandle *readHandle = [pipe fileHandleForReading];
|
NSFileHandle *readHandle = [pipe fileHandleForReading];
|
||||||
[task launch];
|
[task launch];
|
||||||
[task waitUntilExit];
|
[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]
|
NSString *response = [[[NSString alloc] initWithData:[readHandle readDataToEndOfFile]
|
||||||
encoding: NSUTF8StringEncoding] autorelease];
|
encoding: NSUTF8StringEncoding] autorelease];
|
||||||
return ![response isEqualToString:@"Windowed\n"];
|
return ![response isEqualToString:@"Windowed\n"];
|
||||||
@@ -125,9 +114,8 @@ extern char **environ;
|
|||||||
[self shouldHideMenubar] ? @"--hide-menubar" : @"--no-hide-menubar",
|
[self shouldHideMenubar] ? @"--hide-menubar" : @"--no-hide-menubar",
|
||||||
gamePath,
|
gamePath,
|
||||||
monoPath,
|
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:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]],
|
||||||
[NSString stringWithFormat:@"SpecialPackageRoot=%@/",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]],
|
|
||||||
nil];
|
nil];
|
||||||
FSRef appRef;
|
FSRef appRef;
|
||||||
CFURLGetFSRef((CFURLRef)[NSURL URLWithString:[[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], &appRef);
|
CFURLGetFSRef((CFURLRef)[NSURL URLWithString:[[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], &appRef);
|
||||||
@@ -200,46 +188,6 @@ extern char **environ;
|
|||||||
(major == 2 && minor == 6 && point >= 7));
|
(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
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[monoPath release]; monoPath = nil;
|
[monoPath release]; monoPath = nil;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>BuildMachineOSBuild</key>
|
||||||
|
<string>10J869</string>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>English</string>
|
<string>English</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
@@ -24,6 +26,20 @@
|
|||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
|
<key>DTCompiler</key>
|
||||||
|
<string></string>
|
||||||
|
<key>DTPlatformBuild</key>
|
||||||
|
<string>4A304a</string>
|
||||||
|
<key>DTPlatformVersion</key>
|
||||||
|
<string>GM</string>
|
||||||
|
<key>DTSDKBuild</key>
|
||||||
|
<string>4A304a</string>
|
||||||
|
<key>DTSDKName</key>
|
||||||
|
<string>macosx10.6</string>
|
||||||
|
<key>DTXcode</key>
|
||||||
|
<string>0400</string>
|
||||||
|
<key>DTXcodeBuild</key>
|
||||||
|
<string>4A304a</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>10.5</string>
|
<string>10.5</string>
|
||||||
<key>NSMainNibFile</key>
|
<key>NSMainNibFile</key>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
/* When launching a mod, the arguments are of the form
|
/* When launching a mod, the arguments are of the form
|
||||||
* --launch <game dir> <mono path> <utility path> <support dir option> <mod option> */
|
* --launch <game dir> <mono path> <utility path> <support dir option> <mod option> */
|
||||||
if (argc >= 8 && strcmp(argv[1], "--launch") == 0)
|
if (argc >= 7 && strcmp(argv[1], "--launch") == 0)
|
||||||
{
|
{
|
||||||
/* Change into the game dir */
|
/* Change into the game dir */
|
||||||
chdir(argv[3]);
|
chdir(argv[3]);
|
||||||
@@ -25,7 +25,6 @@ int main(int argc, char *argv[])
|
|||||||
"OpenRA.Game.exe",
|
"OpenRA.Game.exe",
|
||||||
argv[5],
|
argv[5],
|
||||||
argv[6],
|
argv[6],
|
||||||
argv[7],
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ int main(int argc, char *argv[])
|
|||||||
/* Exec mono */
|
/* Exec mono */
|
||||||
execve(args[0], args, environ);
|
execve(args[0], args, environ);
|
||||||
}
|
}
|
||||||
|
else /* Else, start the launcher */
|
||||||
/* Else, start the launcher */
|
return NSApplicationMain(argc, (const char **) argv);
|
||||||
return NSApplicationMain(argc, (const char **) argv);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user