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 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)
                    {
                    }
                }
            }
        }
Esempio n. 3
0
        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);
            }
        }
        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);
                        }
                    }
                }
            }
        }