public static void RemoveAll(ManagedMods mods) { LogFile.WriteLine("Removing all installed mods"); // Delete bundled archives: DeployArchiveList deployArchives = new DeployArchiveList(mods.GamePath); foreach (DeployArchive deployArchive in deployArchives) { LogFile.WriteLine($" Removing {deployArchive.ArchiveName}"); if (File.Exists(deployArchive.GetArchivePath())) { File.Delete(deployArchive.GetArchivePath()); } mods.Resources.Remove(deployArchive.ArchiveName); } LogFile.WriteLine($" Deleting temporary folders"); deployArchives.DeleteTempFolder(); // Remove mods: foreach (ManagedMod mod in mods) { LogFile.WriteLine($" Removing mod {mod.Title}"); ModDeployment.Remove(mod, mods.Resources, mods.GamePath); } mods.Save(); }
/// <summary> /// Deletes all files of the mod and removes it from the list. /// Saves the xml file afterwards. /// </summary> public static void DeleteMod(ManagedMods mods, int index, Action <Progress> ProgressChanged = null) { ModDeployment.Remove(mods[index], mods.Resources, mods.GamePath); ModActions.DeleteFiles(mods[index]); mods.RemoveAt(index); mods.Save(); ProgressChanged?.Invoke(Progress.Done("Mod deleted.")); }
public static void Deploy(ManagedMods mods, Action <Progress> ProgressChanged, bool invalidateBundledFrozenArchives = true) { LogFile.WriteLine("\n\n"); LogFile.WriteTimeStamp(); LogFile.WriteLine($"Version {Shared.VERSION}, deploying..."); LogFile.WriteLine($"Game path: {mods.GamePath}"); // TODO: More descriptive ProgressChanged ProgressChanged?.Invoke(Progress.Indetermined("Deploying...")); // Check for conflicts: LogFile.WriteLine("Checking for conflicting archive names..."); List <ModHelpers.Conflict> conflicts = ModHelpers.GetConflictingArchiveNames(mods.Mods); if (conflicts.Count > 0) { LogFile.WriteLine("Conflicts found, abort."); foreach (ModHelpers.Conflict conflict in conflicts) { LogFile.WriteLine($" Conflict: {conflict.conflictText}"); } throw new DeploymentFailedException("Conflicting archive names."); } // Restore *.dll files: RestoreAddedDLLs(mods.GamePath); // Remove all currently deployed mods: ProgressChanged?.Invoke(Progress.Indetermined("Removing mods...")); ModDeployment.RemoveAll(mods); mods.Save(); // If mods are enabled: if (!mods.ModsDisabled) { LogFile.WriteLine("Installing mods..."); // Deploy all SeparateBA2 and Loose mods: foreach (ManagedMod mod in mods) { ProgressChanged?.Invoke(Progress.Indetermined($"Deploying {mod.Title}...")); if (mod.Enabled && Directory.Exists(mod.ManagedFolderPath) && !Utils.IsDirectoryEmpty(mod.ManagedFolderPath)) { switch (mod.Method) { case ManagedMod.DeploymentMethod.SeparateBA2: DeploySeparateArchive(mod, mods.Resources); mods.Save(); break; case ManagedMod.DeploymentMethod.LooseFiles: DeployLooseFiles(mods, mod, mods.GamePath); mods.Save(); break; } } } // Deploy all BundledBA2 mods: ProgressChanged?.Invoke(Progress.Indetermined($"Building bundled archives...")); ModDeployment.DeployBundledArchives(mods, IniFiles.Config.GetBool("Mods", "bFreezeBundledArchives", false), invalidateBundledFrozenArchives); mods.Save(); ProgressChanged?.Invoke(Progress.Done("Mods deployed.")); } else { ProgressChanged?.Invoke(Progress.Done("Mods removed.")); } LogFile.WriteLine("Deployment finished."); LogFile.WriteLine($"Resource list ({mods.Resources.Count} files): \"{mods.Resources}\""); }