From a383f8873c9381c0f1fb01da37f68bdf0f32c49e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Jul 2010 19:10:34 +1200 Subject: [PATCH] SupportDir supports absolute or relative paths; default to ~/OpenRA --- OpenRA.Game/Game.cs | 10 +++++----- OpenRA.Game/GameRules/UserSettings.cs | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index f978267b66..2d8a505dd4 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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; } } diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index 91afb0e088..d763276f84 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -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;