1414using SFS . Adapter ;
1515using SFS . Translations ;
1616using ModLoader . UI ;
17+ using ModLoader . Helpers ;
1718
1819namespace ModLoader
1920{
2021 /// <summary>
21- /// This is the main class of ModLoader. this class is injected into the game with the Unity Doorstop injector.
22+ /// This is the main class of ModLoader. this class is injected into the game with the Unity Doorstop injector.
2223 /// </summary>
2324 public class Loader : MonoBehaviour
2425 {
25- // This save Loader instance
26+
27+ /// <summary>
28+ /// This save Loader instance
29+ /// </summary>
2630 public static Loader main ;
27- //private Console _console;
2831
29- // This save the gameObject that implement Loader class
32+ /// <summary>
33+ /// This save the gameObject that implement Loader class
34+ /// </summary>
3035 public static GameObject root ;
3136
32- private static FolderPath _modsFolder ;
33-
34- // modlaoder version
35- private const string modLoderVersion = "v1.2 .0" ;
37+ /// <summary>
38+ /// Current Modlaoder version
39+ /// </summary>
40+ private const string modLoderVersion = "v1.3 .0" ;
3641
42+ /// <summary>
43+ /// Get folder where mods are
44+ /// </summary>
3745 public static FolderPath ModsFolder
3846 {
39- get { return _modsFolder ; }
47+ get { return FileLocations . BaseFolder . Extend ( "MODS" ) ; }
4048 }
4149
4250 private List < SFSMod > _modsLoaded = new List < SFSMod > ( ) ;
@@ -45,12 +53,12 @@ public static FolderPath ModsFolder
4553 private Dictionary < string , SFSMod > _modList ;
4654
4755 /// <summary>
48- /// First executed method. Save the loader instance to static var, subscribe to the scene event and load mods for early patches.
56+ /// First executed method. Save the loader instance to static var, subscribe to the scene event and load mods for early patches.
4957 /// </summary>
5058 private void Awake ( )
5159 {
5260 Loader . main = this ;
53- _modsFolder = FileLocations . BaseFolder . Extend ( "MODS" ) . CreateFolder ( ) ;
61+ FolderPath modsFolder = ModsFolder . CreateFolder ( ) ;
5462
5563 Debug . Log ( $ "--- ModLoader { modLoderVersion } ---") ;
5664
@@ -75,26 +83,29 @@ private void Awake()
7583 }
7684
7785 Debug . Log ( "Early load finished" ) ;
78- Helper . OnHomeSceneLoaded += this . OnGomeSceneLoaded ;
86+ SceneHelper . OnHomeSceneLoaded += this . OnHomeSceneLoaded ;
7987 }
8088
81- private void OnGomeSceneLoaded ( object sender , EventArgs args )
89+ /// <summary>
90+ /// Is called when Home scenes has been loaded
91+ /// </summary>
92+ /// <param name="sender">Who send this event</param>
93+ /// <param name="scene">Scene information</param>
94+ private void OnHomeSceneLoaded ( object sender , Scene scene )
8295 {
8396 this . insertModsButton ( ) ;
8497 }
8598
8699 /// <summary>
87- /// This method starts reading mods and runs automatically when this class is created after the Awake method.
100+ /// This method starts reading mods and runs automatically when this class is created after the Awake method.
88101 /// </summary>
89102 private void Start ( )
90103 {
91- Debug . Log ( "Loading mods" ) ;
104+ Debug . Log ( "Starting mods" ) ;
92105 foreach ( SFSMod mod in _modsLoaded )
93106 {
94107 mod . load ( ) ;
95108 }
96-
97- Debug . Log ( "Loading finished" ) ;
98109 this . insertModsButton ( ) ;
99110 }
100111
@@ -120,7 +131,7 @@ private void insertModsButton()
120131 }
121132
122133 /// <summary>
123- /// get mod instance.
134+ /// Get mod instance.
124135 /// </summary>
125136 /// <param name="modId">Mod ID you need</param>
126137 /// <returns>instance mod</returns>
@@ -137,7 +148,7 @@ public SFSMod getMod(string modId)
137148 }
138149
139150 /// <summary>
140- /// Get a list of all loaded mods
151+ /// Get a list of all loaded mods
141152 /// </summary>
142153 /// <returns> Loaded mods </returns>
143154 public SFSMod [ ] getMods ( )
@@ -157,7 +168,7 @@ private Dictionary<string, SFSMod> getModList()
157168 this . detectIndividualDlls ( ) ;
158169
159170 // get a list of mod folders in the MODS folder
160- IEnumerable < FolderPath > modsFolders = _modsFolder . GetFoldersInFolder ( false ) ;
171+ IEnumerable < FolderPath > modsFolders = ModsFolder . GetFoldersInFolder ( false ) ;
161172 string basePath = Path . Combine ( FileLocations . BaseFolder , "MODS" ) ;
162173
163174 foreach ( FolderPath folder in modsFolders )
@@ -201,10 +212,14 @@ private Dictionary<string, SFSMod> getModList()
201212 }
202213
203214 /// <summary>
204- /// Load the mod dependencies and check if it is already loaded and check its version.
215+ /// Load the mod dependencies and check if it is already loaded and check its version.
205216 /// </summary>
206- /// <param name="dependencies"> lista de dependencias que necesitas cargar primero</param>
207- /// <returns> verdadero si se han cargado todas las dependencias</returns>
217+ /// <param name="dependencies">
218+ /// List of dependencies that need to be loaded first
219+ /// </param>
220+ /// <returns>
221+ /// True if all dependencies have been loaded
222+ /// </returns>
208223 private bool loadDependencies ( Dictionary < string , string [ ] > dependencies )
209224 {
210225 // for each mod dependency
@@ -241,9 +256,11 @@ private bool loadDependencies(Dictionary<string, string[]> dependencies)
241256 }
242257
243258 /// <summary>
244- /// Start checking mod version and run load method
259+ /// Start checking mod version and run load method
245260 /// </summary>
246- /// <param name="mod">Mod to start load</param>
261+ /// <param name="mod">
262+ /// Mod to start load
263+ /// </param>
247264 private void loadMod ( SFSMod mod )
248265 {
249266 // has this mod been loaded?, if it does not start loading
@@ -275,11 +292,20 @@ private void loadMod(SFSMod mod)
275292 }
276293
277294 /// <summary>
278- /// Check the string of two versions to identify if they are the same
295+ /// Check the string of two versions to identify if they are the same
279296 /// </summary>
280- /// <param name="version1"> version to check</param>
281- /// <param name="version2"> verison to check</param>
282- /// <returns>True if they are valid versions</returns>
297+ /// <param name="version1">
298+ /// Version to check
299+ /// </param>
300+ /// <param name="version2">
301+ /// Verison to check
302+ /// </param>
303+ /// <param name="checkMinVersion">
304+ /// check if version 1 is is less than or equal to version 2
305+ /// </param>
306+ /// <returns>
307+ /// True if they are valid versions
308+ /// </returns>
283309 private bool verifyVersion ( string version1 , string version2 , bool checkMinVersion = false )
284310 {
285311 Regex rx = new Regex ( @"\bv([0-9]+)(\.([0-9]+|x)){2}\b" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
@@ -288,7 +314,7 @@ private bool verifyVersion(string version1, string version2, bool checkMinVersio
288314 {
289315 string [ ] target1 = version1 . Split ( '.' ) ;
290316 string [ ] target2 = version2 . Split ( '.' ) ;
291-
317+ int num1 , num2 ;
292318 if ( target1 . Length == target2 . Length )
293319 {
294320 for ( short index = 0 ; index < target2 . Length ; index ++ )
@@ -300,7 +326,7 @@ private bool verifyVersion(string version1, string version2, bool checkMinVersio
300326
301327 if ( checkMinVersion )
302328 {
303- int num1 , num2 ;
329+
304330 if ( int . TryParse ( target1 [ index ] , out num1 ) )
305331 {
306332 if ( int . TryParse ( target2 [ index ] , out num2 ) )
@@ -326,32 +352,30 @@ private bool verifyVersion(string version1, string version2, bool checkMinVersio
326352 }
327353
328354 /// <summary>
329- /// This function looks in the MODS folder for incorrectly installed mods and moves them to a new folder
330- /// where they should be.
355+ /// This function looks in the MODS folder for incorrectly installed mods and moves them to a new folder
356+ /// where they should be.
331357 /// </summary>
332358 private void detectIndividualDlls ( )
333359 {
334360 try
335361 {
336362 Debug . Log ( "Searching mods improperly installed" ) ;
337363 FolderPath newFolder ;
338- foreach ( FilePath file in _modsFolder . GetFilesInFolder ( false ) )
364+ foreach ( FilePath file in ModsFolder . GetFilesInFolder ( false ) )
339365 {
340366
341367 if ( file . Extension == "dll" )
342368 {
343369 Debug . Log ( $ "{ file . FileName } incorrectly installed!") ;
344- newFolder = _modsFolder . Extend ( file . CleanFileName ) ;
370+ newFolder = ModsFolder . Extend ( file . CleanFileName ) ;
345371 if ( ! newFolder . FolderExists ( ) )
346372 {
347373 newFolder = newFolder . CreateFolder ( ) ;
348374 }
349375 Debug . Log ( $ "{ file . FileName } moved!") ;
350376 file . Move ( newFolder . ExtendToFile ( file . FileName ) ) ;
351- _modsFolder = FileLocations . BaseFolder . Extend ( "MODS" ) ;
352377 }
353378 }
354- Debug . Log ( "Everything moved!" ) ;
355379 }
356380 catch ( Exception e )
357381 {
@@ -361,7 +385,7 @@ private void detectIndividualDlls()
361385 }
362386
363387 /// <summary>
364- /// This is the mod loader entry point, this is the method that is executed after being injected into the game.
388+ /// This is the mod loader entry point, this is the method that is executed after being injected into the game.
365389 /// </summary>
366390 /// <param name="args"></param>
367391 public static void Main ( string [ ] args )
0 commit comments