1- using Microsoft . Win32 ;
1+ using Microsoft . VisualBasic . Devices ;
2+ using Microsoft . Win32 ;
23using Newtonsoft . Json ;
34using System ;
45using System . Collections . Generic ;
@@ -20,118 +21,134 @@ public static class ConfigManager
2021
2122 public static void loadGlobalConfig ( )
2223 {
24+ Utils . log ( "Load global START" , "ConfigManager" ) ;
2325 globalConfig = new GlobalConfig ( ) ;
2426 if ( File . Exists ( globalPath ) )
2527 {
28+ Utils . log ( "Global config exists" , "ConfigManager" ) ;
2629 string json = System . IO . File . ReadAllText ( globalPath ) ;
2730 globalConfig = Newtonsoft . Json . JsonConvert . DeserializeObject < GlobalConfig > ( json ) ;
2831
2932 if ( globalConfig . lg == "English" )
3033 {
34+ Utils . log ( "Global config update to EN" , "ConfigManager" ) ;
3135 globalConfig . lg = "EN" ;
3236 updateGlobalConfig ( ) ;
3337 }
34-
35- return ;
3638 }
3739 else
3840 {
3941 updateGlobalConfig ( ) ;
4042 }
43+ Utils . log ( "Load global END" , "ConfigManager" ) ;
4144 }
4245
4346 public static void load ( )
4447 {
48+ Utils . log ( "Load config START" , "ConfigManager" ) ;
4549 if ( ! ModManager . silent )
4650 ModManagerUI . StatusLabel . Text = "Loading Local Config..." ;
4751 config = new Config ( ) ;
48- Utils . log ( "[ConfigManager] Starting config detection" ) ;
4952 if ( File . Exists ( path ) )
5053 {
51- Utils . log ( "[ConfigManager] Config detected " ) ;
54+ Utils . log ( "Config exists" , "ConfigManager ") ;
5255 string json = System . IO . File . ReadAllText ( path ) ;
5356 config = Newtonsoft . Json . JsonConvert . DeserializeObject < Config > ( json ) ;
5457 if ( ServerConfig . get ( "gameVersion" ) . value != config . currentGameVersion )
5558 {
59+ Utils . log ( "New vanilla version" , "ConfigManager" ) ;
5660 duplicateVanillaAmongUs ( ) ;
5761 }
58- return ;
5962 } else
6063 {
61- Utils . log ( "[ConfigManager] Config not detected " ) ;
64+ Utils . log ( "Config does not exist" , "ConfigManager ") ;
6265 // Config doesn't exist
6366 duplicateVanillaAmongUs ( ) ;
6467 }
68+ Utils . log ( "Load config END" , "ConfigManager" ) ;
6569 }
6670
6771 public static void duplicateVanillaAmongUs ( )
6872 {
69- Utils . log ( "[ConfigManager] Creating new backup for vanilla Among Us " ) ;
73+ Utils . log ( "New backup for Vanilla START" , "ConfigManager ") ;
7074 string amongUsPath = null ;
7175
7276 // Search for Among Us path
7377
7478 // Detection from Steam
75- Utils . log ( "[ConfigManager] Starting detection from Steam " ) ;
79+ Utils . log ( "Steam detection START" , "ConfigManager ") ;
7680 RegistryKey myKey = Registry . LocalMachine . OpenSubKey ( @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 945360" , false ) ;
7781
7882 if ( myKey != null )
7983 {
84+ Utils . log ( "Steam detection YES" , "ConfigManager" ) ;
8085 amongUsPath = ( String ) myKey . GetValue ( "InstallLocation" ) ;
8186 if ( generateFolder ( amongUsPath ) )
8287 {
88+ Utils . log ( "Steam detection CONFIRM" , "ConfigManager" ) ;
8389 return ;
8490 }
8591 }
8692 else
8793 {
88-
94+ Utils . log ( "Steam detection NO" , "ConfigManager" ) ;
8995 }
96+ Utils . log ( "Steam detection END" , "ConfigManager" ) ;
9097
9198 // Detection from Epic Games Store
92- Utils . log ( "[ConfigManager] Starting detection from EGS " ) ;
99+ Utils . log ( "EGS detection START" , "ConfigManager ") ;
93100 foreach ( DriveInfo d in DriveInfo . GetDrives ( ) )
94101 {
95102 amongUsPath = d . Name + @"Program Files\Epic Games\AmongUs" ;
96103 if ( generateFolder ( amongUsPath ) )
97104 {
105+ Utils . log ( "EGS detection YES" , "ConfigManager" ) ;
106+ Utils . log ( "EGS detection END" , "ConfigManager" ) ;
98107 return ;
99108 }
100109 }
110+ Utils . log ( "EGS detection END" , "ConfigManager" ) ;
111+
101112
102-
113+ Utils . log ( "Config detection START" , "ConfigManager" ) ;
103114 if ( config . amongUsPath != null && config . amongUsPath != "" )
104115 {
105- Utils . log ( "[ConfigManager] Among Us path detected in Config " ) ;
116+ Utils . log ( "Config detection YES" , "ConfigManager ") ;
106117 amongUsPath = config . amongUsPath ;
107118 if ( generateFolder ( amongUsPath ) )
108119 {
120+ Utils . log ( "Config detection CONFIRM" , "ConfigManager" ) ;
109121 return ;
110122 }
111123 }
124+ Utils . log ( "Config detection END" , "ConfigManager" ) ;
112125 // No Among Us found
113126
114- Utils . log ( "[ConfigManager] Among Us path not detected, manual selection starts " ) ;
127+ Utils . log ( "Manual selection START" , "ConfigManager ") ;
115128 amongUsPath = null ;
116129 while ( amongUsPath == null || File . Exists ( amongUsPath + @"\Among Us.exe" ) == false )
117130 {
118131 if ( MessageBox . Show ( "Among Us not found ! Please, select the Among Us executable" , "Among Us not found" , MessageBoxButtons . OKCancel , MessageBoxIcon . Information ) == DialogResult . Cancel )
119132 {
133+ Utils . log ( "Manual selection LEFT" , "ConfigManager" ) ;
120134 Environment . Exit ( 0 ) ;
121135 }
122136 amongUsPath = selectFolderWorker ( ) ;
123137 }
138+ Utils . log ( "Manual selection YES" , "ConfigManager" ) ;
124139 if ( generateFolder ( amongUsPath ) )
125140 {
141+ Utils . log ( "Manual selection CONFIRM" , "ConfigManager" ) ;
126142 return ;
127143 }
128144 }
129145
130146 public static Boolean generateFolder ( string path )
131147 {
148+ Utils . log ( "Vanilla creation START" , "ConfigManager" ) ;
132149 if ( File . Exists ( path + @"\Among Us.exe" ) )
133150 {
134- Utils . log ( "[ConfigManager] Among Us path validated " ) ;
151+ Utils . log ( "Vanilla creation YES" , "ConfigManager ") ;
135152 string latest = ServerConfig . get ( "gameVersion" ) . value ;
136153 string destPath = ModManager . appDataPath + @"\vanilla\" + latest ;
137154 Directory . CreateDirectory ( destPath ) ;
@@ -141,13 +158,16 @@ public static Boolean generateFolder(string path)
141158 config . currentGameVersion = latest ;
142159 config . amongUsPath = path ;
143160 update ( ) ;
161+ Utils . log ( "Vanilla creation CONFIRM" , "ConfigManager" ) ;
144162 return true ;
145163 }
164+ Utils . log ( "Vanilla creation NO" , "ConfigManager" ) ;
146165 return false ;
147166 }
148167
149168 public static string selectFolderWorker ( )
150169 {
170+ Utils . log ( "Select folder START" , "ConfigManager" ) ;
151171 OpenFileDialog folderBrowser = new OpenFileDialog ( ) ;
152172 folderBrowser . ValidateNames = false ;
153173 folderBrowser . CheckFileExists = false ;
@@ -159,21 +179,27 @@ public static string selectFolderWorker()
159179 if ( folderBrowser . ShowDialog ( ) == DialogResult . OK )
160180 {
161181 string folderPath = Path . GetDirectoryName ( folderBrowser . FileName ) ;
182+ Utils . log ( "Select folder YES" , "ConfigManager" ) ;
162183 return folderPath ;
163184 }
185+ Utils . log ( "Select folder NO" , "ConfigManager" ) ;
164186 return null ;
165187 }
166188
167189 public static void update ( )
168190 {
191+ Utils . log ( "Config update START" , "ConfigManager" ) ;
169192 string json = JsonConvert . SerializeObject ( config ) ;
170193 File . WriteAllText ( path , json ) ;
194+ Utils . log ( "Config update END" , "ConfigManager" ) ;
171195 }
172196
173197 public static void updateGlobalConfig ( )
174198 {
199+ Utils . log ( "Global config update START" , "ConfigManager" ) ;
175200 string json = JsonConvert . SerializeObject ( globalConfig ) ;
176201 File . WriteAllText ( globalPath , json ) ;
202+ Utils . log ( "Global config update END" , "ConfigManager" ) ;
177203 }
178204
179205 public static InstalledMod getInstalledModById ( string id )
@@ -188,8 +214,24 @@ public static Boolean containsGameVersion(string version)
188214
189215 public static void logConfig ( )
190216 {
191- string ret = "[ConfigManager] OS Version : " + System . Environment . OSVersion . ToString ( ) ;
192- Utils . log ( ret ) ;
217+ Utils . log ( "Computer information" , "ConfigManager" ) ;
218+ ComputerInfo c = new ComputerInfo ( ) ;
219+ decimal ram = c . TotalPhysicalMemory ;
220+ ram = Math . Round ( ram / ( 1024 * 1024 * 1024 ) , 1 ) ;
221+ Utils . log ( "- OS Version: " + c . OSFullName , "ConfigManager" ) ;
222+ Utils . log ( "- OS Language: " + c . InstalledUICulture . Name , "ConfigManager" ) ;
223+ Utils . log ( "- Processor: " + System . Environment . GetEnvironmentVariable ( "PROCESSOR_IDENTIFIER" ) , "ConfigManager" ) ;
224+ Utils . log ( "- RAM: " + ram . ToString ( ) + "Go" , "ConfigManager" ) ;
225+ Utils . log ( "- Drives:" , "ConfigManager" ) ;
226+ foreach ( DriveInfo d in DriveInfo . GetDrives ( ) )
227+ {
228+ decimal free = d . AvailableFreeSpace ;
229+ decimal total = d . TotalSize ;
230+ free = Math . Round ( free / ( 1024 * 1024 * 1024 ) , 1 ) ;
231+ total = Math . Round ( total / ( 1024 * 1024 * 1024 ) , 1 ) ;
232+
233+ Utils . log ( " - Drive " + d . Name + ":" + free + "/" + total , "ConfigManager" ) ;
234+ }
193235 }
194236 }
195237
0 commit comments