Merge pull request #3888 from Mailaender/ts-asset-download

Added Auto-Download for Tiberian Sun assets
This commit is contained in:
Paul Chote
2013-10-05 01:33:57 -07:00
5 changed files with 25 additions and 22 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA.FileFormats
{ {
static IEnumerable<ZipEntry> GetEntries(this ZipInputStream z) static IEnumerable<ZipEntry> GetEntries(this ZipInputStream z)
{ {
for (; ; ) for (;;)
{ {
var e = z.GetNextEntry(); var e = z.GetNextEntry();
if (e != null) yield return e; else break; if (e != null) yield return e; else break;
@@ -43,9 +43,9 @@ namespace OpenRA.FileFormats
if (!Directory.Exists(destPath)) if (!Directory.Exists(destPath))
Directory.CreateDirectory(destPath); Directory.CreateDirectory(destPath);
if (!Directory.Exists(srcPath)) { onError("Cannot find "+package); return false; } if (!Directory.Exists(srcPath)) { onError("Cannot find " + package); return false; }
FileSystem.Mount(srcPath); FileSystem.Mount(srcPath);
if (!FileSystem.Exists(package)) { onError("Cannot find "+package); return false; } if (!FileSystem.Exists(package)) { onError("Cannot find " + package); return false; }
FileSystem.Mount(package); FileSystem.Mount(package);
foreach (string s in files) foreach (string s in files)
@@ -54,10 +54,11 @@ namespace OpenRA.FileFormats
using (var sourceStream = FileSystem.Open(s)) using (var sourceStream = FileSystem.Open(s))
using (var destStream = File.Create(destFile)) using (var destStream = File.Create(destFile))
{ {
onProgress("Extracting "+s); onProgress("Extracting " + s);
destStream.Write(sourceStream.ReadAllBytes()); destStream.Write(sourceStream.ReadAllBytes());
} }
} }
return true; return true;
} }
@@ -68,13 +69,15 @@ namespace OpenRA.FileFormats
var fromPath = Path.Combine(srcPath, file); var fromPath = Path.Combine(srcPath, file);
if (!File.Exists(fromPath)) if (!File.Exists(fromPath))
{ {
onError("Cannot find "+file); onError("Cannot find " + file);
return false; return false;
} }
var destFile = Path.GetFileName(file).ToLowerInvariant(); var destFile = Path.GetFileName(file).ToLowerInvariant();
onProgress("Extracting "+destFile); onProgress("Extracting " + destFile);
File.Copy(fromPath, Path.Combine(destPath, destFile), true); File.Copy(fromPath, Path.Combine(destPath, destFile), true);
} }
return true; return true;
} }
@@ -82,7 +85,7 @@ namespace OpenRA.FileFormats
{ {
if (!File.Exists(zipFile)) if (!File.Exists(zipFile))
{ {
onError("Invalid path: "+zipFile); onError("Invalid path: " + zipFile);
return false; return false;
} }
@@ -90,16 +93,17 @@ namespace OpenRA.FileFormats
try try
{ {
var z = new ZipInputStream(File.OpenRead(zipFile)); var z = new ZipInputStream(File.OpenRead(zipFile));
z.ExtractZip(dest, extracted, s => onProgress("Extracting "+s)); z.ExtractZip(dest, extracted, s => onProgress("Extracting " + s));
} }
catch (SharpZipBaseException) catch (SharpZipBaseException)
{ {
foreach(var f in extracted) foreach (var f in extracted)
File.Delete(f); File.Delete(f);
onError("Invalid archive"); onError("Invalid archive");
return false; return false;
} }
return true; return true;
} }

View File

@@ -22,13 +22,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class DownloadPackagesLogic public class DownloadPackagesLogic
{ {
Widget panel; Widget panel;
Dictionary<string,string> installData; Dictionary<string, string> installData;
ProgressBarWidget progressBar; ProgressBarWidget progressBar;
LabelWidget statusLabel; LabelWidget statusLabel;
Action afterInstall; Action afterInstall;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DownloadPackagesLogic(Widget widget, Dictionary<string,string> installData, Action afterInstall) public DownloadPackagesLogic(Widget widget, Dictionary<string, string> installData, Action afterInstall)
{ {
this.installData = installData; this.installData = installData;
this.afterInstall = afterInstall; this.afterInstall = afterInstall;
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
Game.RunAfterTick(() => Game.RunAfterTick(() =>
{ {
statusLabel.GetText = () => "Error: "+s; statusLabel.GetText = () => "Error: " + s;
retryButton.IsVisible = () => true; retryButton.IsVisible = () => true;
}); });
}; };

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class RAInstallLogic public class RAInstallLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public RAInstallLogic(Widget widget, Dictionary<string,string> installData, Action continueLoading) public RAInstallLogic(Widget widget, Dictionary<string, string> installData, Action continueLoading)
{ {
var panel = widget.Get("INSTALL_PANEL"); var panel = widget.Get("INSTALL_PANEL");
var args = new WidgetArgs() var args = new WidgetArgs()
@@ -38,9 +38,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
panel.Get<ButtonWidget>("MODS_BUTTON").OnClick = () => panel.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Ui.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => {} }, { "onExit", () => { } },
// Close this panel
{ "onSwitch", Ui.CloseWindow }, { "onSwitch", Ui.CloseWindow },
}); });
}; };

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.TS
public class TSLoadScreen : ILoadScreen public class TSLoadScreen : ILoadScreen
{ {
Dictionary<string, string> Info; Dictionary<string, string> Info;
static string[] Comments = new[] { "Updating EVA installation..." }; static string[] Comments = new[] { "Updating EVA installation...", "Changing perspective..." };
Stopwatch lastLoadScreen = new Stopwatch(); Stopwatch lastLoadScreen = new Stopwatch();
Rectangle StripeRect; Rectangle StripeRect;

View File

@@ -50,8 +50,8 @@ Packages:
temperat.mix:CRC32 temperat.mix:CRC32
# Firestorm # Firestorm
~scores01.mix:CRC32 ~scores01.mix:CRC32
expand01.mix:CRC32 ~expand01.mix:CRC32
sounds01.mix:CRC32 ~sounds01.mix:CRC32
~e01sc01.mix:CRC32 ~e01sc01.mix:CRC32
~e01sc02.mix:CRC32 ~e01sc02.mix:CRC32
~e01vox01.mix:CRC32 ~e01vox01.mix:CRC32
@@ -137,8 +137,8 @@ Movies:
LoadScreen: TSLoadScreen LoadScreen: TSLoadScreen
LoadScreenImage: mods/ts/uibits/loadscreen.png LoadScreenImage: mods/ts/uibits/loadscreen.png
InstallerMenuWidget: INSTALL_PANEL InstallerMenuWidget: INSTALL_PANEL
TestFile: tibsun.mix TestFile: isotemp.mix
PackageURL: http://open-ra.org/get-dependency.php?file=ts-packages # TODO: upload a stripped down package PackageURL: http://open-ra.org/get-dependency.php?file=ts-packages
ServerTraits: ServerTraits:
LobbyCommands LobbyCommands