private void InstallMods(List <string> modsToInstall, bool safeInstall = true) { CleanerHelper _cleanerHelper = new CleanerHelper(); InjectionHelper _injectionHelper = new InjectionHelper(); BackupHelper _backupHelper = new BackupHelper(); if (modsToInstall.Count > 0) { var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString); if (installedModsList == null) { _backupHelper.DoBackup(gameFolderPathString); } foreach (string installedMod in installedModsList) { if (modsToInstall.Contains(installedMod)) { Console.WriteLine("Warning: Tried to install an already installed mod"); if (safeInstall) { Console.WriteLine("Safe install is on, aborting. To turn it of, use the --unsafe-install option"); return; } else { modsToInstall.Remove(installedMod); Console.WriteLine("Continuing installation"); } } } if (_injectionHelper.InstallSelectedMods(gameFolderPathString, modsToInstall) == true) //If we successfully combined the mod files into the assembly { Console.WriteLine("Installation successfull"); } else { Console.WriteLine("Installation failed."); Console.WriteLine("Terminated modding attempt. Trying to scrub mod files."); if (_cleanerHelper.CleanGameFolder(gameFolderPathString) == 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 == "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(gameFolderPathString + "\\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) { } } }