コード例 #1
0
        /// <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();
            }
        }
コード例 #2
0
ファイル: XmlConfiguredScript.cs プロジェクト: vjmira/fomm
        /// <summary>
        ///   Installs the given <see cref="OptionsForm.PluginFile" />, and activates any
        ///   esm/esp files it encompasses as requested.
        /// </summary>
        /// <param name="plfFile">The file to install.</param>
        /// <param name="booActivate">Whether or not to activate any esp/esm files.</param>
        /// <returns>
        ///   <lang langref="false" /> if the user cancelled the install;
        ///   <lang langref="true" /> otherwise.
        /// </returns>
        protected bool InstallPluginFile(PluginFile plfFile, bool booActivate)
        {
            var strSource = plfFile.Source;
            var strDest   = plfFile.Destination;

            m_bwdProgress.ItemMessage = "Installing " + (String.IsNullOrEmpty(strDest) ? strSource : strDest);
            if (plfFile.IsFolder)
            {
                CopyDataFolder(strSource, strDest);

                if (m_bwdProgress.Cancelled())
                {
                    return(false);
                }

                //if the destination length is greater than 0, then nothing in
                // this folder is directly in the Data folder as so cannot be
                // activated
                if (strDest.Length == 0)
                {
                    var lstFiles = GetFomodFolderFileList(strSource);
                    m_bwdProgress.ItemMessage         = "Activating " + (String.IsNullOrEmpty(strDest) ? strSource : strDest);
                    m_bwdProgress.ItemProgress        = 0;
                    m_bwdProgress.ItemProgressMaximum = lstFiles.Count;

                    if (!strSource.EndsWith("/"))
                    {
                        strSource += "/";
                    }
                    foreach (var strFile in lstFiles)
                    {
                        if (strFile.ToLowerInvariant().EndsWith(".esm") || strFile.ToLowerInvariant().EndsWith(".esp"))
                        {
                            var strNewFileName = strFile.Substring(strSource.Length, strFile.Length - strSource.Length);
                            m_misInstallScript.SetPluginActivation(strNewFileName, booActivate);
                        }
                        if (m_bwdProgress.Cancelled())
                        {
                            return(false);
                        }
                        m_bwdProgress.StepItemProgress();
                    }
                }
            }
            else
            {
                m_bwdProgress.ItemProgress        = 0;
                m_bwdProgress.ItemProgressMaximum = 2;

                m_misInstallScript.CopyDataFile(strSource, strDest);

                m_bwdProgress.StepItemProgress();

                if (String.IsNullOrEmpty(strDest))
                {
                    if (strSource.ToLowerInvariant().EndsWith(".esm") || strSource.ToLowerInvariant().EndsWith(".esp"))
                    {
                        m_misInstallScript.SetPluginActivation(strSource, booActivate);
                    }
                }
                else if (strDest.ToLowerInvariant().EndsWith(".esm") || strDest.ToLowerInvariant().EndsWith(".esp"))
                {
                    m_misInstallScript.SetPluginActivation(strDest, booActivate);
                }

                m_bwdProgress.StepItemProgress();
            }
            return(true);
        }