Load mod yaml via the virtual filesystem.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
|
||||
static Dictionary<string, Sheet> cachedSheets;
|
||||
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
|
||||
|
||||
public static void Initialize(IEnumerable<string> chromeFiles)
|
||||
public static void Initialize(ModData modData)
|
||||
{
|
||||
Deinitialize();
|
||||
|
||||
@@ -33,7 +33,9 @@ namespace OpenRA.Graphics
|
||||
cachedSheets = new Dictionary<string, Sheet>();
|
||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -123,7 +123,10 @@ namespace OpenRA.Graphics
|
||||
|
||||
Sequences Load(List<MiniYamlNode> 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<string, UnitSequences>();
|
||||
foreach (var n in nodes)
|
||||
{
|
||||
|
||||
@@ -19,11 +19,13 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
static Dictionary<string, Dictionary<string, Voxel>> units;
|
||||
|
||||
public static void Initialize(string[] voxelFiles, List<MiniYamlNode> voxelNodes)
|
||||
public static void Initialize(ModData modData, string[] voxelFiles, List<MiniYamlNode> voxelNodes)
|
||||
{
|
||||
units = new Dictionary<string, Dictionary<string, Voxel>>();
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -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"]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
static Dictionary<string, string> data = new Dictionary<string, string>();
|
||||
|
||||
public static void Initialize(IEnumerable<string> yaml)
|
||||
public static void Initialize(ModData modData)
|
||||
{
|
||||
data = new Dictionary<string, string>();
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user