Rewrite yaml merger.
This commit is contained in:
@@ -36,19 +36,11 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
if (nodes.TryGetValue("Defaults", out defaults))
|
||||
{
|
||||
nodes.Remove("Defaults");
|
||||
nodes = nodes.ToDictionary(kv => kv.Key, kv => MiniYaml.Merge(kv.Value, defaults));
|
||||
|
||||
// Merge 'Defaults' animation image value. An example follows.
|
||||
//
|
||||
// - Before -
|
||||
// stand:
|
||||
// Facings: 8
|
||||
//
|
||||
// - After -
|
||||
// stand: e1
|
||||
// Facings: 8
|
||||
foreach (var n in nodes)
|
||||
{
|
||||
n.Value.Nodes = MiniYaml.Merge(new[] { defaults.Nodes, n.Value.Nodes });
|
||||
n.Value.Value = n.Value.Value ?? defaults.Value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kvp in nodes)
|
||||
|
||||
@@ -31,10 +31,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
this.emitError = emitError;
|
||||
|
||||
var sequenceSource = map != null ? map.SequenceDefinitions : new List<MiniYamlNode>();
|
||||
var partial = Game.ModData.Manifest.Sequences
|
||||
.Select(MiniYaml.FromFile)
|
||||
.Aggregate(MiniYaml.MergePartial);
|
||||
sequenceDefinitions = MiniYaml.Merge(sequenceSource, partial);
|
||||
sequenceDefinitions = MiniYaml.Merge(Game.ModData.Manifest.Sequences.Select(MiniYaml.FromFile).Append(sequenceSource));
|
||||
|
||||
var rules = map == null ? Game.ModData.DefaultRules : map.Rules;
|
||||
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||
|
||||
@@ -36,13 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var ts = new TileSet(Game.ModData, t);
|
||||
Console.WriteLine("Tileset: " + ts.Name);
|
||||
var sc = new SpriteCache(modData.SpriteLoaders, new SheetBuilder(SheetType.Indexed));
|
||||
var sequenceFiles = modData.Manifest.Sequences;
|
||||
|
||||
var partial = sequenceFiles
|
||||
.Select(s => MiniYaml.FromFile(s))
|
||||
.Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
var nodes = MiniYaml.ApplyRemovals(partial);
|
||||
var nodes = MiniYaml.Merge(modData.Manifest.Sequences.Select(MiniYaml.FromFile));
|
||||
foreach (var n in nodes)
|
||||
Game.ModData.SpriteSequenceLoader.ParseSequences(Game.ModData, ts, sc, n);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
[ObjectCreator.UseCtor]
|
||||
public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit)
|
||||
{
|
||||
var modData = Game.ModData;
|
||||
this.onStart = onStart;
|
||||
|
||||
missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");
|
||||
@@ -92,18 +93,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
missionList.RemoveChildren();
|
||||
|
||||
// Add a group for each campaign
|
||||
if (Game.ModData.Manifest.Missions.Any())
|
||||
if (modData.Manifest.Missions.Any())
|
||||
{
|
||||
var partial = Game.ModData.Manifest.Missions
|
||||
.Select(MiniYaml.FromFile)
|
||||
.Aggregate(MiniYaml.MergePartial);
|
||||
|
||||
var yaml = MiniYaml.ApplyRemovals(partial);
|
||||
var yaml = MiniYaml.Merge(modData.Manifest.Missions.Select(MiniYaml.FromFile));
|
||||
foreach (var kv in yaml)
|
||||
{
|
||||
var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();
|
||||
|
||||
var maps = Game.ModData.MapCache
|
||||
var maps = modData.MapCache
|
||||
.Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
|
||||
.Select(p => p.Map)
|
||||
.OrderBy(m => missionMapPaths.IndexOf(Path.GetFullPath(m.Path)));
|
||||
@@ -114,7 +111,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
// Add an additional group for loose missions
|
||||
var looseMissions = Game.ModData.MapCache
|
||||
var looseMissions = modData.MapCache
|
||||
.Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map))
|
||||
.Select(p => p.Map);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user