private void UninstallAllMods()
        {
            CleanerHelper _cleanerHelper = new CleanerHelper();
            BackupHelper  _backupHelper  = new BackupHelper();

            //copy pasted
            if (_cleanerHelper.CheckModStatus(gameFolderPathString) == true)
            {
                var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString);
                if (installedModsList.Count > 0)
                {
                    _cleanerHelper.RemoveMods(gameFolderPathString, installedModsList);
                    _cleanerHelper.CleanGameFolder(gameFolderPathString);
                }

                try
                {
                    _cleanerHelper.RemoveMod(gameFolderPathString, "ModMenu");
                    _backupHelper.RestoreBackup(gameFolderPathString);
                    _backupHelper.DeleteBackup(gameFolderPathString);
                }
                catch { Console.WriteLine("Could not remove ModMenu. Please verify your files"); }
                Console.WriteLine("Uninstalled All mods");
            }
            else
            {
                Console.WriteLine("CheckModStatus failed");
                _cleanerHelper.CleanGameFolder(gameFolderPathString);
            }
        }
        private void RefreshInstalledMods()
        {
            CleanerHelper   _cleanerHelper   = new CleanerHelper();
            InjectionHelper _injectionHelper = new InjectionHelper();

            //copy pasted
            var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString);

            if (installedModsList.Count > 0)
            {
                _injectionHelper.RefreshInstalledMods(gameFolderPathString, installedModsList);
                Console.WriteLine("Mods Refreshed");
            }
        }
        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 UninstallMods(List <string> modsToUninstall)
        {
            CleanerHelper _cleanerHelper = new CleanerHelper();
            BackupHelper  _backupHelper  = new BackupHelper();

            // mostly copy pasted
            if (_cleanerHelper.CheckModStatus(gameFolderPathString) == true)
            {
                foreach (var mod in modsToUninstall)
                {
                    if (_cleanerHelper.RemoveMod(gameFolderPathString, mod))
                    {
                        var installedModsList = _cleanerHelper.InstalledMods(gameFolderPathString);
                        if (installedModsList.Count == 0)
                        {
                            _cleanerHelper.RemoveMod(gameFolderPathString, "ModMenu");
                            _backupHelper.RestoreBackup(gameFolderPathString);
                            _backupHelper.DeleteBackup(gameFolderPathString);
                        }
                    }
                }
            }
        }
示例#5
0
        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(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 == 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;
            }
        }