Load assets using absolute paths. Fixes #6717.

This commit is contained in:
Paul Chote
2014-10-09 08:36:24 +13:00
parent 0d0b8c1e22
commit 4f44cc1969
35 changed files with 491 additions and 458 deletions

View File

@@ -93,6 +93,40 @@ namespace OpenRA
}
}
public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } }
/// <summary>Replace special character prefixes with full paths</summary>
public static string ResolvePath(string path)
{
// paths starting with ^ are relative to the support dir
if (path.StartsWith("^"))
path = SupportDir + path.Substring(1);
// paths starting with . are relative to the game dir
if (path.StartsWith("./") || path.StartsWith(".\\"))
path = GameDir + path.Substring(2);
return path;
}
/// <summary>Replace special character prefixes with full paths</summary>
public static string ResolvePath(params string[] path)
{
return ResolvePath(path.Aggregate(Path.Combine));
}
/// <summary>Replace the full path prefix with the special notation characters ^ or .</summary>
public static string UnresolvePath(string path)
{
if (path.StartsWith(SupportDir))
path = "^" + path.Substring(SupportDir.Length);
if (path.StartsWith(GameDir))
path = "." + path.Substring(GameDir.Length);
return path;
}
public static void ShowFatalErrorDialog()
{
var process = "OpenRA.CrashDialog.exe";