Use an IReadOnlyDictionary for package definitions.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA
|
|||||||
Weapons, Voices, Notifications, Music, Movies, Translations, TileSets,
|
Weapons, Voices, Notifications, Music, Movies, Translations, TileSets,
|
||||||
ChromeMetrics, PackageContents, LuaScripts, MapCompatibility, Missions;
|
ChromeMetrics, PackageContents, LuaScripts, MapCompatibility, Missions;
|
||||||
|
|
||||||
public readonly Dictionary<string, string> Packages;
|
public readonly IReadOnlyDictionary<string, string> Packages;
|
||||||
public readonly MiniYaml LoadScreen;
|
public readonly MiniYaml LoadScreen;
|
||||||
public readonly MiniYaml LobbyDefaults;
|
public readonly MiniYaml LobbyDefaults;
|
||||||
public readonly Dictionary<string, Pair<string, int>> Fonts;
|
public readonly Dictionary<string, Pair<string, int>> Fonts;
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
|||||||
// TODO: Use fieldloader
|
// TODO: Use fieldloader
|
||||||
Folders = YamlList(yaml, "Folders");
|
Folders = YamlList(yaml, "Folders");
|
||||||
MapFolders = YamlList(yaml, "MapFolders");
|
MapFolders = YamlList(yaml, "MapFolders");
|
||||||
Packages = yaml["Packages"].NodesDict.ToDictionary(x => x.Key, x => x.Value.Value);
|
Packages = YamlDictionary(yaml, "Packages");
|
||||||
Rules = YamlList(yaml, "Rules");
|
Rules = YamlList(yaml, "Rules");
|
||||||
ServerTraits = YamlList(yaml, "ServerTraits");
|
ServerTraits = YamlList(yaml, "ServerTraits");
|
||||||
Sequences = YamlList(yaml, "Sequences");
|
Sequences = YamlList(yaml, "Sequences");
|
||||||
@@ -95,5 +95,14 @@ namespace OpenRA
|
|||||||
|
|
||||||
return yaml[key].NodesDict.Keys.ToArray();
|
return yaml[key].NodesDict.Keys.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static IReadOnlyDictionary<string, string> YamlDictionary(Dictionary<string, MiniYaml> yaml, string key)
|
||||||
|
{
|
||||||
|
if (!yaml.ContainsKey(key))
|
||||||
|
return new ReadOnlyDictionary<string, string>();
|
||||||
|
|
||||||
|
var inner = yaml[key].NodesDict.ToDictionary(x => x.Key, x => x.Value.Value);
|
||||||
|
return new ReadOnlyDictionary<string, string>(inner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,5 +47,4 @@ Fonts:
|
|||||||
TinyBold:
|
TinyBold:
|
||||||
Font:FreeSansBold.ttf
|
Font:FreeSansBold.ttf
|
||||||
Size:10
|
Size:10
|
||||||
Packages:
|
|
||||||
LobbyDefaults:
|
LobbyDefaults:
|
||||||
Reference in New Issue
Block a user