/// <summary> /// This undoes any changes that were made by the previous version of the fomod being upgraded, but /// were not made by the current version. /// </summary> /// <remarks> /// This method is used for the background worker. /// </remarks> private void ReconcileDifferences() { m_bwdProgress.OverallProgressMaximum = 3; m_bwdProgress.ItemMessage = "Synchronizing Files"; var ilmPreviousChanges = InstallLog.Current.GetMergeModule(Fomod.BaseName); m_bwdProgress.ItemProgressMaximum = ilmPreviousChanges.DataFiles.Count; foreach (var strFile in ilmPreviousChanges.DataFiles) { if (!MergeModule.ContainsFile(strFile)) { Script.UninstallDataFile(strFile); } if (m_bwdProgress.Cancelled()) { return; } m_bwdProgress.StepItemProgress(); } m_bwdProgress.StepOverallProgress(); m_bwdProgress.ItemMessage = "Synchronizing Ini Edits"; m_bwdProgress.ItemProgressMaximum = ilmPreviousChanges.IniEdits.Count; foreach (var iniEdit in ilmPreviousChanges.IniEdits) { if (!MergeModule.IniEdits.Contains(iniEdit)) { Script.UneditIni(iniEdit.File, iniEdit.Section, iniEdit.Key); } if (m_bwdProgress.Cancelled()) { return; } m_bwdProgress.StepItemProgress(); } m_bwdProgress.StepOverallProgress(); m_bwdProgress.ItemMessage = "Synchronizing Game Specific Value Edits"; m_bwdProgress.ItemProgressMaximum = ilmPreviousChanges.GameSpecificValueEdits.Count; foreach (var gsvEdit in ilmPreviousChanges.GameSpecificValueEdits) { if (!MergeModule.GameSpecificValueEdits.Contains(gsvEdit)) { Script.UneditGameSpecificValue(gsvEdit.Key); } if (m_bwdProgress.Cancelled()) { return; } m_bwdProgress.StepItemProgress(); } m_bwdProgress.StepOverallProgress(); }
/// <summary> /// This performs the mirgration. /// </summary> /// <param name="p_objArgs">The path to the old FOMM installation.</param> protected void DoMigration(object p_objArgs) { var strOldFOMMLocation = (string)p_objArgs; var tfmFileManager = new TxFileManager(); //copy the mods //do we need to copy? if ( !Path.Combine(strOldFOMMLocation, "mods") .Equals(Program.GameMode.ModDirectory, StringComparison.InvariantCultureIgnoreCase)) { var lstModFiles = new List <string>(); lstModFiles.AddRange(Directory.GetFiles(Path.Combine(strOldFOMMLocation, "mods"), "*.fomod")); lstModFiles.AddRange(Directory.GetFiles(Path.Combine(strOldFOMMLocation, "mods"), "*.xml")); m_bwdProgress.ItemMessage = "Copying mods..."; m_bwdProgress.ItemProgressMaximum = lstModFiles.Count; m_bwdProgress.ItemProgress = 0; foreach (var strMod in lstModFiles) { var strModFileName = Path.GetFileName(strMod); m_bwdProgress.ItemMessage = "Copying mods (" + strModFileName + ")..."; tfmFileManager.Copy(strMod, Path.Combine(Program.GameMode.ModDirectory, strModFileName), true); //File.Copy(strMod, Path.Combine(Program.GameMode.ModDirectory, Path.GetFileName(strMod))); m_bwdProgress.StepItemProgress(); if (m_bwdProgress.Cancelled()) { return; } } } m_bwdProgress.StepOverallProgress(); //copy overwrites folder //do we need to? if ( !Path.Combine(strOldFOMMLocation, "overwrites") .Equals(Program.GameMode.OverwriteDirectory, StringComparison.InvariantCultureIgnoreCase)) { var strOverwriteFiles = Directory.GetFiles(Path.Combine(strOldFOMMLocation, "overwrites"), "*.*", SearchOption.AllDirectories); m_bwdProgress.ItemMessage = "Copying overwrites..."; m_bwdProgress.ItemProgressMaximum = strOverwriteFiles.Length; m_bwdProgress.ItemProgress = 0; FileUtil.Copy(tfmFileManager, Path.Combine(strOldFOMMLocation, "overwrites"), Program.GameMode.OverwriteDirectory, OverwriteFileCopied); } m_bwdProgress.StepOverallProgress(); //copy install logs //do we need to? if ( !Path.Combine(strOldFOMMLocation, "fomm") .Equals(Program.GameMode.InstallInfoDirectory, StringComparison.InvariantCultureIgnoreCase)) { var strMiscFiles = Directory.GetFiles(Path.Combine(strOldFOMMLocation, "fomm"), "InstallLog.xml*"); m_bwdProgress.ItemMessage = "Copying info files..."; m_bwdProgress.ItemProgressMaximum = strMiscFiles.Length; m_bwdProgress.ItemProgress = 0; foreach (var strFile in strMiscFiles) { tfmFileManager.Copy(strFile, Path.Combine(Program.GameMode.InstallInfoDirectory, Path.GetFileName(strFile)), true); m_bwdProgress.StepItemProgress(); if (m_bwdProgress.Cancelled()) { return; } } } m_bwdProgress.StepOverallProgress(); }
/// <summary> /// Handles the <see cref="fomod.ReadOnlyInitStepFinished" /> event of the FOMod. /// </summary> /// <remarks> /// This steps the progress in the progress dialog. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">A <see cref="CancelEventArgs" /> describing the event arguments.</param> private void Fomod_ReadOnlyInitStepFinished(object sender, CancelEventArgs e) { m_bwdProgress.StepOverallProgress(); }
/// <summary> /// Called when the conflict detector has processed a plugin. /// </summary> /// <remarks> /// This updates the detector progress bar. /// </remarks> /// <param name="sender">The object that trigger the event.</param> /// <param name="e">A <see cref="PluginProcessedEventArgs" /> describing the event arguments.</param> private void cdrDetector_PluginProcessed(object sender, PluginProcessedEventArgs e) { m_bwdProgress.StepOverallProgress(); e.Cancel = m_bwdProgress.Cancelled(); }
/// <summary> /// Performs a basic uninstall of the mod. /// </summary> /// <remarks> /// A basic uninstall removes all of the files that were installed by the mod, /// and undos all of the edits the mod made during install. /// </remarks> protected void PerformBasicUninstall() { var lstFiles = MergeModule.DataFiles; var lstIniEdits = MergeModule.IniEdits; var lstGameSpecificValueEdits = MergeModule.GameSpecificValueEdits; m_bwdProgress.OverallProgressMaximum = lstFiles.Count + lstIniEdits.Count + lstGameSpecificValueEdits.Count; m_bwdProgress.ItemProgressMaximum = lstFiles.Count; m_bwdProgress.ItemMessage = "Uninstalling Files"; foreach (var strFile in lstFiles) { if (m_bwdProgress.Cancelled()) { return; } if (Fomod == null) { Script.UninstallDataFile(m_strBaseName, strFile); } else { Script.UninstallDataFile(strFile); } m_bwdProgress.StepItemProgress(); m_bwdProgress.StepOverallProgress(); } m_bwdProgress.ItemProgressMaximum = lstIniEdits.Count; m_bwdProgress.ItemMessage = "Undoing Ini Edits"; foreach (var iniEdit in lstIniEdits) { if (m_bwdProgress.Cancelled()) { return; } if (Fomod == null) { Script.UneditIni(m_strBaseName, iniEdit.File, iniEdit.Section, iniEdit.Key); } else { Script.UneditIni(iniEdit.File, iniEdit.Section, iniEdit.Key); } m_bwdProgress.StepItemProgress(); m_bwdProgress.StepOverallProgress(); } m_bwdProgress.ItemProgressMaximum = lstGameSpecificValueEdits.Count; m_bwdProgress.ItemMessage = "Undoing Game Specific Value Edits"; foreach (var gsvEdit in lstGameSpecificValueEdits) { if (m_bwdProgress.Cancelled()) { return; } if (Fomod == null) { Script.UneditGameSpecificValue(m_strBaseName, gsvEdit.Key); } else { Script.UneditGameSpecificValue(gsvEdit.Key); } m_bwdProgress.StepItemProgress(); m_bwdProgress.StepOverallProgress(); } }
/// <summary> /// Installs and activates files are required. This method is used by the background worker. /// </summary> /// <param name="p_ifaArgs">The arguments used to configure what is installed.</param> protected void InstallFiles(object p_ifaArgs) { if (!(p_ifaArgs is InstallFilesArguments)) { throw new ArgumentException("The given argument obejct is not of type InstallFilesArguments.", "p_ifaArgs"); } var prsParser = ((InstallFilesArguments)p_ifaArgs).Parser; var ofmOptions = ((InstallFilesArguments)p_ifaArgs).Form; var lstRequiredFiles = prsParser.GetRequiredInstallFiles(); var lstInstallFiles = ofmOptions.FilesToInstall; m_bwdProgress.OverallProgressMaximum = lstRequiredFiles.Count + lstInstallFiles.Count; foreach (var pflRequiredFile in lstRequiredFiles) { if (m_bwdProgress.Cancelled()) { return; } if (!InstallPluginFile(pflRequiredFile, true)) { return; } m_bwdProgress.StepOverallProgress(); } var lstActivateFiles = ofmOptions.PluginsToActivate; foreach (var plfFile in lstInstallFiles) { if (m_bwdProgress.Cancelled()) { return; } if (!InstallPluginFile(plfFile, lstActivateFiles.Contains(plfFile))) { return; } m_bwdProgress.StepOverallProgress(); } var lstConditionInstallPatterns = prsParser.GetConditionalFileInstallPatterns(); foreach (var cipPattern in lstConditionInstallPatterns) { if (cipPattern.Dependency.IsFufilled) { foreach (var plfFile in cipPattern.Files) { if (m_bwdProgress.Cancelled()) { return; } if (!InstallPluginFile(plfFile, true)) { return; } m_bwdProgress.StepOverallProgress(); } } } }