File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 1616// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717
1818using System ;
19+ using System . IO ;
1920using System . Collections . Generic ;
2021using System . Diagnostics ;
2122using System . Linq ;
@@ -27,6 +28,20 @@ namespace ORTS.Common
2728 /// </summary>
2829 public abstract class SettingsBase
2930 {
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"
33+
34+ static SettingsBase ( )
35+ {
36+ // 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" ) ;
39+ if ( File . Exists ( SettingsFilePath ) )
40+ RegistryKey = null ;
41+ else
42+ SettingsFilePath = null ;
43+ }
44+
3045 /// <summary>
3146 /// Enumeration of the various sources for settings
3247 /// </summary>
@@ -42,6 +57,7 @@ protected enum Source
4257
4358 /// <summary>The store of the settings</summary>
4459 protected SettingsStore SettingStore { get ; private set ; }
60+
4561 /// <summary>Translates name of a setting to its source</summary>
4662 protected readonly Dictionary < string , Source > Sources = new Dictionary < string , Source > ( ) ;
4763
Original file line number Diff line number Diff line change @@ -43,22 +43,12 @@ public sealed class DoNotSaveAttribute : Attribute
4343
4444 public class UserSettings : SettingsBase
4545 {
46- public static readonly string RegistryKey ; // ie @"SOFTWARE\OpenRails\ORTS"
47- public static readonly string SettingsFilePath ; // ie @"C:\Program Files\Open Rails\OpenRails.ini"
4846 public static readonly string UserDataFolder ; // ie @"C:\Users\Wayne\AppData\Roaming\Open Rails"
4947 public static readonly string DeletedSaveFolder ; // ie @"C:\Users\Wayne\AppData\Roaming\Open Rails\Deleted Saves"
5048 public static readonly string SavePackFolder ; // ie @"C:\Users\Wayne\AppData\Roaming\Open Rails\Save Packs"
5149
5250 static UserSettings ( )
5351 {
54- // Only one of these is allowed; if the INI file exists, we use that, otherwise we use the registry.
55- RegistryKey = "SOFTWARE\\ OpenRails\\ ORTS" ;
56- SettingsFilePath = Path . Combine ( ApplicationInfo . ProcessDirectory , "OpenRails.ini" ) ;
57- if ( File . Exists ( SettingsFilePath ) )
58- RegistryKey = null ;
59- else
60- SettingsFilePath = null ;
61-
6252 UserDataFolder = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , ApplicationInfo . ProductName ) ;
6353 // TODO: If using INI file, move these to application directory as well.
6454 if ( ! Directory . Exists ( UserDataFolder ) ) Directory . CreateDirectory ( UserDataFolder ) ;
You can’t perform that action at this time.
0 commit comments