Use an IReadOnlyDictionary for package definitions.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA
|
||||
Weapons, Voices, Notifications, Music, Movies, Translations, TileSets,
|
||||
ChromeMetrics, PackageContents, LuaScripts, MapCompatibility, Missions;
|
||||
|
||||
public readonly Dictionary<string, string> Packages;
|
||||
public readonly IReadOnlyDictionary<string, string> Packages;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly MiniYaml LobbyDefaults;
|
||||
public readonly Dictionary<string, Pair<string, int>> Fonts;
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
||||
// TODO: Use fieldloader
|
||||
Folders = YamlList(yaml, "Folders");
|
||||
MapFolders = YamlList(yaml, "MapFolders");
|
||||
Packages = yaml["Packages"].NodesDict.ToDictionary(x => x.Key, x => x.Value.Value);
|
||||
Packages = YamlDictionary(yaml, "Packages");
|
||||
Rules = YamlList(yaml, "Rules");
|
||||
ServerTraits = YamlList(yaml, "ServerTraits");
|
||||
Sequences = YamlList(yaml, "Sequences");
|
||||
@@ -95,5 +95,14 @@ namespace OpenRA
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user