diff --git a/Makefile b/Makefile index 52d15784ed..12971286e7 100644 --- a/Makefile +++ b/Makefile @@ -161,8 +161,8 @@ PHONY += fixheader utility_SRCS = $(shell find OpenRA.Utility/ -iname '*.cs') utility_TARGET = OpenRA.Utility.exe utility_KIND = exe -utility_DEPS = $(fileformats_TARGET) thirdparty/ICSharpCode.SharpZipLib.dll -utility_LIBS = $(COMMON_LIBS) $(utility_DEPS) +utility_DEPS = $(fileformats_TARGET) +utility_LIBS = $(COMMON_LIBS) $(utility_DEPS) thirdparty/ICSharpCode.SharpZipLib.dll System.Windows.Forms.dll PROGRAMS += utility utility: $(utility_TARGET) diff --git a/OpenRA.Game/Utilities.cs b/OpenRA.Game/Utilities.cs index abe53dba8f..5d7dcc64dc 100644 --- a/OpenRA.Game/Utilities.cs +++ b/OpenRA.Game/Utilities.cs @@ -33,11 +33,9 @@ namespace OpenRA ExecuteUtilityAsync("--install-ra-packages \"{0}\"".F(cdPath), parseOutput, onComplete); } - public void PromptFilepathAsync(string title, string message, bool directory, Action withPath) + public void PromptFilepathAsync(string title, Action withPath) { - ExecuteUtility("--display-filepicker --title \"{0}\" --message \"{1}\" \"{2}\" --button-text \"Select\"" - .F(title, message, directory ? "--require-directory" : ""), - withPath); + ExecuteUtility("--display-filepicker \"{0}\"".F(title), withPath); } void ExecuteUtility(string args, Action onComplete) diff --git a/OpenRA.Launcher.Mac/Controller.m b/OpenRA.Launcher.Mac/Controller.m index 025782a02a..a46d7bda12 100644 --- a/OpenRA.Launcher.Mac/Controller.m +++ b/OpenRA.Launcher.Mac/Controller.m @@ -78,30 +78,10 @@ [op setLevel:CGShieldingWindowLevel()]; [op setAllowsMultipleSelection:NO]; - NSUInteger a = [args indexOfObject:@"--title"]; + NSUInteger a = [args indexOfObject:@"--display-filepicker"]; if (a != NSNotFound) [op setTitle:[args objectAtIndex:a+1]]; - - a = [args indexOfObject:@"--message"]; - if (a != NSNotFound) - [op setMessage:[args objectAtIndex:a+1]]; - - a = [args indexOfObject:@"--directory"]; - if (a != NSNotFound) - [op setDirectory:[[args objectAtIndex:a+1] stringByExpandingTildeInPath]]; - - a = [args indexOfObject:@"--require-directory"]; - if (a != NSNotFound) - { - [op setCanChooseFiles:NO]; - [op setCanChooseDirectories:YES]; - } - - a = [args indexOfObject:@"--button-text"]; - if (a != NSNotFound) - [op setPrompt:[[args objectAtIndex:a+1] stringByExpandingTildeInPath]]; - - + if ([op runModal] == NSFileHandlingPanelOKButton) printf("%s\n", [[[op URL] path] UTF8String]); @@ -116,7 +96,7 @@ // 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, monoPath, - [NSString stringWithFormat:@"NativeUtilityPath=%@", [[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], + [NSString stringWithFormat:@"UtilityPath=%@", [[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], [NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]], [NSString stringWithFormat:@"Game.Mods=%@",mod], nil]; 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 85bdff27b9..a54d317931 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 de7b42a725..3e4a9fc259 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.Mods.RA/Widgets/Delegates/GameInitDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs index ada626b115..b9906d7d73 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs @@ -125,10 +125,10 @@ namespace OpenRA.Mods.RA.Widgets.Delegates bool PromptForCD() { - Game.Utilities.PromptFilepathAsync("Select CD", "Select the {0} CD".F(Info.GameTitle), true, path => + Game.Utilities.PromptFilepathAsync("Select MAIN.MIX on the CD", path => { if (!string.IsNullOrEmpty(path)) - Game.RunAfterTick(() => InstallFromCD(path)); + Game.RunAfterTick(() => InstallFromCD(Path.GetDirectoryName(path))); }); return true; } diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index c17902292f..b128758620 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -14,6 +14,7 @@ using System.IO; using System.Linq; using System.Net; using System.Threading; +using System.Windows.Forms; using ICSharpCode.SharpZipLib; using ICSharpCode.SharpZipLib.Zip; using OpenRA.FileFormats; @@ -114,6 +115,21 @@ namespace OpenRA.Utility } Console.WriteLine("Status: Completed"); } + + public static void DisplayFilepicker(string[] args) + { + if (args.Length < 2) + { + Console.WriteLine("Error: Invalid syntax"); + return; + } + + var dialog = new OpenFileDialog(); + dialog.Title = args[1]; + + if (dialog.ShowDialog() == DialogResult.OK) + Console.WriteLine(dialog.FileName); + } public static void Settings(string[] args) { diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 93e72739c2..42b0d19b41 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -30,6 +30,7 @@ namespace OpenRA.Utility argCallbacks.Add("--extract-zip", Command.ExtractZip); argCallbacks.Add("--install-ra-packages", Command.InstallRAPackages); argCallbacks.Add("--install-cnc-packages", Command.InstallCncPackages); + argCallbacks.Add("--display-filepicker", Command.DisplayFilepicker); argCallbacks.Add("--settings-value", Command.Settings); if (args.Length == 0) { PrintUsage(); return; }