Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 139f095

Browse files
committed
Add incorrectly installed mods function
1 parent 2f4271c commit 139f095

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

ModLoader/Loader.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ private void Awake()
5252
Loader.main = this;
5353
_modsFolder = FileLocations.BaseFolder.Extend("MODS").CreateFolder();
5454

55+
Debug.Log($"--- ModLoader {modLoderVersion} ---");
56+
5557
Debug.Log("Early loading mods");
5658
this._modList = this.getModList();
5759

@@ -145,6 +147,9 @@ private Dictionary<string, SFSMod> getModList()
145147
{
146148
Dictionary<string, SFSMod> modList = new Dictionary<string, SFSMod>();
147149

150+
// find if the user misplaced the dll file
151+
this.detectIndividualDlls();
152+
148153
// get a list of mod folders in the MODS folder
149154
IEnumerable<FolderPath> modsFolders = _modsFolder.GetFoldersInFolder(false);
150155
string basePath = Path.Combine(FileLocations.BaseFolder, "MODS");
@@ -314,6 +319,41 @@ private bool verifyVersion(string version1, string version2, bool checkMinVersio
314319
return false;
315320
}
316321

322+
/// <summary>
323+
/// This function looks in the MODS folder for incorrectly installed mods and moves them to a new folder
324+
/// where they should be.
325+
/// </summary>
326+
private void detectIndividualDlls()
327+
{
328+
try
329+
{
330+
Debug.Log("Searching mods improperly installed");
331+
FolderPath newFolder;
332+
foreach (FilePath file in _modsFolder.GetFilesInFolder(false))
333+
{
334+
335+
if(file.Extension == "dll")
336+
{
337+
Debug.Log($"{file.FileName} incorrectly installed!");
338+
newFolder = _modsFolder.Extend(file.CleanFileName);
339+
if (!newFolder.FolderExists())
340+
{
341+
newFolder = newFolder.CreateFolder();
342+
}
343+
Debug.Log($"{file.FileName} moved!");
344+
file.Move(newFolder.ExtendToFile(file.FileName));
345+
_modsFolder = FileLocations.BaseFolder.Extend("MODS");
346+
}
347+
}
348+
Debug.Log("Everything moved!");
349+
}
350+
catch(Exception e)
351+
{
352+
Debug.LogException(e);
353+
Debug.Log("Failed to check for incorrectly installed mods!");
354+
}
355+
}
356+
317357
/// <summary>
318358
/// This is the mod loader entry point, this is the method that is executed after being injected into the game.
319359
/// </summary>

0 commit comments

Comments
 (0)