@@ -23,54 +23,41 @@ public static class Config
23
23
public static bool BoneBlockFix = true ;
24
24
public static bool GoldCritterDropTweak = true ;
25
25
26
- static int ConfigVersion ;
27
- const int LatestVersion = 1 ;
28
- static string ConfigFolderPath = Path . Combine ( Main . SavePath , "Mod Configs" , "Vanilla Tweaks" ) ;
29
- static string ConfigPath = Path . Combine ( ConfigFolderPath , "config.json" ) ;
30
- static string ConfigVersionPath = Path . Combine ( ConfigFolderPath , "config.version" ) ;
26
+ static string ConfigPath = Path . Combine ( Main . SavePath , "Mod Configs" , "Vanilla Tweaks.json" ) ;
27
+
28
+ static string OldConfigFolderPath = Path . Combine ( Main . SavePath , "Mod Configs" , "Vanilla Tweaks" ) ;
29
+ static string OldConfigPath = Path . Combine ( OldConfigFolderPath , "config.json" ) ;
30
+ static string OldConfigVersionPath = Path . Combine ( OldConfigFolderPath , "config.version" ) ;
31
31
32
32
static readonly Preferences Configuration = new Preferences ( ConfigPath ) ;
33
33
34
34
public static void Load ( )
35
35
{
36
- if ( File . Exists ( ConfigVersionPath ) )
37
- {
38
- try
39
- {
40
- int . TryParse ( File . ReadAllText ( ConfigVersionPath ) , out ConfigVersion ) ;
41
- }
42
- catch ( Exception e )
43
- {
44
- VanillaTweaks . Log ( "Unable to read config version!" ) ;
45
- VanillaTweaks . Log ( e . ToString ( ) ) ;
46
- ConfigVersion = 0 ;
47
- }
48
- }
49
- else
50
- {
51
- ConfigVersion = 0 ;
52
- }
53
-
54
- if ( ConfigVersion < LatestVersion )
55
- {
56
- VanillaTweaks . Log ( "Config is outdated! Current version: {0} Latest version: {1}" , ConfigVersion , LatestVersion ) ;
57
- }
58
- if ( ConfigVersion > LatestVersion )
59
- {
60
- VanillaTweaks . Log ( "Config is from the future?! Current version: {0} Latest version: {1}" , ConfigVersion , LatestVersion ) ;
61
- }
62
- // BossExpertise.Log("Reading config...");
36
+ if ( Directory . Exists ( OldConfigFolderPath ) )
37
+ {
38
+ if ( File . Exists ( OldConfigPath ) )
39
+ {
40
+ VanillaTweaks . Log ( "Found config file in old folder! Moving config..." ) ;
41
+ File . Move ( OldConfigPath , ConfigPath ) ;
42
+ }
43
+ if ( File . Exists ( OldConfigVersionPath ) )
44
+ {
45
+ File . Delete ( OldConfigVersionPath ) ;
46
+ }
47
+ if ( Directory . GetFiles ( OldConfigFolderPath ) . Length == 0 && Directory . GetDirectories ( OldConfigFolderPath ) . Length == 0 )
48
+ {
49
+ Directory . Delete ( OldConfigFolderPath ) ;
50
+ }
51
+ else
52
+ {
53
+ VanillaTweaks . Log ( "Old config folder still cotains some files/directories. They will not get deleted." ) ;
54
+ }
55
+ }
63
56
if ( ! ReadConfig ( ) )
64
57
{
65
58
VanillaTweaks . Log ( "Failed to read config file! Recreating config..." ) ;
66
59
SaveConfig ( ) ;
67
60
}
68
- else if ( ConfigVersion != LatestVersion )
69
- {
70
- VanillaTweaks . Log ( "Replacing config with newest version..." ) ;
71
- File . WriteAllText ( ConfigVersionPath , LatestVersion . ToString ( ) ) ;
72
- SaveConfig ( ) ;
73
- }
74
61
}
75
62
76
63
static bool ReadConfig ( )
0 commit comments