Installer downloads now using specified IPackageLoader.
This commit is contained in:
committed by
Matthias Mailänder
parent
a9da6bb2d8
commit
fcc8f53b59
@@ -74,14 +74,17 @@ namespace OpenRA
|
||||
|
||||
public class ModDownload
|
||||
{
|
||||
public readonly ObjectCreator ObjectCreator;
|
||||
public readonly string Title;
|
||||
public readonly string URL;
|
||||
public readonly string MirrorList;
|
||||
public readonly string SHA1;
|
||||
public readonly string Type;
|
||||
public readonly Dictionary<string, string> Extract;
|
||||
|
||||
public ModDownload(MiniYaml yaml)
|
||||
public ModDownload(MiniYaml yaml, ObjectCreator objectCreator)
|
||||
{
|
||||
ObjectCreator = objectCreator;
|
||||
Title = yaml.Value;
|
||||
FieldLoader.Load(this, yaml);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -217,26 +217,29 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
try
|
||||
{
|
||||
using (var stream = File.OpenRead(file))
|
||||
using (var z = new ZipFile(stream))
|
||||
{
|
||||
var packageLoader = download.ObjectCreator.CreateObject<IPackageLoader>($"{download.Type}Loader");
|
||||
|
||||
if (packageLoader.TryParsePackage(stream, file, modData.ModFiles, out var package))
|
||||
{
|
||||
foreach (var kv in download.Extract)
|
||||
{
|
||||
var entry = z.GetEntry(kv.Value);
|
||||
if (entry == null || !entry.IsFile)
|
||||
if (!package.Contains(kv.Value))
|
||||
continue;
|
||||
|
||||
onExtractProgress(modData.Translation.GetString(ExtractingEntry, Translation.Arguments("entry", entry.Name)));
|
||||
Log.Write("install", "Extracting " + entry.Name);
|
||||
onExtractProgress(modData.Translation.GetString(ExtractingEntry, Translation.Arguments("entry", kv.Value)));
|
||||
Log.Write("install", "Extracting " + kv.Value);
|
||||
var targetPath = Platform.ResolvePath(kv.Key);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||
extracted.Add(targetPath);
|
||||
|
||||
using (var zz = z.GetInputStream(entry))
|
||||
using (var zz = package.GetStream(kv.Value))
|
||||
using (var f = File.Create(targetPath))
|
||||
zz.CopyTo(f);
|
||||
}
|
||||
|
||||
z.Close();
|
||||
package.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Game.RunAfterTick(() =>
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
|
||||
foreach (var d in downloadYaml)
|
||||
downloads.Add(d.Key, new ModContent.ModDownload(d.Value));
|
||||
downloads.Add(d.Key, new ModContent.ModDownload(d.Value, modObjectCreator));
|
||||
|
||||
modFileSystem.UnmountAll();
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
Ui.OpenWindow("PACKAGE_DOWNLOAD_PANEL", new WidgetArgs
|
||||
{
|
||||
{ "download", new ModContent.ModDownload(download.Value) },
|
||||
{ "download", new ModContent.ModDownload(download.Value, modObjectCreator) },
|
||||
{ "onSuccess", continueLoading }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
basefiles: Base Freeware Content
|
||||
Type: ZipFile
|
||||
SHA1: 72f337464963fa37d3688eb03e80eefd33669a3d
|
||||
MirrorList: http://www.openra.net/packages/cnc-mirrors.txt
|
||||
Extract:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
quickinstall: Quick Install Package
|
||||
Type: ZipFile
|
||||
SHA1: eb9ff88ca24858bd06a752f923156a6480c25c06
|
||||
MirrorList: http://www.openra.net/packages/d2k-quickinstall-mirrors.txt
|
||||
Extract:
|
||||
@@ -269,6 +270,7 @@ quickinstall: Quick Install Package
|
||||
^SupportDir|Content/d2k/v2/DATA.R8: v2/DATA.R8
|
||||
|
||||
basefiles: Base Content
|
||||
Type: ZipFile
|
||||
SHA1: 82221691fe843a5a245969095f147e929c364234
|
||||
MirrorList: http://www.openra.net/packages/d2k-base-mirrors.txt
|
||||
Extract:
|
||||
@@ -537,6 +539,7 @@ basefiles: Base Content
|
||||
^SupportDir|Content/d2k/v2/SOUND.RS: v2/SOUND.RS
|
||||
|
||||
patch106: Patch 1.06 Content
|
||||
Type: ZipFile
|
||||
SHA1: 90924e5254468ec79c71e456384f5895a6c84bae
|
||||
MirrorList: http://www.openra.net/packages/d2k-patch106-mirrors.txt
|
||||
Extract:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
quickinstall: Quick Install Package
|
||||
Type: ZipFile
|
||||
SHA1: 44241f68e69db9511db82cf83c174737ccda300b
|
||||
MirrorList: http://www.openra.net/packages/ra-quickinstall-mirrors.txt
|
||||
Extract:
|
||||
@@ -43,6 +44,7 @@ quickinstall: Quick Install Package
|
||||
^SupportDir|Content/ra/v2/cnc/desert.mix: cnc/desert.mix
|
||||
|
||||
basefiles: Base Freeware Content
|
||||
Type: ZipFile
|
||||
SHA1: aa022b208a3b45b4a45c00fdae22ccf3c6de3e5c
|
||||
MirrorList: http://www.openra.net/packages/ra-base-mirrors.txt
|
||||
Extract:
|
||||
@@ -59,6 +61,7 @@ basefiles: Base Freeware Content
|
||||
^SupportDir|Content/ra/v2/temperat.mix: temperat.mix
|
||||
|
||||
aftermath: Aftermath Expansion Files
|
||||
Type: ZipFile
|
||||
SHA1: d511d4363b485e11c63eecf96d4365d42ec4ef5e
|
||||
MirrorList: http://www.openra.net/packages/ra-aftermath-mirrors.txt
|
||||
Extract:
|
||||
@@ -91,6 +94,7 @@ aftermath: Aftermath Expansion Files
|
||||
^SupportDir|Content/ra/v2/expand/myes1.aud: expand/myes1.aud
|
||||
|
||||
cncdesert: C&C Desert Tileset
|
||||
Type: ZipFile
|
||||
SHA1: 039849f16e39e4722e8c838a393c8a0d6529fd59
|
||||
MirrorList: http://www.openra.net/packages/ra-cncdesert-mirrors.txt
|
||||
Extract:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
basefiles: Base Freeware Content
|
||||
Type: ZipFile
|
||||
SHA1: 824df30de0004ad13fac29cf16450caafee9fb1b
|
||||
MirrorList: http://www.openra.net/packages/ts-mirrors.txt
|
||||
Extract:
|
||||
@@ -18,6 +19,7 @@ basefiles: Base Freeware Content
|
||||
^SupportDir|Content/ts/temperat.mix: temperat.mix
|
||||
|
||||
fstorm: Expansion Freeware Content
|
||||
Type: ZipFile
|
||||
SHA1: 8bff90870a9348b72cbe91314aec7d3a50311aa9
|
||||
MirrorList: http://www.openra.net/packages/fs-mirrors.txt
|
||||
Extract:
|
||||
@@ -201,6 +203,7 @@ fstorm: Expansion Freeware Content
|
||||
^SupportDir|Content/ts/firestorm/bigblue3.tem: firestorm/bigblue3.tem
|
||||
|
||||
quickinstall: Quick Install Package
|
||||
Type: ZipFile
|
||||
SHA1: d9339e7b6ecf624ac6ca91d25c58b88fb88a49d2
|
||||
MirrorList: http://www.openra.net/packages/ts-quickinstall-mirrors.txt
|
||||
Extract:
|
||||
|
||||
Reference in New Issue
Block a user