Changed MiniYaml.NodesDict property into a method.

Method is now called ToDictionary.
- Cached a few invocations into locals which should prevent some redundant evaluation.
- Added ToDictionary overloads that take projection functions for the keys and elements, since several callsites were doing a subsequent Linq.ToDictionary call to get this.
This commit is contained in:
RoosterDragon
2014-05-21 05:14:16 +01:00
parent 334a210231
commit 2e992a7310
21 changed files with 104 additions and 74 deletions

View File

@@ -31,20 +31,20 @@ namespace OpenRA.Graphics
var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
var shadowIndex = new int[] { };
if (sequences.NodesDict.ContainsKey("ShadowIndex"))
var nodesDict = sequences.ToDictionary();
if (nodesDict.ContainsKey("ShadowIndex"))
{
Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
Exts.TryParseIntegerInvariant(sequences.NodesDict["ShadowIndex"].Value,
Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
out shadowIndex[shadowIndex.Length - 1]);
}
palette = new HardwarePalette();
foreach (var p in sequences.NodesDict["Palettes"].Nodes)
foreach (var p in nodesDict["Palettes"].Nodes)
palette.AddPalette(p.Key, new Palette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);
var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));
foreach (var s in sequences.NodesDict["Cursors"].Nodes)
foreach (var s in nodesDict["Cursors"].Nodes)
LoadSequencesForCursor(spriteLoader, s.Key, s.Value);
palette.Initialize();