From 221d6ebd4ff1e2fb903870bf4d8183e3969488da Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 4 May 2011 18:55:23 +1200 Subject: [PATCH] Make it actually work --- .../Widgets/Delegates/GameInitDelegate.cs | 46 ++++++++++--------- OpenRA.Utility/Program.cs | 3 -- mods/cnc/chrome/gameinit.yaml | 2 +- mods/cnc/mod.yaml | 2 +- mods/ra/chrome/gameinit.yaml | 2 +- mods/ra/mod.yaml | 2 +- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs index 7f1743f471..9f089a0ab8 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs @@ -18,6 +18,7 @@ using ICSharpCode.SharpZipLib.Zip; using OpenRA.FileFormats; using OpenRA.Network; using OpenRA.Widgets; +using System.Threading; namespace OpenRA.Mods.RA.Widgets.Delegates { @@ -108,20 +109,24 @@ namespace OpenRA.Mods.RA.Widgets.Delegates window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; }; window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD(); - switch (Info.InstallMode) + var t = new Thread( _ => { - case "ra": - if (InstallRAPackages(window, path, Info.ResolvedPackagePath)) - Game.RunAfterTick(TestAndContinue); - break; - case "cnc": - if (InstallCncPackages(window, path, Info.ResolvedPackagePath)) - Game.RunAfterTick(TestAndContinue); - break; - default: - ShowDownloadError(window, "Installing from CD not supported"); - break; - } + switch (Info.InstallMode) + { + case "ra": + if (InstallRAPackages(window, path, Info.ResolvedPackagePath)) + Game.RunAfterTick(TestAndContinue); + break; + case "cnc": + if (InstallCncPackages(window, path, Info.ResolvedPackagePath)) + Game.RunAfterTick(TestAndContinue); + break; + default: + ShowError(window, "Installing from CD not supported"); + break; + } + }) { IsBackground = true }; + t.Start(); } void ShowDownloadDialog() @@ -142,7 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates Action onDownloadComplete = (i, cancelled) => { if (i.Error != null) - ShowDownloadError(window, i.Error.Message); + ShowError(window, i.Error.Message); else if (!cancelled) { // Automatically extract @@ -151,7 +156,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates if (ExtractZip(window, file, Info.ResolvedPackagePath)) Game.RunAfterTick(TestAndContinue); - } }; @@ -160,7 +164,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates window.GetWidget("RETRY").OnMouseUp = mi => { dl.Cancel(); ShowDownloadDialog(); return true; }; } - void ShowDownloadError(Widget window, string e) + void ShowError(Widget window, string e) { if (window.GetWidget("STATUS") != null) /* ugh */ { @@ -202,7 +206,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates { if (!File.Exists(zipFile)) { - ShowDownloadError(window, "Invalid path: "+zipFile); + ShowError(window, "Invalid path: "+zipFile); return false; } @@ -216,7 +220,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates { foreach(var f in extracted) File.Delete(f); - ShowDownloadError(window, "Archive corrupt"); + ShowError(window, "Archive corrupt"); return false; } status.GetText = () => "Extraction complete"; @@ -231,9 +235,9 @@ namespace OpenRA.Mods.RA.Widgets.Delegates if (!Directory.Exists(destPath)) Directory.CreateDirectory(destPath); - if (!Directory.Exists(srcPath)) { ShowDownloadError(window, "Cannot find "+package); return false; } + if (!Directory.Exists(srcPath)) { ShowError(window, "Cannot find "+package); return false; } FileSystem.Mount(srcPath); - if (!FileSystem.Exists(package)) { ShowDownloadError(window, "Cannot find "+package); return false; } + if (!FileSystem.Exists(package)) { ShowError(window, "Cannot find "+package); return false; } FileSystem.Mount(package); foreach (string s in files) @@ -260,7 +264,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates var fromPath = Path.Combine(srcPath, file); if (!File.Exists(fromPath)) { - ShowDownloadError(window, "Cannot find "+file); + ShowError(window, "Cannot find "+file); return false; } status.GetText = () => "Extracting "+file.ToLowerInvariant(); diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index b05f7fae0f..47cc94be4c 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -58,10 +58,7 @@ namespace OpenRA.Utility var supportDir = GetNamedArg(args, "--SupportDir"); if (supportDir != null) - { Log.LogPath = Path.Combine(supportDir.Replace("\"", ""), "Logs"); - Console.WriteLine("LogPath: {0}", Log.LogPath); - } try { diff --git a/mods/cnc/chrome/gameinit.yaml b/mods/cnc/chrome/gameinit.yaml index cbff1eb4b8..cc07d3f84f 100644 --- a/mods/cnc/chrome/gameinit.yaml +++ b/mods/cnc/chrome/gameinit.yaml @@ -3,7 +3,7 @@ GameInitInfo@INIT_SETUP: TestFile: conquer.mix GameTitle: Command & Conquer PackageURL:http://open-ra.org/get-dependency.php?file=cnc-packages - PackagePath:^/packages/cnc + PackagePath:^/Content/cnc InstallMode:cnc Delegate:GameInitDelegate diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 358a1c281f..237583604a 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -10,7 +10,7 @@ Folders: ./mods/cnc/bits ./mods/cnc/uibits ~./mods/cnc/packages - ~^/packages/cnc + ~^/Content/cnc Packages: overrides.mix diff --git a/mods/ra/chrome/gameinit.yaml b/mods/ra/chrome/gameinit.yaml index ecb95c76e0..8d041372f7 100644 --- a/mods/ra/chrome/gameinit.yaml +++ b/mods/ra/chrome/gameinit.yaml @@ -3,7 +3,7 @@ GameInitInfo@INIT_SETUP: TestFile: redalert.mix GameTitle: Red Alert PackageURL:http://open-ra.org/get-dependency.php?file=ra-packages - PackagePath:^/packages/ra + PackagePath:^/Content/ra InstallMode:ra Delegate:GameInitDelegate diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index b5e5556463..a2d12a01bb 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -11,7 +11,7 @@ Folders: ./mods/ra/bits ./mods/ra/uibits ~./mods/ra/packages - ~^/packages/ra + ~^/Content/ra Packages: ~main.mix