Restore key:value syntax for MapFolders.

This commit is contained in:
Paul Chote
2016-02-06 19:17:05 +00:00
parent a229e4253f
commit b50b2f31b5
5 changed files with 11 additions and 28 deletions

View File

@@ -70,7 +70,7 @@ namespace OpenRA
Mod.Id = modId;
// TODO: Use fieldloader
MapFolders = YamlDictionary(yaml, "MapFolders", true);
MapFolders = YamlDictionary(yaml, "MapFolders");
MiniYaml packages;
if (yaml.TryGetValue("Packages", out packages))
@@ -160,29 +160,12 @@ namespace OpenRA
return yaml[key].ToDictionary().Keys.ToArray();
}
static IReadOnlyDictionary<string, string> YamlDictionary(Dictionary<string, MiniYaml> yaml, string key, bool parsePaths = false)
static IReadOnlyDictionary<string, string> YamlDictionary(Dictionary<string, MiniYaml> yaml, string key)
{
if (!yaml.ContainsKey(key))
return new ReadOnlyDictionary<string, string>();
var inner = new Dictionary<string, string>();
foreach (var node in yaml[key].Nodes)
{
var line = node.Key;
if (node.Value.Value != null)
line += ":" + node.Value.Value;
// '@' may be used in mod.yaml to indicate extra information (similar to trait @ tags).
// Applies to MapFolders (to indicate System and User directories) and Packages (to indicate package annotation).
if (line.Contains('@'))
{
var split = line.Split('@');
inner.Add(parsePaths ? Platform.ResolvePath(split[0]) : split[0], split[1]);
}
else
inner.Add(line, null);
}
var inner = yaml[key].ToDictionary(my => my.Value);
return new ReadOnlyDictionary<string, string>(inner);
}

View File

@@ -33,8 +33,8 @@ Packages:
cnc|uibits
MapFolders:
./mods/cnc/maps@System
~^maps/cnc/{DEV_VERSION}@User
cnc|maps: System
~^maps/cnc/{DEV_VERSION}: User
Rules:
cnc|rules/misc.yaml

View File

@@ -25,8 +25,8 @@ Packages:
d2k|uibits
MapFolders:
./mods/d2k/maps@System
~^maps/d2k/{DEV_VERSION}@User
d2k|maps: System
~^maps/d2k/{DEV_VERSION}: User
Rules:
d2k|rules/misc.yaml

View File

@@ -33,8 +33,8 @@ Packages:
ra|uibits
MapFolders:
./mods/ra/maps@System
~^maps/ra/{DEV_VERSION}@User
ra|maps: System
~^maps/ra/{DEV_VERSION}: User
Rules:
ra|rules/misc.yaml

View File

@@ -59,8 +59,8 @@ Packages:
ts|uibits
MapFolders:
./mods/ts/maps@System
~^maps/ts/{DEV_VERSION}@User
ts|maps: System
~^maps/ts/{DEV_VERSION}: User
Rules:
ts|rules/ai.yaml