Move file system mounting into mod code.
This commit is contained in:
@@ -181,12 +181,8 @@ namespace OpenRA.FileSystem
|
||||
fileIndex = new Cache<string, List<IReadOnlyPackage>>(_ => new List<IReadOnlyPackage>());
|
||||
}
|
||||
|
||||
public void LoadFromManifest(Manifest manifest)
|
||||
public void TrimExcess()
|
||||
{
|
||||
UnmountAll();
|
||||
foreach (var kv in manifest.Packages)
|
||||
Mount(kv.Key, kv.Value);
|
||||
|
||||
mountedPackages.TrimExcess();
|
||||
explicitMounts.TrimExcess();
|
||||
modPackages.TrimExcess();
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace OpenRA
|
||||
Weapons, Voices, Notifications, Music, Translations, TileSets,
|
||||
ChromeMetrics, MapCompatibility, Missions, Hotkeys;
|
||||
|
||||
public readonly IReadOnlyDictionary<string, string> Packages;
|
||||
public readonly IReadOnlyDictionary<string, string> MapFolders;
|
||||
public readonly MiniYaml FileSystem;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly string DefaultOrderGenerator;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA
|
||||
|
||||
readonly string[] reservedModuleNames =
|
||||
{
|
||||
"Include", "Metadata", "Folders", "MapFolders", "Packages", "Rules",
|
||||
"Include", "Metadata", "FileSystem", "MapFolders", "Rules",
|
||||
"Sequences", "ModelSequences", "Cursors", "Chrome", "Assemblies", "ChromeLayout", "Weapons",
|
||||
"Voices", "Notifications", "Music", "Translations", "TileSets", "ChromeMetrics", "Missions", "Hotkeys",
|
||||
"ServerTraits", "LoadScreen", "DefaultOrderGenerator", "SupportsMapsFrom", "SoundFormats", "SpriteFormats", "VideoFormats",
|
||||
@@ -123,8 +123,8 @@ namespace OpenRA
|
||||
// TODO: Use fieldloader
|
||||
MapFolders = YamlDictionary(yaml, "MapFolders");
|
||||
|
||||
if (yaml.TryGetValue("Packages", out var packages))
|
||||
Packages = packages.ToDictionary(x => x.Value);
|
||||
if (!yaml.TryGetValue("FileSystem", out FileSystem))
|
||||
throw new InvalidDataException("`FileSystem` section is not defined.");
|
||||
|
||||
Rules = YamlList(yaml, "Rules");
|
||||
Sequences = YamlList(yaml, "Sequences");
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace OpenRA
|
||||
public readonly ISpriteSequenceLoader SpriteSequenceLoader;
|
||||
public readonly IVideoLoader[] VideoLoaders;
|
||||
public readonly HotkeyManager Hotkeys;
|
||||
public readonly IFileSystemLoader FileSystemLoader;
|
||||
|
||||
public ILoadScreen LoadScreen { get; }
|
||||
public CursorProvider CursorProvider { get; private set; }
|
||||
public FS ModFiles;
|
||||
@@ -54,9 +56,13 @@ namespace OpenRA
|
||||
Manifest = new Manifest(mod.Id, mod.Package);
|
||||
ObjectCreator = new ObjectCreator(Manifest, mods);
|
||||
PackageLoaders = ObjectCreator.GetLoaders<IPackageLoader>(Manifest.PackageFormats, "package");
|
||||
|
||||
ModFiles = new FS(mod.Id, mods, PackageLoaders);
|
||||
ModFiles.LoadFromManifest(Manifest);
|
||||
|
||||
FileSystemLoader = ObjectCreator.GetLoader<IFileSystemLoader>(Manifest.FileSystem.Value, "filesystem");
|
||||
FieldLoader.Load(FileSystemLoader, Manifest.FileSystem);
|
||||
FileSystemLoader.Mount(ModFiles, ObjectCreator);
|
||||
ModFiles.TrimExcess();
|
||||
|
||||
Manifest.LoadCustomData(ObjectCreator);
|
||||
|
||||
if (useLoadScreen)
|
||||
@@ -190,4 +196,9 @@ namespace OpenRA
|
||||
/// <summary>Called when the engine expects to connect to a server/replay or load the shellmap.</summary>
|
||||
void StartGame(Arguments args);
|
||||
}
|
||||
|
||||
public interface IFileSystemLoader
|
||||
{
|
||||
void Mount(FS fileSystem, ObjectCreator objectCreator);
|
||||
}
|
||||
}
|
||||
|
||||
27
OpenRA.Mods.Common/FileSystem/DefaultFileSystemLoader.cs
Normal file
27
OpenRA.Mods.Common/FileSystem/DefaultFileSystemLoader.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.FileSystem
|
||||
{
|
||||
public class DefaultFileSystemLoader : IFileSystemLoader
|
||||
{
|
||||
public readonly Dictionary<string, string> Packages = null;
|
||||
|
||||
public void Mount(OpenRA.FileSystem.FileSystem fileSystem, ObjectCreator objectCreator)
|
||||
{
|
||||
if (Packages != null)
|
||||
foreach (var kv in Packages)
|
||||
fileSystem.Mount(kv.Key, kv.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var modObjectCreator = new ObjectCreator(mod, Game.Mods);
|
||||
var modPackageLoaders = modObjectCreator.GetLoaders<IPackageLoader>(mod.PackageFormats, "package");
|
||||
var modFileSystem = new FS(mod.Id, Game.Mods, modPackageLoaders);
|
||||
modFileSystem.LoadFromManifest(mod);
|
||||
|
||||
var modFileSystemLoader = modObjectCreator.GetLoader<IFileSystemLoader>(mod.FileSystem.Value, "filesystem");
|
||||
FieldLoader.Load(modFileSystemLoader, mod.FileSystem);
|
||||
modFileSystemLoader.Mount(modFileSystem, modObjectCreator);
|
||||
modFileSystem.TrimExcess();
|
||||
|
||||
var sourceYaml = MiniYaml.Load(modFileSystem, content.Sources, null);
|
||||
foreach (var s in sourceYaml)
|
||||
|
||||
@@ -78,7 +78,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var modObjectCreator = new ObjectCreator(mod, Game.Mods);
|
||||
var modPackageLoaders = modObjectCreator.GetLoaders<IPackageLoader>(mod.PackageFormats, "package");
|
||||
var modFileSystem = new FS(mod.Id, Game.Mods, modPackageLoaders);
|
||||
modFileSystem.LoadFromManifest(mod);
|
||||
|
||||
var modFileSystemLoader = modObjectCreator.GetLoader<IFileSystemLoader>(mod.FileSystem.Value, "filesystem");
|
||||
FieldLoader.Load(modFileSystemLoader, mod.FileSystem);
|
||||
modFileSystemLoader.Mount(modFileSystem, modObjectCreator);
|
||||
modFileSystem.TrimExcess();
|
||||
|
||||
var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
|
||||
modFileSystem.UnmountAll();
|
||||
|
||||
@@ -3,8 +3,9 @@ Metadata:
|
||||
Version: {DEV_VERSION}
|
||||
Hidden: true
|
||||
|
||||
Packages:
|
||||
^EngineDir
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
^EngineDir
|
||||
|
||||
Cursors:
|
||||
|
||||
|
||||
@@ -7,33 +7,34 @@ Metadata:
|
||||
|
||||
PackageFormats: Mix
|
||||
|
||||
Packages:
|
||||
~^SupportDir|Content/cnc
|
||||
~^SupportDir|Content/cnc/movies
|
||||
^EngineDir
|
||||
$cnc: cnc
|
||||
^EngineDir|mods/common: common
|
||||
~speech.mix
|
||||
~conquer.mix
|
||||
~sounds.mix
|
||||
~tempicnh.mix
|
||||
~temperat.mix
|
||||
~winter.mix
|
||||
~desert.mix
|
||||
~movies.mix
|
||||
~scores.mix
|
||||
~scores2.mix
|
||||
~scores-covertops.mix
|
||||
~transit.mix
|
||||
~general.mix
|
||||
cnc|bits/snow.mix
|
||||
cnc|bits
|
||||
cnc|bits/jungle
|
||||
cnc|bits/desert
|
||||
cnc|bits/ss
|
||||
cnc|scripts
|
||||
common|scripts
|
||||
cnc|uibits
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
~^SupportDir|Content/cnc
|
||||
~^SupportDir|Content/cnc/movies
|
||||
^EngineDir
|
||||
$cnc: cnc
|
||||
^EngineDir|mods/common: common
|
||||
~speech.mix
|
||||
~conquer.mix
|
||||
~sounds.mix
|
||||
~tempicnh.mix
|
||||
~temperat.mix
|
||||
~winter.mix
|
||||
~desert.mix
|
||||
~movies.mix
|
||||
~scores.mix
|
||||
~scores2.mix
|
||||
~scores-covertops.mix
|
||||
~transit.mix
|
||||
~general.mix
|
||||
cnc|bits/snow.mix
|
||||
cnc|bits
|
||||
cnc|bits/jungle
|
||||
cnc|bits/desert
|
||||
cnc|bits/ss
|
||||
cnc|scripts
|
||||
common|scripts
|
||||
cnc|uibits
|
||||
|
||||
MapFolders:
|
||||
cnc|maps: System
|
||||
|
||||
@@ -7,20 +7,20 @@ Metadata:
|
||||
|
||||
PackageFormats: D2kSoundResources
|
||||
|
||||
Packages:
|
||||
~^SupportDir|Content/d2k/v3/
|
||||
~^SupportDir|Content/d2k/v3/GAMESFX
|
||||
~^SupportDir|Content/d2k/v3/Movies
|
||||
~^SupportDir|Content/d2k/v3/Music
|
||||
^EngineDir
|
||||
$d2k: d2k
|
||||
^EngineDir|mods/common: common
|
||||
|
||||
~SOUND.RS
|
||||
d2k|bits
|
||||
d2k|scripts
|
||||
common|scripts
|
||||
d2k|uibits
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
~^SupportDir|Content/d2k/v3/
|
||||
~^SupportDir|Content/d2k/v3/GAMESFX
|
||||
~^SupportDir|Content/d2k/v3/Movies
|
||||
~^SupportDir|Content/d2k/v3/Music
|
||||
^EngineDir
|
||||
$d2k: d2k
|
||||
^EngineDir|mods/common: common
|
||||
~SOUND.RS
|
||||
d2k|bits
|
||||
d2k|scripts
|
||||
common|scripts
|
||||
d2k|uibits
|
||||
|
||||
MapFolders:
|
||||
d2k|maps: System
|
||||
|
||||
@@ -3,10 +3,11 @@ Metadata:
|
||||
Version: {DEV_VERSION}
|
||||
Hidden: true
|
||||
|
||||
Packages:
|
||||
^EngineDir
|
||||
^EngineDir|mods/modcontent: modcontent
|
||||
^EngineDir|mods/common: common
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
^EngineDir
|
||||
^EngineDir|mods/modcontent: modcontent
|
||||
^EngineDir|mods/common: common
|
||||
|
||||
Rules:
|
||||
modcontent|rules.yaml
|
||||
|
||||
@@ -7,36 +7,37 @@ Metadata:
|
||||
|
||||
PackageFormats: Mix
|
||||
|
||||
Packages:
|
||||
~^SupportDir|Content/ra/v2/
|
||||
~^SupportDir|Content/ra/v2/expand
|
||||
~^SupportDir|Content/ra/v2/cnc
|
||||
~^SupportDir|Content/ra/v2/movies
|
||||
^EngineDir
|
||||
$ra: ra
|
||||
^EngineDir|mods/common: common
|
||||
~main.mix
|
||||
~conquer.mix
|
||||
~lores.mix: lores
|
||||
~hires.mix
|
||||
~local.mix
|
||||
~sounds.mix
|
||||
~speech.mix
|
||||
~allies.mix
|
||||
~russian.mix
|
||||
~temperat.mix
|
||||
~snow.mix
|
||||
~interior.mix
|
||||
~scores.mix
|
||||
~expand2.mix
|
||||
~hires1.mix
|
||||
~desert.mix
|
||||
~general.mix
|
||||
ra|bits
|
||||
ra|bits/desert
|
||||
ra|scripts
|
||||
common|scripts
|
||||
ra|uibits
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
~^SupportDir|Content/ra/v2/
|
||||
~^SupportDir|Content/ra/v2/expand
|
||||
~^SupportDir|Content/ra/v2/cnc
|
||||
~^SupportDir|Content/ra/v2/movies
|
||||
^EngineDir
|
||||
$ra: ra
|
||||
^EngineDir|mods/common: common
|
||||
~main.mix
|
||||
~conquer.mix
|
||||
~lores.mix: lores
|
||||
~hires.mix
|
||||
~local.mix
|
||||
~sounds.mix
|
||||
~speech.mix
|
||||
~allies.mix
|
||||
~russian.mix
|
||||
~temperat.mix
|
||||
~snow.mix
|
||||
~interior.mix
|
||||
~scores.mix
|
||||
~expand2.mix
|
||||
~hires1.mix
|
||||
~desert.mix
|
||||
~general.mix
|
||||
ra|bits
|
||||
ra|bits/desert
|
||||
ra|scripts
|
||||
common|scripts
|
||||
ra|uibits
|
||||
|
||||
MapFolders:
|
||||
ra|maps: System
|
||||
|
||||
@@ -7,48 +7,49 @@ Metadata:
|
||||
|
||||
PackageFormats: Mix
|
||||
|
||||
Packages:
|
||||
~^SupportDir|Content/ts
|
||||
~^SupportDir|Content/ts/firestorm
|
||||
^EngineDir
|
||||
$ts: ts
|
||||
^EngineDir|mods/common: common
|
||||
FileSystem: DefaultFileSystem
|
||||
Packages:
|
||||
~^SupportDir|Content/ts
|
||||
~^SupportDir|Content/ts/firestorm
|
||||
^EngineDir
|
||||
$ts: ts
|
||||
^EngineDir|mods/common: common
|
||||
|
||||
# Tiberian Sun
|
||||
~scores.mix
|
||||
~sidenc01.mix
|
||||
~sidenc02.mix
|
||||
~e01scd01.mix
|
||||
~e01scd02.mix
|
||||
~movies01.mix
|
||||
~movies02.mix
|
||||
~sidecd01.mix
|
||||
~sidecd02.mix
|
||||
~cache.mix
|
||||
~conquer.mix
|
||||
~isosnow.mix
|
||||
~isotemp.mix
|
||||
~local.mix
|
||||
~sidec01.mix: sidebar-gdi
|
||||
~sidec02.mix: sidebar-nod
|
||||
~sno.mix
|
||||
~snow.mix
|
||||
~sounds.mix
|
||||
~speech01.mix: speech-gdi
|
||||
~speech02.mix: speech-nod
|
||||
~tem.mix
|
||||
~temperat.mix
|
||||
# Firestorm
|
||||
~scores01.mix
|
||||
~expand01.mix
|
||||
~sounds01.mix
|
||||
~e01sc01.mix
|
||||
~e01sc02.mix
|
||||
~e01vox01.mix
|
||||
~e01vox02.mix
|
||||
~ecache01.mix
|
||||
ts|bits
|
||||
ts|uibits
|
||||
# Tiberian Sun
|
||||
~scores.mix
|
||||
~sidenc01.mix
|
||||
~sidenc02.mix
|
||||
~e01scd01.mix
|
||||
~e01scd02.mix
|
||||
~movies01.mix
|
||||
~movies02.mix
|
||||
~sidecd01.mix
|
||||
~sidecd02.mix
|
||||
~cache.mix
|
||||
~conquer.mix
|
||||
~isosnow.mix
|
||||
~isotemp.mix
|
||||
~local.mix
|
||||
~sidec01.mix: sidebar-gdi
|
||||
~sidec02.mix: sidebar-nod
|
||||
~sno.mix
|
||||
~snow.mix
|
||||
~sounds.mix
|
||||
~speech01.mix: speech-gdi
|
||||
~speech02.mix: speech-nod
|
||||
~tem.mix
|
||||
~temperat.mix
|
||||
# Firestorm
|
||||
~scores01.mix
|
||||
~expand01.mix
|
||||
~sounds01.mix
|
||||
~e01sc01.mix
|
||||
~e01sc02.mix
|
||||
~e01vox01.mix
|
||||
~e01vox02.mix
|
||||
~ecache01.mix
|
||||
ts|bits
|
||||
ts|uibits
|
||||
|
||||
MapFolders:
|
||||
ts|maps: System
|
||||
|
||||
Reference in New Issue
Block a user