SupportDir supports absolute or relative paths; default to ~/OpenRA

This commit is contained in:
Paul Chote
2010-07-08 19:10:34 +12:00
parent 3508e71168
commit a383f8873c
2 changed files with 9 additions and 8 deletions

View File

@@ -647,12 +647,12 @@ namespace OpenRA
public static string SupportDir
{
get {
// Unless the user has specified otherwise, put support files in a subdirectory of the game install
if (Settings.SupportDir == null)
return Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Support" + Path.DirectorySeparatorChar;
var dir = Settings.SupportDir;
// Custom paths are relative to the home directory (My Documents under windows)
return Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + Settings.SupportDir + Path.DirectorySeparatorChar;
// Expand paths relative to the personal directory
if (dir.ElementAt(0) == '~')
dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dir.Substring(1);
return dir + Path.DirectorySeparatorChar;
}
}

View File

@@ -19,13 +19,14 @@
#endregion
using OpenRA.FileFormats.Graphics;
using System;
using System.IO;
namespace OpenRA.GameRules
{
public class UserSettings
{
public readonly string SupportDir = null;
public readonly string SupportDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ Path.DirectorySeparatorChar + "OpenRA" + Path.DirectorySeparatorChar;
// Debug settings
public bool UnitDebug = false;
public bool PathDebug = true;