public void RefreshInstalledMods(string _gameFolder, List <string> installedMods) { string managedFolder = PathHelper.Get().GetLLBGameManagedDirPath(_gameFolder); string modsFolder = Path.Combine(Directory.GetCurrentDirectory(), "mods"); foreach (string mod in installedMods) { string llbmm_modFolderPath = Path.Combine(modsFolder, mod); if (File.Exists(Path.Combine(managedFolder, mod + ".dll")) && File.Exists(Path.Combine(llbmm_modFolderPath, mod + ".dll"))) { File.Delete(Path.Combine(managedFolder, mod + ".dll")); File.Copy(Path.Combine(llbmm_modFolderPath, mod + ".dll"), Path.Combine(managedFolder, mod + ".dll")); string game_modRessourceFolder = Path.Combine(managedFolder, mod + "Resources"); string llbmm_modRessourceFolder = Path.Combine(llbmm_modFolderPath, mod + "Resources"); if (Directory.Exists(game_modRessourceFolder) && Directory.Exists(llbmm_modRessourceFolder)) { foreach (string f in Directory.GetFiles(llbmm_modRessourceFolder)) { File.Delete(f); } foreach (string dirPath in Directory.GetDirectories(llbmm_modRessourceFolder, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(llbmm_modRessourceFolder, game_modRessourceFolder)); } foreach (string newPath in Directory.GetFiles(llbmm_modRessourceFolder, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(llbmm_modRessourceFolder, game_modRessourceFolder), true); } } } } }
public bool CheckModStatus(string _gameDataFolder) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string assemblyPath = Path.Combine(_gameDataFolder, gameDataDirName, "Managed", "Assembly-CSharp.dll"); try { asmDef = AssemblyDefinition.ReadAssembly(assemblyPath); } catch { Debug.WriteLine("CleanerHelper.CheckModStatus: Could not find assembly"); return(false); } mainModule = asmDef.MainModule; var isModded = false; foreach (var type in mainModule.Types) { if (type.Name == "Mods") { if (type.Methods.Count > 0) { isModded = true; } } } asmDef.Dispose(); return(isModded); }
public void DoRewrite(string _gameFolder) { string gameManagedPath = PathHelper.Get().GetLLBGameManagedDirPath(_gameFolder); //Run all ASMRewriters var _rewriters = Directory.EnumerateFiles(gameManagedPath, "*", SearchOption.AllDirectories) .Where(s => s.EndsWith("ASMRewriter.exe") && s.Count(c => c == '.') == 1) .ToList(); _rewriters.Add(Path.Combine(Directory.GetCurrentDirectory(), "ModMenu", "ASMRewriter.exe")); if (_rewriters != null) { foreach (var writer in _rewriters) { var arg = gameManagedPath; var newarg = arg.Replace(" ", "%20"); Process ExternalProcess = new Process(); ExternalProcess.StartInfo.FileName = writer; ExternalProcess.StartInfo.Arguments = newarg; // supplies the exe with the needed path ExternalProcess.Start(); ExternalProcess.WaitForExit(); ExternalProcess.Dispose(); } } }
public void DoBackup(string gameDataFolder) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string assemblyPath = Path.Combine(gameDataFolder, gameDataDirName, "Managed", "Assembly-CSharp.dll"); string backupPath = Path.Combine(gameDataFolder, gameDataDirName, "Managed", "ModManagerBackup"); string backupAssemblyPath = Path.Combine(backupPath, "Assembly-CSharp-Backup.dll"); if (File.Exists(assemblyPath)) { if (File.Exists(backupAssemblyPath)) { File.Delete(backupAssemblyPath); } try { Directory.CreateDirectory(backupPath); File.Copy(assemblyPath, backupAssemblyPath); } catch { MessageBox.Show("Failed backup - Could not create backup directory or could not copy the old Assembly-CSharp file", "Error"); } } }
private void BrowseButton_Click(object sender, EventArgs e) { string gameExecFilename = PathHelper.Get().GetLLBExecutableName(); string gameDirName = PathHelper.Get().GetLLBGameDirName(); FolderBrowserDialog _LLBFolderFinder = new FolderBrowserDialog(); _LLBFolderFinder.Description = "Please select the " + gameDirName + " folder (The folder where the .exe is located)"; if (_config.LoadConfig().Count == 0) { _LLBFolderFinder.SelectedPath = Directory.GetCurrentDirectory(); } else { _LLBFolderFinder.SelectedPath = _config.LoadConfig()[0]; } if (_LLBFolderFinder.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!File.Exists(Path.Combine(_LLBFolderFinder.SelectedPath, gameExecFilename))) { MessageBox.Show("The selected directory does not contain " + gameExecFilename + ", please select the folder containing said file.", "Warning"); } _config.SaveConfig(_LLBFolderFinder.SelectedPath, showReadmeCheckbox.Checked); gameFolderPath.Text = _LLBFolderFinder.SelectedPath + dataFolderEnding; gameFolderPathString = _LLBFolderFinder.SelectedPath + dataFolderEnding; if (_cleanerHelper.CheckModStatus(gameFolderPathString) == true) { InstalledModsDGV.Rows.Clear(); GetInstalledModsAndAddThemToInstalledModsList(); } } }
public void RunRewriter(string _gameFolder, string path) { string gameManagedPath = PathHelper.Get().GetLLBGameManagedDirPath(_gameFolder); var arg = Path.Combine(gameManagedPath); var newarg = arg.Replace(" ", "%20"); Process ExternalProcess = new Process(); ExternalProcess.StartInfo.FileName = path; ExternalProcess.StartInfo.Arguments = newarg; // supplies the exe with the needed path ExternalProcess.Start(); ExternalProcess.WaitForExit(); ExternalProcess.Dispose(); }
public void RestoreBackup(string gameDataFolder) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string assemblyPath = Path.Combine(gameDataFolder, gameDataDirName, "Managed", "Assembly-CSharp.dll"); string backupPath = Path.Combine(gameDataFolder, gameDataDirName, "Managed", "ModManagerBackup"); string backupAssemblyPath = Path.Combine(backupPath, "Assembly-CSharp-Backup.dll"); if (File.Exists(backupAssemblyPath)) { File.Delete(assemblyPath); File.Copy(backupAssemblyPath, assemblyPath); } }
private void InitConfig() { List <string> configPath = _config.LoadConfig(); if (configPath.Count > 0) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string gameDirName = PathHelper.Get().GetLLBGameDirName(); if (configPath[0].Contains(Path.DirectorySeparatorChar + gameDataDirName)) { MessageBox.Show("LLBMM has detected that you have " + gameDataDirName + " as your selected game folder. This version requires you to set your selected folder to " + gameDirName + " instead. (The folder containing the exe)", "Warning"); } gameFolderPath.Text = configPath[0]; gameFolderPathString = configPath[0]; if (configPath[1] == "True") { showReadmeCheckbox.Checked = true; } else { showReadmeCheckbox.Checked = false; } ResizeWindow(); } string LLBMMPath = Directory.GetCurrentDirectory(); availableModsPath = Path.Combine(LLBMMPath, "mods"); Directory.CreateDirectory(availableModsPath); modInfoLabel.Text = "Mod Manager information"; if (File.Exists(Path.Combine(LLBMMPath, "Readme.rtf"))) { readmeBox.LoadFile(Path.Combine(LLBMMPath, "Readme.rtf")); } else { readmeBox.Clear(); readmeBox.AppendText("Could not find the LLBMM readme file.."); } var token = _config.LoadGitToken(); if (token != "") { GitClient.Credentials = new Credentials(token); Debug.WriteLine("Loaded token " + token); } }
public List <string> InstalledMods(string _gameDataFolder) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string assemblyPath = Path.Combine(_gameDataFolder, gameDataDirName, "Managed", "Assembly-CSharp.dll"); List <string> installedModsList = new List <string>(); try { asmDef = AssemblyDefinition.ReadAssembly(assemblyPath); } catch { return(installedModsList);; } mainModule = asmDef.MainModule; TypeDefinition typeDef = null; foreach (var type in mainModule.Types) { if (type.Name == "Mods") { typeDef = type; } } if (typeDef == null) { Debug.WriteLine("CleanerHelper.InstalledMods: TypeDefinition in was null"); asmDef.Dispose(); return(installedModsList); } if (typeDef != null) { foreach (var field in typeDef.Fields) { installedModsList.Add(field.Name); } } else { asmDef.Dispose(); } asmDef.Dispose(); return(installedModsList); }
public bool CleanGameFolder(string _gameDataFolder) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); try { string managedPath = Path.Combine(_gameDataFolder, gameDataDirName, "Managed"); string managedTempPath = Path.Combine(managedPath, "temp"); var bh = new BackupHelper(); bh.DeleteBackup(_gameDataFolder); if (Directory.Exists(managedTempPath)) { DirectoryInfo di = new DirectoryInfo(managedTempPath); foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } foreach (FileInfo file in di.GetFiles()) { file.Delete(); } Directory.Delete(managedTempPath); } foreach (string dirPath in Directory.GetDirectories(managedPath, " * ", SearchOption.AllDirectories)) { if (dirPath.EndsWith("Resources")) { foreach (string f in Directory.GetFiles(dirPath)) { File.Delete(f); } Directory.Delete(dirPath); } } return(true); } catch { MessageBox.Show("Could not clean all mod files from folder. Please go into the " + gameDataDirName + Path.DirectorySeparatorChar + "Managed folder and check if there is a ModManagerBackup folder. If there is, delete the Assembly-CSharp file in Managed and copy the backup file over it and remove 'backup' from its name. Also, delete the temp folder and any mod folders if they exist. Ensure that there is no ModMenu.dll present either.", ""); return(false); } }
public bool RemoveMod(string _gameDataFolder, string mod) { string gameDataDirName = PathHelper.Get().GetLLBGameDataDirName(); string managedPath = Path.Combine(_gameDataFolder, gameDataDirName, "Managed"); string assemblyPath = Path.Combine(managedPath, "Assembly-CSharp.dll"); //Injection information string injectTypeName = "LLScreen.ScreenIntroTitle"; // What type to inject into in Assemby-CSharp string injectMethodName = "CShowTitle"; // Method name in the type string modMethodNames = "Initialize"; DefaultAssemblyResolver defaultAssemblyResolver = new DefaultAssemblyResolver(); defaultAssemblyResolver.AddSearchDirectory(managedPath); ReaderParameters parameters = new ReaderParameters { AssemblyResolver = defaultAssemblyResolver }; try { asmDef = AssemblyDefinition.ReadAssembly(assemblyPath, parameters); } catch { MessageBox.Show("Could not find main game assembly, verify your gamefiles"); return(false); } AssemblyDefinition modAsm = null; try { modAsm = AssemblyDefinition.ReadAssembly(Path.Combine(managedPath, mod + ".dll")); } catch { return(false); } TypeDefinition injectPointType = asmDef.MainModule.GetType(injectTypeName); foreach (MethodDefinition method in injectPointType.Methods) { if (method.Name == injectMethodName) { try { ILProcessor ilproc = method.Body.GetILProcessor(); if (ilproc.Body.Instructions.Count > 0) { foreach (TypeDefinition modTypeDef in modAsm.MainModule.Types) { foreach (MethodDefinition modMethodDef in modTypeDef.Methods) { if (modMethodDef.Name == modMethodNames) { MethodReference callRef = asmDef.MainModule.ImportReference(modMethodDef); Instruction destroy = null; foreach (Instruction i in ilproc.Body.Instructions) { if (i.OpCode == OpCodes.Call && i.Operand.ToString() == callRef.ToString()) { destroy = i; } } ilproc.Remove(destroy); modAsm.Dispose(); } } } } } catch {} } } //Remove from mods list if (mod != "ModMenu") { mainModule = asmDef.MainModule; TypeDefinition typeDef = null; foreach (var type in mainModule.Types) { if (type.Name == "Mods") { typeDef = type; } } FieldDefinition fieldToDelete = null; foreach (var field in typeDef.Fields) { if (field.Name == mod) { fieldToDelete = field; } } if (fieldToDelete != null) { typeDef.Fields.Remove(fieldToDelete); } } else { modAsm.Dispose(); } var assemblyTempPath = Path.Combine(managedPath, "Assembly-CSharp-temp.dll"); asmDef.Write(assemblyTempPath); asmDef.Dispose(); if (File.Exists(assemblyTempPath)) { File.Delete(assemblyPath); File.Copy(assemblyTempPath, assemblyPath); File.Delete(assemblyTempPath); } if (Directory.Exists(Path.Combine(managedPath, mod + "Resources"))) { Directory.Delete(Path.Combine(managedPath, mod + "Resources"), true); } if (File.Exists(Path.Combine(managedPath, mod + ".dll"))) { File.Delete(Path.Combine(managedPath, mod + ".dll")); } return(true); }
public bool InstallSelectedMods(string _gameFolder, List <string> modsToInstall) { //LLBMM Paths string llbmm_rootDir = Directory.GetCurrentDirectory(); string llbmm_modsDir = Path.Combine(llbmm_rootDir, "mods"); //Game Folder Paths string game_managedDir = PathHelper.Get().GetLLBGameManagedDirPath(_gameFolder); string game_tempDir = Path.Combine(game_managedDir, "temp"); string game_mainAsmFile = Path.Combine(game_managedDir, "Assembly-CSharp.dll"); List <string> modsToInstallPaths = new List <string>(); //Will hold the file paths for the mods we recieved from the pendingMods ListBox. var i = 0; var _modList = modsToInstall; foreach (var mod in _modList) //Checks if a mods file exists and adds its path to a list if it does. { string modPath = Path.Combine(llbmm_modsDir, mod.ToString(), mod.ToString() + ".dll"); if (File.Exists(modPath)) { modsToInstallPaths.Add(modPath); } else { MessageBox.Show("Skipping " + mod + ". Can't find mod file at" + modPath + ". Please ensure that the file path matches the one in this window", "Error"); modsToInstall.Remove(mod); } i++; } Directory.CreateDirectory(game_tempDir); try { File.Copy(game_mainAsmFile, Path.Combine(game_tempDir, "Assembly-CSharp.dll")); } catch { MessageBox.Show("Could not copy the main Assembly-CSharp.dll to temp folder. Terminating modding attempt. Make sure you've set the correct gamefolder in LLBMM, if it's correct then please verify your gamefiles through steam", "Error"); return(false); } foreach (var path in modsToInstallPaths) { try { File.Copy(path, Path.Combine(game_tempDir, Path.GetFileName(path))); } catch { MessageBox.Show("Skipping mod " + Path.GetFileNameWithoutExtension(path) + ". Could not copy mod file at" + path + " to temp folder", "Error"); modsToInstall.Remove(Path.GetFileNameWithoutExtension(path)); } } if (!File.Exists(Path.Combine(game_managedDir, "ModMenu.dll"))) { File.Copy(Path.Combine(llbmm_rootDir, "ModMenu", "ModMenu.dll"), Path.Combine(game_tempDir, "ModMenu.dll")); //If modmenu isn't installed try to install it } else { byte[] past = File.ReadAllBytes(Path.Combine(game_managedDir, "ModMenu.dll")); byte[] present = File.ReadAllBytes(Path.Combine(llbmm_rootDir, "ModMenu", "ModMenu.dll")); if (past.Length != present.Length) { CleanerHelper ch = new CleanerHelper(); ch.RemoveMod(_gameFolder, "ModMenu"); File.Copy(Path.Combine(llbmm_rootDir, "ModMenu", "ModMenu.dll"), Path.Combine(game_tempDir, "ModMenu.dll")); } } List <string> tempFiles = Directory.EnumerateFiles(game_tempDir, "*", SearchOption.AllDirectories).Where(s => s.EndsWith(".dll") && s.Count(c => c == '.') == 1).ToList(); //Injection information string injectTypeName = "LLScreen.ScreenIntroTitle"; // What type to inject into in Assemby-CSharp string injectMethodName = "CShowTitle"; // Method name in the type string modMethodNames = "Initialize"; //Init Resolver DefaultAssemblyResolver defaultAssemblyResolver = new DefaultAssemblyResolver(); defaultAssemblyResolver.AddSearchDirectory(game_managedDir); defaultAssemblyResolver.AddSearchDirectory(game_tempDir); defaultAssemblyResolver.AddSearchDirectory(llbmm_rootDir); //Test om e kan fjærn den hær og den over ReaderParameters parameters = new ReaderParameters { AssemblyResolver = defaultAssemblyResolver }; //Get the assembly definitions of the main file AssemblyDefinition _mainFileAssemblyDef = AssemblyDefinition.ReadAssembly(Path.Combine(game_tempDir, "Assembly-CSharp.dll"), parameters); ModuleDefinition _mainFileMainModule = _mainFileAssemblyDef.MainModule; //Get the assembly definitions of the mod files List <AssemblyDefinition> _modAssemblyList = new List <AssemblyDefinition>(); foreach (string path in tempFiles) { if (path != Path.Combine(game_tempDir, "Assembly-CSharp.dll")) { try { _modAssemblyList.Add(AssemblyDefinition.ReadAssembly(path)); } catch { MessageBox.Show("Skipping mod " + Path.GetFileNameWithoutExtension(path) + ". Mod file " + path + " can't be injected", "Error"); modsToInstall.Remove(Path.GetFileNameWithoutExtension(path)); } } } TypeDefinition moddedClass = null; foreach (TypeDefinition type in _mainFileMainModule.Types) { if (type.Name == "Mods") { moddedClass = type; } } if (moddedClass == null) { //create custom class that holds mod names moddedClass = new TypeDefinition("", "Mods", TypeAttributes.Public | TypeAttributes.Class, _mainFileMainModule.TypeSystem.Object); //insert custom class into assembly _mainFileMainModule.Types.Add(moddedClass); moddedClass.Methods.Add(new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, _mainFileMainModule.TypeSystem.Void)); } foreach (var mod in modsToInstall) { moddedClass.Fields.Add(new FieldDefinition(mod.ToString(), FieldAttributes.Public, _mainFileMainModule.TypeSystem.String)); } TypeDefinition injectPointType = _mainFileAssemblyDef.MainModule.GetType(injectTypeName); if (injectPointType == null || injectPointType.Methods == null) { MessageBox.Show("Bad inject point (Terminating modding session)"); return(false); } foreach (MethodDefinition method in injectPointType.Methods) { if (method.Name == injectMethodName) { try { ILProcessor ilproc = method.Body.GetILProcessor(); if (ilproc.Body.Instructions.Count > 0) { var modCount = 0; //Create the instructions to inject Instruction codePosition = ilproc.Body.Instructions[ilproc.Body.Instructions.Count - 1]; foreach (AssemblyDefinition modArrayDef in _modAssemblyList) { foreach (TypeDefinition modTypeDef in modArrayDef.MainModule.Types) { foreach (MethodDefinition modMethodDef in modTypeDef.Methods) { if (modMethodDef.Name == modMethodNames) { Debug.WriteLine("Found " + modMethodDef.Name + " function"); MethodReference callRef = _mainFileAssemblyDef.MainModule.ImportReference(modMethodDef); Debug.WriteLine("Found call reference " + callRef.ToString()); ilproc.InsertBefore(codePosition, ilproc.Create(OpCodes.Call, callRef)); modCount++; } } } } } } catch { MessageBox.Show("Can't get method or insert instructions. Try narrowing down what modfile is breaking the insertion (Terminating modding attempt)"); return(false); } } } //save Assembly try { _mainFileAssemblyDef.Write(Path.Combine(game_tempDir, "Assembly-CSharp-modded.dll")); } catch { MessageBox.Show("Could not write assembly! Is the game running?", "Error"); return(false); } _mainFileAssemblyDef.Dispose(); foreach (var asm in _modAssemblyList) { asm.Dispose(); } foreach (var mod in modsToInstall) { var path = Path.Combine(game_tempDir, mod + ".dll"); if (path != Path.Combine(game_tempDir, "Assembly-CSharp.dll")) { try { File.Copy(path, Path.Combine(game_managedDir, Path.GetFileName(path))); } catch { File.Delete(Path.Combine(game_managedDir, Path.GetFileName(path))); File.Copy(path, Path.Combine(game_managedDir, Path.GetFileName(path))); } } var modResourcesDir = Path.Combine(llbmm_modsDir, mod, mod + "Resources"); if (Directory.Exists(modResourcesDir)) { Directory.CreateDirectory(Path.Combine(game_managedDir, mod + "Resources")); foreach (string dirPath in Directory.GetDirectories(modResourcesDir, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(modResourcesDir, Path.Combine(game_managedDir, mod + "Resources"))); } foreach (string newPath in Directory.GetFiles(modResourcesDir, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(modResourcesDir, Path.Combine(game_managedDir, mod + "Resources")), true); } } } if (File.Exists(game_mainAsmFile)) { File.Delete(game_mainAsmFile); File.Copy(Path.Combine(game_tempDir, "Assembly-CSharp-modded.dll"), game_mainAsmFile); } foreach (var mod in modsToInstall) { if (File.Exists(Path.Combine(game_managedDir, mod + "Resources", "ASMRewriter.exe"))) { RunRewriter(_gameFolder, Path.Combine(game_managedDir, mod + "Resources", "ASMRewriter.exe")); } } try { File.Copy(Path.Combine(game_tempDir, "ModMenu.dll"), Path.Combine(game_managedDir, "ModMenu.dll")); RunRewriter(_gameFolder, Path.Combine(llbmm_rootDir, "ModMenu", "ASMRewriter.exe")); } catch { } if (Directory.Exists(game_tempDir)) { DirectoryInfo di = new DirectoryInfo(game_tempDir); foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } foreach (FileInfo file in di.GetFiles()) { file.Delete(); } Directory.Delete(game_tempDir); } Debug.WriteLine("Modding complete!"); return(true); }
private void InstallModsButton_Click(object sender, EventArgs e) { var terminated = false; List <string> modsToInstall = new List <string>(); foreach (DataGridViewRow row in AvailableModsDGV.Rows) { if (row.Cells[3].Value != null && row.Cells[3].Value.Equals(true)) { modsToInstall.Add(row.Cells[0].Value.ToString()); } } if (modsToInstall.Count > 0) { var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString); if (installedModsList == null) { _backupHelper.DoBackup(gameFolderPathString); } if (_injectionHelper.InstallSelectedMods(gameFolderPathString, modsToInstall) == true) //If we successfully combined the mod files into the assembly { installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString); //get the installed mods InstalledModsDGV.Rows.Clear(); foreach (string mod in installedModsList) { var alreadyAdded = false; foreach (KeyValuePair <string, List <string> > keyVal in modsInformation) { if (keyVal.Key == mod) { alreadyAdded = true; } } if (!alreadyAdded) { List <string> modInfo = _availableMods.GetModInformation(Path.Combine(gameFolderPathString, PathHelper.Get().GetLLBGameDataDirName(), "Managed", mod + ".dll"), GitClient); modsInformation.Add(Path.GetFileNameWithoutExtension(mod), modInfo); InstalledModsDGV.Rows.Add(modInfo[0], modInfo[1], modInfo[2]); } else { foreach (KeyValuePair <string, List <string> > keyVal in modsInformation) { if (keyVal.Key == mod) { InstalledModsDGV.Rows.Add(keyVal.Value[0], keyVal.Value[1], keyVal.Value[2]); } } } } GetAvailableModsAndAddThemToAvailbleModsList(); if (InstalledModsDGV.Rows.Count < 7) { InstalledModsDGV.Columns[0].Width = 297; } else { InstalledModsDGV.Columns[0].Width = 280; } } else { terminated = true; } } if (terminated) { Debug.WriteLine("Terminated modding attempt. Trying to scrub mod files."); if (_cleanerHelper.CleanGameFolder(gameFolderPathString) == true) { } } }
private void GetInstalledModsAndAddThemToInstalledModsList() { var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString); if (installedModsList != null) { foreach (string mod in installedModsList) { var alreadyAdded = false; foreach (KeyValuePair <string, List <string> > keyVal in modsInformation) { if (keyVal.Key == mod) { alreadyAdded = true; } } if (!alreadyAdded) { List <string> modInfo = _availableMods.GetModInformation(Path.Combine(gameFolderPathString, PathHelper.Get().GetLLBGameDataDirName(), "Managed", mod + ".dll"), GitClient); modsInformation.Add(Path.GetFileNameWithoutExtension(mod), modInfo); InstalledModsDGV.Rows.Add(modInfo[0], modInfo[1], modInfo[2]); } else { foreach (KeyValuePair <string, List <string> > keyVal in modsInformation) { if (keyVal.Key == Path.GetFileNameWithoutExtension(mod)) { InstalledModsDGV.Rows.Add(keyVal.Value[0], keyVal.Value[1], keyVal.Value[2]); } } } } } if (InstalledModsDGV.Rows.Count < 7) { InstalledModsDGV.Columns[0].Width = 297; } else { InstalledModsDGV.Columns[0].Width = 280; } }