Load assets using absolute paths. Fixes #6717.
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user