Load mod yaml via the virtual filesystem.
This commit is contained in:
@@ -112,7 +112,7 @@ namespace OpenRA
|
|||||||
return t;
|
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);
|
.ToDictionaryWithConflictLog(n => n.Key, n => n.Value, "LoadYamlRules", null, null);
|
||||||
RaiseProgress();
|
RaiseProgress();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
|
|||||||
static Dictionary<string, Sheet> cachedSheets;
|
static Dictionary<string, Sheet> cachedSheets;
|
||||||
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
|
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
|
||||||
|
|
||||||
public static void Initialize(IEnumerable<string> chromeFiles)
|
public static void Initialize(ModData modData)
|
||||||
{
|
{
|
||||||
Deinitialize();
|
Deinitialize();
|
||||||
|
|
||||||
@@ -33,7 +33,9 @@ namespace OpenRA.Graphics
|
|||||||
cachedSheets = new Dictionary<string, Sheet>();
|
cachedSheets = new Dictionary<string, Sheet>();
|
||||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
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)
|
foreach (var c in chrome)
|
||||||
LoadCollection(c.Key, c.Value);
|
LoadCollection(c.Key, c.Value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public CursorProvider(ModData modData)
|
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 shadowIndex = new int[] { };
|
||||||
|
|
||||||
var nodesDict = sequences.ToDictionary();
|
var nodesDict = new MiniYaml(null, sequenceYaml).ToDictionary();
|
||||||
if (nodesDict.ContainsKey("ShadowIndex"))
|
if (nodesDict.ContainsKey("ShadowIndex"))
|
||||||
{
|
{
|
||||||
Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
|
Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
Sequences Load(List<MiniYamlNode> sequenceNodes)
|
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>();
|
var items = new Dictionary<string, UnitSequences>();
|
||||||
foreach (var n in nodes)
|
foreach (var n in nodes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,11 +19,13 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
static Dictionary<string, Dictionary<string, Voxel>> units;
|
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>>();
|
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)
|
foreach (var s in sequences)
|
||||||
LoadVoxelsForUnit(s.Key, s.Value);
|
LoadVoxelsForUnit(s.Key, s.Value);
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public TileSet(ModData modData, string filepath)
|
public TileSet(ModData modData, string filepath)
|
||||||
{
|
{
|
||||||
var yaml = MiniYaml.DictFromFile(filepath);
|
var yaml = MiniYaml.DictFromStream(modData.ModFiles.Open(filepath));
|
||||||
|
|
||||||
// General info
|
// General info
|
||||||
FieldLoader.Load(this, yaml["General"]);
|
FieldLoader.Load(this, yaml["General"]);
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
// all this manipulation of static crap here is nasty and breaks
|
// all this manipulation of static crap here is nasty and breaks
|
||||||
// horribly when you use ModData in unexpected ways.
|
// horribly when you use ModData in unexpected ways.
|
||||||
ChromeMetrics.Initialize(Manifest.ChromeMetrics);
|
ChromeMetrics.Initialize(this);
|
||||||
ChromeProvider.Initialize(Manifest.Chrome);
|
ChromeProvider.Initialize(this);
|
||||||
|
|
||||||
if (VoxelLoader != null)
|
if (VoxelLoader != null)
|
||||||
VoxelLoader.Dispose();
|
VoxelLoader.Dispose();
|
||||||
@@ -130,7 +130,9 @@ namespace OpenRA
|
|||||||
return;
|
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();
|
Languages = yaml.Select(t => t.Key).ToArray();
|
||||||
|
|
||||||
foreach (var y in yaml)
|
foreach (var y in yaml)
|
||||||
@@ -185,7 +187,7 @@ namespace OpenRA
|
|||||||
foreach (var entry in map.Rules.Music)
|
foreach (var entry in map.Rules.Music)
|
||||||
entry.Value.Load();
|
entry.Value.Load();
|
||||||
|
|
||||||
VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequenceDefinitions);
|
VoxelProvider.Initialize(this, Manifest.VoxelSequences, map.VoxelSequenceDefinitions);
|
||||||
VoxelLoader.Finish();
|
VoxelLoader.Finish();
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
static Dictionary<string, string> data = new Dictionary<string, string>();
|
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>();
|
data = new Dictionary<string, string>();
|
||||||
|
var metrics = MiniYaml.Merge(modData.Manifest.ChromeMetrics.Select(
|
||||||
var metrics = MiniYaml.Merge(yaml.Select(MiniYaml.FromFile));
|
y => MiniYaml.FromStream(modData.ModFiles.Open(y))));
|
||||||
foreach (var m in metrics)
|
foreach (var m in metrics)
|
||||||
foreach (var n in m.Value.Nodes)
|
foreach (var n in m.Value.Nodes)
|
||||||
data[n.Key] = n.Value.Value;
|
data[n.Key] = n.Value.Value;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (hk == Game.Settings.Keys.DevReloadChromeKey)
|
if (hk == Game.Settings.Keys.DevReloadChromeKey)
|
||||||
{
|
{
|
||||||
ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
|
ChromeProvider.Initialize(Game.ModData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
this.modData = modData;
|
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)
|
foreach (var w in file)
|
||||||
{
|
{
|
||||||
var key = w.Key.Substring(w.Key.IndexOf('@') + 1);
|
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
|
// Add a group for each campaign
|
||||||
if (modData.Manifest.Missions.Any())
|
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)
|
foreach (var kv in yaml)
|
||||||
{
|
{
|
||||||
var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();
|
var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();
|
||||||
|
|||||||
Reference in New Issue
Block a user