@@ -28,14 +28,34 @@ namespace ORTS.Common
2828 /// </summary>
2929 public abstract class SettingsBase
3030 {
31- public static string RegistryKey { get ; protected set ; } // ie @"SOFTWARE\OpenRails\ORTS"
32- public static string SettingsFilePath { get ; protected set ; } // ie @"C:\Program Files\Open Rails\OpenRails.ini"
31+ private const string DefaultRegistryKey = "SOFTWARE\\ OpenRails\\ ORTS" ;
32+ private const string DefaultSettingsFileName = "OpenRails.ini" ;
33+
34+ public static string RegistryKey { get ; private set ; } // ie @"SOFTWARE\OpenRails\ORTS"
35+ public static string SettingsFilePath { get ; private set ; } // ie @"C:\Program Files\Open Rails\OpenRails.ini"
3336
3437 static SettingsBase ( )
3538 {
3639 // Only one of these is allowed; if the INI file exists, we use that, otherwise we use the registry.
37- RegistryKey = "SOFTWARE\\ OpenRails\\ ORTS" ;
38- SettingsFilePath = Path . Combine ( ApplicationInfo . ProcessDirectory , "OpenRails.ini" ) ;
40+ RegistryKey = DefaultRegistryKey ;
41+ SettingsFilePath = Path . Combine ( ApplicationInfo . ProcessDirectory , DefaultSettingsFileName ) ;
42+ if ( File . Exists ( SettingsFilePath ) )
43+ RegistryKey = null ;
44+ else
45+ SettingsFilePath = null ;
46+ }
47+
48+ /// <summary>
49+ /// Override the location for the settings. This only changes the static names.
50+ /// If settings objects already exist, they need to be changed using ChangeSettingsStore().
51+ /// </summary>
52+ /// <param name="filePath">The new ini file path, relative to the OpenRails base directory.</param>
53+ /// <param name="registryKey">The new registry key, relative to the HKEY_CURRENT_USER. May be NULL.</param>
54+ static public void OverrideSettingsLocations ( string filePath , string registryKey )
55+ {
56+ // Only one of these is allowed; if the INI file exists, we use that, otherwise we use the registry.
57+ RegistryKey = registryKey ;
58+ SettingsFilePath = Path . Combine ( ApplicationInfo . ProcessDirectory , filePath ) ;
3959 if ( File . Exists ( SettingsFilePath ) )
4060 RegistryKey = null ;
4161 else
0 commit comments