Make it actually work

This commit is contained in:
Paul Chote
2011-05-04 18:55:23 +12:00
parent 07dac11144
commit 221d6ebd4f
6 changed files with 29 additions and 28 deletions

View File

@@ -18,6 +18,7 @@ using ICSharpCode.SharpZipLib.Zip;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Widgets; using OpenRA.Widgets;
using System.Threading;
namespace OpenRA.Mods.RA.Widgets.Delegates 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("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; };
window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD(); window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD();
switch (Info.InstallMode) var t = new Thread( _ =>
{ {
case "ra": switch (Info.InstallMode)
if (InstallRAPackages(window, path, Info.ResolvedPackagePath)) {
Game.RunAfterTick(TestAndContinue); case "ra":
break; if (InstallRAPackages(window, path, Info.ResolvedPackagePath))
case "cnc": Game.RunAfterTick(TestAndContinue);
if (InstallCncPackages(window, path, Info.ResolvedPackagePath)) break;
Game.RunAfterTick(TestAndContinue); case "cnc":
break; if (InstallCncPackages(window, path, Info.ResolvedPackagePath))
default: Game.RunAfterTick(TestAndContinue);
ShowDownloadError(window, "Installing from CD not supported"); break;
break; default:
} ShowError(window, "Installing from CD not supported");
break;
}
}) { IsBackground = true };
t.Start();
} }
void ShowDownloadDialog() void ShowDownloadDialog()
@@ -142,7 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) => Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>
{ {
if (i.Error != null) if (i.Error != null)
ShowDownloadError(window, i.Error.Message); ShowError(window, i.Error.Message);
else if (!cancelled) else if (!cancelled)
{ {
// Automatically extract // Automatically extract
@@ -151,7 +156,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
if (ExtractZip(window, file, Info.ResolvedPackagePath)) if (ExtractZip(window, file, Info.ResolvedPackagePath))
Game.RunAfterTick(TestAndContinue); Game.RunAfterTick(TestAndContinue);
} }
}; };
@@ -160,7 +164,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
window.GetWidget("RETRY").OnMouseUp = mi => { dl.Cancel(); ShowDownloadDialog(); return true; }; 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<LabelWidget>("STATUS") != null) /* ugh */ if (window.GetWidget<LabelWidget>("STATUS") != null) /* ugh */
{ {
@@ -202,7 +206,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{ {
if (!File.Exists(zipFile)) if (!File.Exists(zipFile))
{ {
ShowDownloadError(window, "Invalid path: "+zipFile); ShowError(window, "Invalid path: "+zipFile);
return false; return false;
} }
@@ -216,7 +220,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{ {
foreach(var f in extracted) foreach(var f in extracted)
File.Delete(f); File.Delete(f);
ShowDownloadError(window, "Archive corrupt"); ShowError(window, "Archive corrupt");
return false; return false;
} }
status.GetText = () => "Extraction complete"; status.GetText = () => "Extraction complete";
@@ -231,9 +235,9 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
if (!Directory.Exists(destPath)) if (!Directory.Exists(destPath))
Directory.CreateDirectory(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); 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); FileSystem.Mount(package);
foreach (string s in files) foreach (string s in files)
@@ -260,7 +264,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
var fromPath = Path.Combine(srcPath, file); var fromPath = Path.Combine(srcPath, file);
if (!File.Exists(fromPath)) if (!File.Exists(fromPath))
{ {
ShowDownloadError(window, "Cannot find "+file); ShowError(window, "Cannot find "+file);
return false; return false;
} }
status.GetText = () => "Extracting "+file.ToLowerInvariant(); status.GetText = () => "Extracting "+file.ToLowerInvariant();

View File

@@ -58,10 +58,7 @@ namespace OpenRA.Utility
var supportDir = GetNamedArg(args, "--SupportDir"); var supportDir = GetNamedArg(args, "--SupportDir");
if (supportDir != null) if (supportDir != null)
{
Log.LogPath = Path.Combine(supportDir.Replace("\"", ""), "Logs"); Log.LogPath = Path.Combine(supportDir.Replace("\"", ""), "Logs");
Console.WriteLine("LogPath: {0}", Log.LogPath);
}
try try
{ {

View File

@@ -3,7 +3,7 @@ GameInitInfo@INIT_SETUP:
TestFile: conquer.mix TestFile: conquer.mix
GameTitle: Command & Conquer GameTitle: Command & Conquer
PackageURL:http://open-ra.org/get-dependency.php?file=cnc-packages PackageURL:http://open-ra.org/get-dependency.php?file=cnc-packages
PackagePath:^/packages/cnc PackagePath:^/Content/cnc
InstallMode:cnc InstallMode:cnc
Delegate:GameInitDelegate Delegate:GameInitDelegate

View File

@@ -10,7 +10,7 @@ Folders:
./mods/cnc/bits ./mods/cnc/bits
./mods/cnc/uibits ./mods/cnc/uibits
~./mods/cnc/packages ~./mods/cnc/packages
~^/packages/cnc ~^/Content/cnc
Packages: Packages:
overrides.mix overrides.mix

View File

@@ -3,7 +3,7 @@ GameInitInfo@INIT_SETUP:
TestFile: redalert.mix TestFile: redalert.mix
GameTitle: Red Alert GameTitle: Red Alert
PackageURL:http://open-ra.org/get-dependency.php?file=ra-packages PackageURL:http://open-ra.org/get-dependency.php?file=ra-packages
PackagePath:^/packages/ra PackagePath:^/Content/ra
InstallMode:ra InstallMode:ra
Delegate:GameInitDelegate Delegate:GameInitDelegate

View File

@@ -11,7 +11,7 @@ Folders:
./mods/ra/bits ./mods/ra/bits
./mods/ra/uibits ./mods/ra/uibits
~./mods/ra/packages ~./mods/ra/packages
~^/packages/ra ~^/Content/ra
Packages: Packages:
~main.mix ~main.mix