diff --git a/OpenRA.Game/GameRules/RulesetCache.cs b/OpenRA.Game/GameRules/RulesetCache.cs index 715ea41f63..f61320f845 100644 --- a/OpenRA.Game/GameRules/RulesetCache.cs +++ b/OpenRA.Game/GameRules/RulesetCache.cs @@ -122,7 +122,8 @@ namespace OpenRA return itemSet; } - Dictionary LoadTileSets(IReadOnlyFileSystem fileSystem, Dictionary itemCache, Dictionary sequenceCaches, string[] files) + Dictionary LoadTileSets(IReadOnlyFileSystem fileSystem, Dictionary itemCache, + Dictionary sequenceCaches, string[] files) { var items = new Dictionary(); @@ -133,7 +134,7 @@ namespace OpenRA items.Add(t.Id, t); else { - t = new TileSet(modData, file); + t = new TileSet(fileSystem, file); itemCache.Add(file, t); // every time we load a tile set, we create a sequence cache for it diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index 67e0ca3927..903dea1569 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; +using OpenRA.FileSystem; using OpenRA.Primitives; namespace OpenRA @@ -191,9 +192,9 @@ namespace OpenRA // Private default ctor for serialization comparison TileSet() { } - public TileSet(ModData modData, string filepath) + public TileSet(IReadOnlyFileSystem fileSystem, string filepath) { - var yaml = MiniYaml.DictFromStream(modData.ModFiles.Open(filepath)); + var yaml = MiniYaml.DictFromStream(fileSystem.Open(filepath)); // General info FieldLoader.Load(this, yaml["General"]); diff --git a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs index 818b3f8b93..a95ab4fa03 100644 --- a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs +++ b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs @@ -142,7 +142,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands public override void ReadPacks(IniFile file, string filename) { - using (var s = Game.ModData.ModFiles.Open(filename.Substring(0, filename.Length - 4) + ".bin")) + using (var s = ModData.DefaultFileSystem.Open(filename.Substring(0, filename.Length - 4) + ".bin")) UnpackTileData(s); ReadOverlay(file); diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckSequenceSprites.cs b/OpenRA.Mods.Common/UtilityCommands/CheckSequenceSprites.cs index 32df401ae1..37e4e85a7d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckSequenceSprites.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckSequenceSprites.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.UtilityCommands foreach (var t in modData.Manifest.TileSets) { - var ts = new TileSet(modData, t); + var ts = new TileSet(modData.DefaultFileSystem, t); Console.WriteLine("Tileset: " + ts.Name); var sc = new SpriteCache(modData.DefaultFileSystem, modData.SpriteLoaders, new SheetBuilder(SheetType.Indexed)); var nodes = MiniYaml.Merge(modData.Manifest.Sequences.Select(s => MiniYaml.FromStream(modData.DefaultFileSystem.Open(s)))); diff --git a/OpenRA.Mods.Common/UtilityCommands/FixClassicTilesets.cs b/OpenRA.Mods.Common/UtilityCommands/FixClassicTilesets.cs index cb75142c0f..c7ded37ed9 100644 --- a/OpenRA.Mods.Common/UtilityCommands/FixClassicTilesets.cs +++ b/OpenRA.Mods.Common/UtilityCommands/FixClassicTilesets.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.UtilityCommands foreach (var t in modData.Manifest.TileSets) { - var ts = new TileSet(modData, t); + var ts = new TileSet(modData.DefaultFileSystem, t); var frameCache = new FrameCache(modData.DefaultFileSystem, modData.SpriteLoaders); Console.WriteLine("Tileset: " + ts.Name); diff --git a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs index 8cb3afbba9..bc21ec4f6a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs @@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.UtilityCommands MapSize = mapSize; } + public ModData ModData; public Map Map; public Ruleset Rules; public List Players = new List(); @@ -42,9 +43,10 @@ namespace OpenRA.Mods.Common.UtilityCommands [Desc("FILENAME", "Convert a legacy INI/MPR map to the OpenRA format.")] public virtual void Run(ModData modData, string[] args) { + ModData = modData; + // HACK: The engine code assumes that Game.modData is set. Game.ModData = modData; - Rules = modData.RulesetCache.Load(modData.DefaultFileSystem); var filename = args[1]; diff --git a/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs index a65305d7e2..3c7a985d35 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic public CreditsLogic(Widget widget, Action onExit) { var panel = widget.Get("CREDITS_PANEL"); + var modData = Game.ModData; panel.Get("BACK_BUTTON").OnClick = () => { @@ -31,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var template = scrollPanel.Get("CREDITS_TEMPLATE"); scrollPanel.RemoveChildren(); - var lines = Game.ModData.ModFiles.Open("AUTHORS").ReadAllLines(); + var lines = modData.DefaultFileSystem.Open("AUTHORS").ReadAllLines(); foreach (var l in lines) { // Improve the formatting diff --git a/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs b/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs index 373a746f41..9b02045006 100644 --- a/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets { if (filename == cachedVideo) return; - var video = new VqaReader(Game.ModData.ModFiles.Open(filename)); + var video = new VqaReader(Game.ModData.DefaultFileSystem.Open(filename)); cachedVideo = filename; Open(video);