Implement new syntax for mod-specific filesystem requests.
This commit is contained in:
@@ -81,10 +81,16 @@ namespace OpenRA.FileSystem
|
||||
if (optional)
|
||||
name = name.Substring(1);
|
||||
|
||||
Action a = () => Mount(OpenPackage(name), explicitName);
|
||||
var modPackage = name.StartsWith("$");
|
||||
if (modPackage)
|
||||
name = name.Substring(1);
|
||||
|
||||
Action a = () => Mount(modPackage ? ModMetadata.AllMods[name].Package : OpenPackage(name), explicitName);
|
||||
if (optional)
|
||||
{
|
||||
try { a(); }
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
a();
|
||||
}
|
||||
|
||||
@@ -74,23 +74,23 @@ namespace OpenRA
|
||||
|
||||
MiniYaml packages;
|
||||
if (yaml.TryGetValue("Packages", out packages))
|
||||
Packages = packages.ToDictionary(x => Platform.ResolvePath(x), x => x.Value).AsReadOnly();
|
||||
Packages = packages.ToDictionary(x => x.Value).AsReadOnly();
|
||||
|
||||
Rules = YamlList(yaml, "Rules", true);
|
||||
Sequences = YamlList(yaml, "Sequences", true);
|
||||
VoxelSequences = YamlList(yaml, "VoxelSequences", true);
|
||||
Cursors = YamlList(yaml, "Cursors", true);
|
||||
Chrome = YamlList(yaml, "Chrome", true);
|
||||
Assemblies = YamlList(yaml, "Assemblies", true);
|
||||
ChromeLayout = YamlList(yaml, "ChromeLayout", true);
|
||||
Weapons = YamlList(yaml, "Weapons", true);
|
||||
Voices = YamlList(yaml, "Voices", true);
|
||||
Notifications = YamlList(yaml, "Notifications", true);
|
||||
Music = YamlList(yaml, "Music", true);
|
||||
Translations = YamlList(yaml, "Translations", true);
|
||||
TileSets = YamlList(yaml, "TileSets", true);
|
||||
ChromeMetrics = YamlList(yaml, "ChromeMetrics", true);
|
||||
Missions = YamlList(yaml, "Missions", true);
|
||||
Rules = YamlList(yaml, "Rules");
|
||||
Sequences = YamlList(yaml, "Sequences");
|
||||
VoxelSequences = YamlList(yaml, "VoxelSequences");
|
||||
Cursors = YamlList(yaml, "Cursors");
|
||||
Chrome = YamlList(yaml, "Chrome");
|
||||
Assemblies = YamlList(yaml, "Assemblies");
|
||||
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
||||
Weapons = YamlList(yaml, "Weapons");
|
||||
Voices = YamlList(yaml, "Voices");
|
||||
Notifications = YamlList(yaml, "Notifications");
|
||||
Music = YamlList(yaml, "Music");
|
||||
Translations = YamlList(yaml, "Translations");
|
||||
TileSets = YamlList(yaml, "TileSets");
|
||||
ChromeMetrics = YamlList(yaml, "ChromeMetrics");
|
||||
Missions = YamlList(yaml, "Missions");
|
||||
|
||||
ServerTraits = YamlList(yaml, "ServerTraits");
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace OpenRA
|
||||
throw new InvalidDataException("`LobbyDefaults` section is not defined.");
|
||||
|
||||
Fonts = yaml["Fonts"].ToDictionary(my =>
|
||||
{
|
||||
var nd = my.ToDictionary();
|
||||
return Pair.New(nd["Font"].Value, Exts.ParseIntegerInvariant(nd["Size"].Value));
|
||||
});
|
||||
{
|
||||
var nd = my.ToDictionary();
|
||||
return Pair.New(nd["Font"].Value, Exts.ParseIntegerInvariant(nd["Size"].Value));
|
||||
});
|
||||
|
||||
RequiresMods = yaml["RequiresMods"].ToDictionary(my => my.Value);
|
||||
|
||||
@@ -157,9 +157,6 @@ namespace OpenRA
|
||||
if (!yaml.ContainsKey(key))
|
||||
return new string[] { };
|
||||
|
||||
if (parsePaths)
|
||||
return yaml[key].Nodes.Select(node => Platform.ResolvePath(node.Key, node.Value.Value ?? string.Empty)).ToArray();
|
||||
|
||||
return yaml[key].ToDictionary().Keys.ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,14 +100,6 @@ namespace OpenRA
|
||||
{
|
||||
path = path.TrimEnd(new char[] { ' ', '\t' });
|
||||
|
||||
// If the path contains ':', chances are it is a package path.
|
||||
// If it isn't, someone passed an already resolved path, which is wrong.
|
||||
if (path.IndexOf(":", StringComparison.Ordinal) > 1)
|
||||
{
|
||||
var split = path.Split(':');
|
||||
return ResolvePath(split[0], split[1]);
|
||||
}
|
||||
|
||||
// paths starting with ^ are relative to the support dir
|
||||
if (path.StartsWith("^"))
|
||||
path = SupportDir + path.Substring(1);
|
||||
@@ -119,16 +111,6 @@ namespace OpenRA
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>Replaces package names with full paths. Avoid using this for non-package paths.</summary>
|
||||
public static string ResolvePath(string package, string target)
|
||||
{
|
||||
// Resolve mod package paths.
|
||||
if (ModMetadata.AllMods.ContainsKey(package))
|
||||
package = ModMetadata.AllMods[package].Package.Name;
|
||||
|
||||
return ResolvePath(Path.Combine(package, target));
|
||||
}
|
||||
|
||||
/// <summary>Replace special character prefixes with full paths.</summary>
|
||||
public static string ResolvePath(params string[] path)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user