Implement mod-defined package loaders.
This commit is contained in:
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
|
||||
|
||||
Map.Save(ZipFile.Create(dest, new Folder(".")));
|
||||
Map.Save(ZipFileLoader.Create(dest, new Folder(".")));
|
||||
Console.WriteLine(dest + " saved.");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
[Desc("ARCHIVE.Z", "Lists the content ranges for a InstallShield V3 file")]
|
||||
void IUtilityCommand.Run(Utility utility, string[] args)
|
||||
{
|
||||
var filename = Path.GetFileName(args[1]);
|
||||
var path = Path.GetDirectoryName(args[1]);
|
||||
|
||||
var fs = new FileSystem.FileSystem(utility.Mods);
|
||||
fs.Mount(path, "parent");
|
||||
var package = new InstallShieldPackage(fs, "parent|" + filename);
|
||||
|
||||
var package = new InstallShieldLoader.InstallShieldPackage(File.OpenRead(args[1]), args[1]);
|
||||
foreach (var kv in package.Index)
|
||||
{
|
||||
Console.WriteLine("{0}:", kv.Key);
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileSystem;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
@@ -22,23 +24,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
bool IUtilityCommand.ValidateArguments(string[] args)
|
||||
{
|
||||
return args.Length == 2;
|
||||
return args.Length == 3;
|
||||
}
|
||||
|
||||
[Desc("ARCHIVE.MIX", "Lists the content ranges for a mix file")]
|
||||
[Desc("ARCHIVE.MIX", "MIXDATABASE.DAT", "Lists the content ranges for a mix file")]
|
||||
void IUtilityCommand.Run(Utility utility, string[] args)
|
||||
{
|
||||
var filename = Path.GetFileName(args[1]);
|
||||
var path = Path.GetDirectoryName(args[1]);
|
||||
|
||||
var fs = new FileSystem.FileSystem(utility.Mods);
|
||||
|
||||
// Needed to access the global mix database
|
||||
fs.LoadFromManifest(utility.ModData.Manifest);
|
||||
|
||||
fs.Mount(path, "parent");
|
||||
var package = new MixFile(fs, "parent|" + filename);
|
||||
var allPossibleFilenames = new HashSet<string>();
|
||||
using (var db = new XccGlobalDatabase(File.OpenRead(args[2])))
|
||||
foreach (var e in db.Entries)
|
||||
allPossibleFilenames.Add(e);
|
||||
|
||||
var package = new MixLoader.MixFile(File.OpenRead(args[1]), args[1], allPossibleFilenames);
|
||||
foreach (var kv in package.Index.OrderBy(kv => kv.Value.Offset))
|
||||
{
|
||||
Console.WriteLine("{0}:", kv.Key);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
directoryDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, writableDirectories, setupItem);
|
||||
}
|
||||
|
||||
var mapIsUnpacked = map.Package != null && (map.Package is Folder || map.Package is ZipFolder);
|
||||
var mapIsUnpacked = map.Package != null && map.Package is Folder;
|
||||
|
||||
var filename = widget.Get<TextFieldWidget>("FILENAME");
|
||||
filename.Text = map.Package == null ? "" : mapIsUnpacked ? Path.GetFileName(map.Package.Name) : Path.GetFileNameWithoutExtension(map.Package.Name);
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
selectedDirectory.Folder.Delete(combinedPath);
|
||||
if (fileType == MapFileType.OraMap)
|
||||
package = ZipFile.Create(combinedPath, selectedDirectory.Folder);
|
||||
package = ZipFileLoader.Create(combinedPath, selectedDirectory.Folder);
|
||||
else
|
||||
package = new Folder(combinedPath);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -28,13 +29,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool discAvailable;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ModContentLogic(Widget widget, Manifest mod, ModContent content, Action onCancel)
|
||||
public ModContentLogic(Widget widget, ModData modData, Manifest mod, ModContent content, Action onCancel)
|
||||
{
|
||||
this.content = content;
|
||||
|
||||
var panel = widget.Get("CONTENT_PANEL");
|
||||
|
||||
var modFileSystem = new FileSystem.FileSystem(Game.Mods);
|
||||
var modObjectCreator = new ObjectCreator(mod, Game.Mods);
|
||||
var modPackageLoaders = modObjectCreator.GetLoaders<IPackageLoader>(mod.PackageFormats, "package");
|
||||
var modFileSystem = new FileSystem.FileSystem(Game.Mods, modPackageLoaders);
|
||||
modFileSystem.LoadFromManifest(mod);
|
||||
|
||||
var sourceYaml = MiniYaml.Load(modFileSystem, content.Sources, null);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -18,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class ModContentPromptLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public ModContentPromptLogic(Widget widget, Manifest mod, ModContent content, Action continueLoading)
|
||||
public ModContentPromptLogic(Widget widget, ModData modData, Manifest mod, ModContent content, Action continueLoading)
|
||||
{
|
||||
var panel = widget.Get("CONTENT_PROMPT_PANEL");
|
||||
|
||||
@@ -55,8 +56,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
quickButton.Bounds.Y += headerHeight;
|
||||
quickButton.OnClick = () =>
|
||||
{
|
||||
var modFileSystem = new FileSystem.FileSystem(Game.Mods);
|
||||
var modObjectCreator = new ObjectCreator(mod, Game.Mods);
|
||||
var modPackageLoaders = modObjectCreator.GetLoaders<IPackageLoader>(mod.PackageFormats, "package");
|
||||
var modFileSystem = new FileSystem.FileSystem(Game.Mods, modPackageLoaders);
|
||||
modFileSystem.LoadFromManifest(mod);
|
||||
|
||||
var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
|
||||
modFileSystem.UnmountAll();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user