diff --git a/OpenRA.Game/GameRules/RulesetCache.cs b/OpenRA.Game/GameRules/RulesetCache.cs index 93ea54c438..d15aed6600 100644 --- a/OpenRA.Game/GameRules/RulesetCache.cs +++ b/OpenRA.Game/GameRules/RulesetCache.cs @@ -112,7 +112,7 @@ namespace OpenRA return t; }; - var tree = MiniYaml.Merge(files.Select(MiniYaml.FromFile).Append(nodes)) + var tree = MiniYaml.Merge(files.Select(s => MiniYaml.FromStream(modData.ModFiles.Open(s))).Append(nodes)) .ToDictionaryWithConflictLog(n => n.Key, n => n.Value, "LoadYamlRules", null, null); RaiseProgress(); diff --git a/OpenRA.Game/Graphics/ChromeProvider.cs b/OpenRA.Game/Graphics/ChromeProvider.cs index c26d7cb968..5b6c3be2cf 100644 --- a/OpenRA.Game/Graphics/ChromeProvider.cs +++ b/OpenRA.Game/Graphics/ChromeProvider.cs @@ -25,7 +25,7 @@ namespace OpenRA.Graphics static Dictionary cachedSheets; static Dictionary> cachedSprites; - public static void Initialize(IEnumerable chromeFiles) + public static void Initialize(ModData modData) { Deinitialize(); @@ -33,7 +33,9 @@ namespace OpenRA.Graphics cachedSheets = new Dictionary(); cachedSprites = new Dictionary>(); - var chrome = MiniYaml.Merge(chromeFiles.Select(MiniYaml.FromFile)); + var chrome = MiniYaml.Merge(modData.Manifest.Chrome + .Select(s => MiniYaml.FromStream(modData.ModFiles.Open(s)))); + foreach (var c in chrome) LoadCollection(c.Key, c.Value); } diff --git a/OpenRA.Game/Graphics/CursorProvider.cs b/OpenRA.Game/Graphics/CursorProvider.cs index ed4b6d8f94..1d69d65f1c 100644 --- a/OpenRA.Game/Graphics/CursorProvider.cs +++ b/OpenRA.Game/Graphics/CursorProvider.cs @@ -21,11 +21,12 @@ namespace OpenRA.Graphics public CursorProvider(ModData modData) { - var sequences = new MiniYaml(null, MiniYaml.Merge(modData.Manifest.Cursors.Select(MiniYaml.FromFile))); + var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select( + s => MiniYaml.FromStream(modData.ModFiles.Open(s)))); var shadowIndex = new int[] { }; - var nodesDict = sequences.ToDictionary(); + var nodesDict = new MiniYaml(null, sequenceYaml).ToDictionary(); if (nodesDict.ContainsKey("ShadowIndex")) { Array.Resize(ref shadowIndex, shadowIndex.Length + 1); diff --git a/OpenRA.Game/Graphics/SequenceProvider.cs b/OpenRA.Game/Graphics/SequenceProvider.cs index 5125fc12da..ce8ebd460e 100644 --- a/OpenRA.Game/Graphics/SequenceProvider.cs +++ b/OpenRA.Game/Graphics/SequenceProvider.cs @@ -123,7 +123,10 @@ namespace OpenRA.Graphics Sequences Load(List sequenceNodes) { - var nodes = MiniYaml.Merge(modData.Manifest.Sequences.Select(MiniYaml.FromFile).Append(sequenceNodes)); + var nodes = MiniYaml.Merge(modData.Manifest.Sequences + .Select(s => MiniYaml.FromStream(modData.ModFiles.Open(s))) + .Append(sequenceNodes)); + var items = new Dictionary(); foreach (var n in nodes) { diff --git a/OpenRA.Game/Graphics/VoxelProvider.cs b/OpenRA.Game/Graphics/VoxelProvider.cs index 3a3b068776..87e8131c55 100644 --- a/OpenRA.Game/Graphics/VoxelProvider.cs +++ b/OpenRA.Game/Graphics/VoxelProvider.cs @@ -19,11 +19,13 @@ namespace OpenRA.Graphics { static Dictionary> units; - public static void Initialize(string[] voxelFiles, List voxelNodes) + public static void Initialize(ModData modData, string[] voxelFiles, List voxelNodes) { units = new Dictionary>(); - var sequences = MiniYaml.Merge(voxelFiles.Select(MiniYaml.FromFile)); + var sequences = MiniYaml.Merge(voxelFiles.Select( + s => MiniYaml.FromStream(modData.ModFiles.Open(s)))); + foreach (var s in sequences) LoadVoxelsForUnit(s.Key, s.Value); diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index 4d0a47bd90..67e0ca3927 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -193,7 +193,7 @@ namespace OpenRA public TileSet(ModData modData, string filepath) { - var yaml = MiniYaml.DictFromFile(filepath); + var yaml = MiniYaml.DictFromStream(modData.ModFiles.Open(filepath)); // General info FieldLoader.Load(this, yaml["General"]); diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 8e36fb8717..e6ad5fd73f 100644 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -92,8 +92,8 @@ namespace OpenRA { // all this manipulation of static crap here is nasty and breaks // horribly when you use ModData in unexpected ways. - ChromeMetrics.Initialize(Manifest.ChromeMetrics); - ChromeProvider.Initialize(Manifest.Chrome); + ChromeMetrics.Initialize(this); + ChromeProvider.Initialize(this); if (VoxelLoader != null) VoxelLoader.Dispose(); @@ -130,7 +130,9 @@ namespace OpenRA return; } - var yaml = MiniYaml.Merge(Manifest.Translations.Select(MiniYaml.FromFile).Append(map.TranslationDefinitions)); + var yaml = MiniYaml.Merge(Manifest.Translations + .Select(t => MiniYaml.FromStream(ModFiles.Open(t))) + .Append(map.TranslationDefinitions)); Languages = yaml.Select(t => t.Key).ToArray(); foreach (var y in yaml) @@ -185,7 +187,7 @@ namespace OpenRA foreach (var entry in map.Rules.Music) entry.Value.Load(); - VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequenceDefinitions); + VoxelProvider.Initialize(this, Manifest.VoxelSequences, map.VoxelSequenceDefinitions); VoxelLoader.Finish(); return map; diff --git a/OpenRA.Game/Widgets/ChromeMetrics.cs b/OpenRA.Game/Widgets/ChromeMetrics.cs index 34e3e5ad38..acfb8da59d 100644 --- a/OpenRA.Game/Widgets/ChromeMetrics.cs +++ b/OpenRA.Game/Widgets/ChromeMetrics.cs @@ -17,11 +17,11 @@ namespace OpenRA.Widgets { static Dictionary data = new Dictionary(); - public static void Initialize(IEnumerable yaml) + public static void Initialize(ModData modData) { data = new Dictionary(); - - var metrics = MiniYaml.Merge(yaml.Select(MiniYaml.FromFile)); + var metrics = MiniYaml.Merge(modData.Manifest.ChromeMetrics.Select( + y => MiniYaml.FromStream(modData.ModFiles.Open(y)))); foreach (var m in metrics) foreach (var n in m.Value.Nodes) data[n.Key] = n.Value.Value; diff --git a/OpenRA.Game/Widgets/RootWidget.cs b/OpenRA.Game/Widgets/RootWidget.cs index c6cabcbd68..47860c5455 100644 --- a/OpenRA.Game/Widgets/RootWidget.cs +++ b/OpenRA.Game/Widgets/RootWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Widgets if (hk == Game.Settings.Keys.DevReloadChromeKey) { - ChromeProvider.Initialize(Game.ModData.Manifest.Chrome); + ChromeProvider.Initialize(Game.ModData); return true; } diff --git a/OpenRA.Game/Widgets/WidgetLoader.cs b/OpenRA.Game/Widgets/WidgetLoader.cs index 6c79da7ed9..6a9e7db967 100644 --- a/OpenRA.Game/Widgets/WidgetLoader.cs +++ b/OpenRA.Game/Widgets/WidgetLoader.cs @@ -24,7 +24,7 @@ namespace OpenRA { this.modData = modData; - foreach (var file in modData.Manifest.ChromeLayout.Select(a => MiniYaml.FromFile(a))) + foreach (var file in modData.Manifest.ChromeLayout.Select(a => MiniYaml.FromStream(modData.ModFiles.Open(a)))) foreach (var w in file) { var key = w.Key.Substring(w.Key.IndexOf('@') + 1); diff --git a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs index 2cb94c94ef..b87ce9c3d7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs @@ -95,7 +95,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Add a group for each campaign if (modData.Manifest.Missions.Any()) { - var yaml = MiniYaml.Merge(modData.Manifest.Missions.Select(MiniYaml.FromFile)); + var yaml = MiniYaml.Merge(modData.Manifest.Missions.Select( + m => MiniYaml.FromStream(modData.ModFiles.Open(m)))); + foreach (var kv in yaml) { var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();