Rename MiniYaml MergeLiberal -> MergePartial, MergeStrict -> Merge.
This commit is contained in:
committed by
Oliver Brakmann
parent
abed25d293
commit
a074bb1d4b
@@ -98,7 +98,7 @@ namespace OpenRA
|
||||
throw new YamlException(
|
||||
"Bogus inheritance -- duplicate inheritance of {0}.".F(kv.Key));
|
||||
|
||||
node = MiniYaml.MergeStrict(node, MergeWithParents(kv.Value, allUnits, allParents));
|
||||
node = MiniYaml.Merge(node, MergeWithParents(kv.Value, allUnits, allParents));
|
||||
}
|
||||
|
||||
return node;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA
|
||||
|
||||
var mergedNodes = files
|
||||
.Select(s => MiniYaml.FromFile(s))
|
||||
.Aggregate(nodes, MiniYaml.MergeLiberal);
|
||||
.Aggregate(nodes, MiniYaml.MergePartial);
|
||||
|
||||
Func<MiniYamlNode, Dictionary<string, MiniYaml>, T> wrap = (wkv, wyy) =>
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
|
||||
cachedSheets = new Dictionary<string, Sheet>();
|
||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
||||
|
||||
var chrome = chromeFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal);
|
||||
var chrome = chromeFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
foreach (var c in chrome)
|
||||
LoadCollection(c.Key, c.Value);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
|
||||
public CursorProvider(ModData modData)
|
||||
{
|
||||
var sequenceFiles = modData.Manifest.Cursors;
|
||||
var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
|
||||
var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergePartial));
|
||||
var shadowIndex = new int[] { };
|
||||
|
||||
var nodesDict = sequences.ToDictionary();
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
var nodes = sequenceFiles
|
||||
.Select(s => MiniYaml.FromFile(s))
|
||||
.Aggregate(sequenceNodes, MiniYaml.MergeLiberal);
|
||||
.Aggregate(sequenceNodes, MiniYaml.MergePartial);
|
||||
|
||||
var items = new Dictionary<string, UnitSequences>();
|
||||
foreach (var n in nodes)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
var sequences = voxelFiles
|
||||
.Select(s => MiniYaml.FromFile(s))
|
||||
.Aggregate(voxelNodes, MiniYaml.MergeLiberal);
|
||||
.Aggregate(voxelNodes, MiniYaml.MergePartial);
|
||||
|
||||
foreach (var s in sequences)
|
||||
LoadVoxelsForUnit(s.Key, s.Value);
|
||||
|
||||
@@ -262,12 +262,12 @@ namespace OpenRA
|
||||
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), fileName);
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> MergeStrict(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
public static List<MiniYamlNode> Merge(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> MergeLiberal(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
public static List<MiniYamlNode> MergePartial(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
@@ -327,12 +327,12 @@ namespace OpenRA
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b)
|
||||
public static MiniYaml MergePartial(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
|
||||
public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b)
|
||||
public static MiniYaml Merge(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
|
||||
@@ -119,10 +119,10 @@ namespace OpenRA
|
||||
return;
|
||||
}
|
||||
|
||||
var yaml = Manifest.Translations.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);
|
||||
var yaml = Manifest.Translations.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial);
|
||||
Languages = yaml.Select(t => t.Key).ToArray();
|
||||
|
||||
yaml = MiniYaml.MergeLiberal(map.TranslationDefinitions, yaml);
|
||||
yaml = MiniYaml.MergePartial(map.TranslationDefinitions, yaml);
|
||||
|
||||
foreach (var y in yaml)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
data = new Dictionary<string, string>();
|
||||
var metrics = yaml.Select(y => MiniYaml.FromFile(y))
|
||||
.Aggregate(MiniYaml.MergeLiberal);
|
||||
.Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
foreach (var m in metrics)
|
||||
foreach (var n in m.Value.Nodes)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
if (nodes.TryGetValue("Defaults", out defaults))
|
||||
{
|
||||
nodes.Remove("Defaults");
|
||||
nodes = nodes.ToDictionary(kv => kv.Key, kv => MiniYaml.MergeStrict(kv.Value, defaults));
|
||||
nodes = nodes.ToDictionary(kv => kv.Key, kv => MiniYaml.Merge(kv.Value, defaults));
|
||||
|
||||
// Merge 'Defaults' animation image value. An example follows.
|
||||
//
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace OpenRA.Mods.Common.Lint
|
||||
this.emitError = emitError;
|
||||
|
||||
var sequenceSource = map != null ? map.SequenceDefinitions : new List<MiniYamlNode>();
|
||||
sequenceDefinitions = MiniYaml.MergeLiberal(sequenceSource,
|
||||
Game.ModData.Manifest.Sequences.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal));
|
||||
sequenceDefinitions = MiniYaml.MergePartial(sequenceSource,
|
||||
Game.ModData.Manifest.Sequences.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial));
|
||||
|
||||
var rules = map == null ? Game.ModData.DefaultRules : map.Rules;
|
||||
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
var nodes = sequenceFiles
|
||||
.Select(s => MiniYaml.FromFile(s))
|
||||
.Aggregate(MiniYaml.MergeLiberal);
|
||||
.Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
foreach (var n in nodes)
|
||||
Game.ModData.SpriteSequenceLoader.ParseSequences(Game.ModData, ts, sc, n);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// Add a group for each campaign
|
||||
if (Game.ModData.Manifest.Missions.Any())
|
||||
{
|
||||
var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);
|
||||
var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
foreach (var kv in yaml)
|
||||
{
|
||||
|
||||
@@ -73,9 +73,9 @@ Root2:
|
||||
|
||||
// Merge order should not matter
|
||||
// Note: All the Merge* variants are different plumbing over the same
|
||||
// internal logic. Testing only MergeStrict is sufficient.
|
||||
TestMixedMerge(MiniYaml.MergeStrict(a, b).First().Value);
|
||||
TestMixedMerge(MiniYaml.MergeStrict(b, a).First().Value);
|
||||
// Internal logic. Testing only Merge is sufficient.
|
||||
TestMixedMerge(MiniYaml.Merge(a, b).First().Value);
|
||||
TestMixedMerge(MiniYaml.Merge(b, a).First().Value);
|
||||
}
|
||||
|
||||
void TestMixedMerge(MiniYaml result)
|
||||
|
||||
Reference in New Issue
Block a user