Пример #1
0
        /// <summary>
        /// This executes the install script.
        /// </summary>
        /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
        /// <returns><c>true</c> if the script completed successfully;
        /// <c>false</c> otherwise.</returns>
        protected bool RunScript(TxFileManager p_tfmFileManager)
        {
            IModFileInstaller mfiFileInstaller = CreateFileInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);
            bool booResult = false;

            if (Mod.HasInstallScript)
            {
                IDataFileUtil dfuDataFileUtility = new DataFileUtil(GameMode.GameModeEnvironmentInfo.InstallationPath);

                IIniInstaller iniIniInstaller = CreateIniInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);
                IGameSpecificValueInstaller gviGameSpecificValueInstaller = CreateGameSpecificValueInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);

                InstallerGroup  ipgInstallers = new InstallerGroup(dfuDataFileUtility, mfiFileInstaller, iniIniInstaller, gviGameSpecificValueInstaller, PluginManager);
                IScriptExecutor sexScript     = Mod.InstallScript.Type.CreateExecutor(Mod, GameMode, EnvironmentInfo, ipgInstallers, UIContext);
                sexScript.TaskStarted      += new EventHandler <EventArgs <IBackgroundTask> >(ScriptExecutor_TaskStarted);
                sexScript.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(ScriptExecutor_TaskSetCompleted);
                booResult = sexScript.Execute(Mod.InstallScript);

                iniIniInstaller.FinalizeInstall();

                if (gviGameSpecificValueInstaller != null)
                {
                    gviGameSpecificValueInstaller.FinalizeInstall();
                }
            }
            else
            {
                booResult = RunBasicInstallScript(mfiFileInstaller, ActiveMods);
            }
            mfiFileInstaller.FinalizeInstall();
            return(booResult);
        }
Пример #2
0
        /// <summary>
        /// Runs the basic uninstall script.
        /// </summary>
        /// <remarks>
        /// A basic uninstall uninstalls all of the changes made when the mod was installed.
        /// </remarks>
        /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
        /// <returns><c>true</c> if the uninstallation was successful;
        /// <c>false</c> otherwise.</returns>
        protected bool RunBasicUninstallScript(TxFileManager p_tfmFileManager, out string p_strErrorMessage)
        {
            p_strErrorMessage = null;
            IDataFileUtil dfuDataFileUtility = new DataFileUtil(GameMode.GameModeEnvironmentInfo.InstallationPath);

            IModFileInstaller           mfiFileInstaller = new ModFileInstaller(GameMode.GameModeEnvironmentInfo, Mod, ModInstallLog, PluginManager, dfuDataFileUtility, p_tfmFileManager, null, GameMode.UsesPlugins, m_mmModManager);
            IIniInstaller               iniIniInstaller  = new IniInstaller(Mod, ModInstallLog, p_tfmFileManager, null);
            IGameSpecificValueInstaller gviGameSpecificValueInstaller = GameMode.GetGameSpecificValueInstaller(Mod, ModInstallLog, p_tfmFileManager, new NexusFileUtil(EnvironmentInfo), null);

            InstallerGroup     ipgInstallers = new InstallerGroup(dfuDataFileUtility, mfiFileInstaller, iniIniInstaller, gviGameSpecificValueInstaller, PluginManager);
            BasicUninstallTask butTask       = new BasicUninstallTask(Mod, ipgInstallers, ModInstallLog, GameMode, ActiveMods);

            OnTaskStarted(butTask);

            bool booResult = butTask.Execute();

            if (mfiFileInstaller.InstallErrors.Count > 0)
            {
                p_strErrorMessage = Environment.NewLine + "The manager was unable to remove these files:" + Environment.NewLine;
                foreach (string strPath in mfiFileInstaller.InstallErrors)
                {
                    p_strErrorMessage += strPath + Environment.NewLine;
                }
            }

            mfiFileInstaller.FinalizeInstall();
            iniIniInstaller.FinalizeInstall();
            if (gviGameSpecificValueInstaller != null)
            {
                gviGameSpecificValueInstaller.FinalizeInstall();
            }

            return(booResult);
        }
Пример #3
0
        /// <summary>
        /// This executes the install script.
        /// </summary>
        /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
        /// <returns><c>true</c> if the script completed successfully;
        /// <c>false</c> otherwise.</returns>
        protected bool RunScript(TxFileManager p_tfmFileManager)
        {
            IModFileInstaller mfiFileInstaller = CreateFileInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);
            bool          booResult            = false;
            IIniInstaller iniIniInstaller      = null;
            IGameSpecificValueInstaller gviGameSpecificValueInstaller = null;

            if (Mod.HasInstallScript)
            {
                if (CheckScriptedModLog())
                {
                    booResult = RunBasicInstallScript(mfiFileInstaller, ActiveMods, LoadXMLModFilesToInstall());
                }
                else
                {
                    try
                    {
                        IDataFileUtil dfuDataFileUtility = new DataFileUtil(GameMode.GameModeEnvironmentInfo.InstallationPath);

                        iniIniInstaller = CreateIniInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);
                        gviGameSpecificValueInstaller = CreateGameSpecificValueInstaller(p_tfmFileManager, m_dlgOverwriteConfirmationDelegate);

                        InstallerGroup  ipgInstallers = new InstallerGroup(dfuDataFileUtility, mfiFileInstaller, iniIniInstaller, gviGameSpecificValueInstaller, PluginManager);
                        IScriptExecutor sexScript     = Mod.InstallScript.Type.CreateExecutor(Mod, GameMode, EnvironmentInfo, VirtualModActivator, ipgInstallers, UIContext);
                        sexScript.TaskStarted      += new EventHandler <EventArgs <IBackgroundTask> >(ScriptExecutor_TaskStarted);
                        sexScript.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(ScriptExecutor_TaskSetCompleted);
                        booResult = sexScript.Execute(Mod.InstallScript);
                    }
                    catch (Exception ex)
                    {
                        PopupErrorMessage     = ex.Message;
                        PopupErrorMessageType = "Error";
                    }

                    iniIniInstaller.FinalizeInstall();

                    if (gviGameSpecificValueInstaller != null)
                    {
                        gviGameSpecificValueInstaller.FinalizeInstall();
                    }
                }
            }
            else
            {
                booResult = RunBasicInstallScript(mfiFileInstaller, ActiveMods, null);
            }
            mfiFileInstaller.FinalizeInstall();
            return(booResult);
        }
Пример #4
0
        /// <summary>
        /// Runs the basic uninstall script.
        /// </summary>
        /// <remarks>
        /// A basic uninstall uninstalls all of the changes made when the mod was installed.
        /// </remarks>
        /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
        /// <returns><c>true</c> if the uninstallation was successful;
        /// <c>false</c> otherwise.</returns>
        protected bool RunBasicUninstallScript(TxFileManager p_tfmFileManager, out string p_strErrorMessage)
        {
            p_strErrorMessage = null;
            IDataFileUtil dfuDataFileUtility = new DataFileUtil(GameMode.GameModeEnvironmentInfo.InstallationPath);

            IModFileInstaller           mfiFileInstaller = new ModFileInstaller(GameMode.GameModeEnvironmentInfo, Mod, ModInstallLog, PluginManager, dfuDataFileUtility, p_tfmFileManager, null, GameMode.UsesPlugins, EnvironmentInfo);
            IIniInstaller               iniIniInstaller  = new IniInstaller(Mod, ModInstallLog, VirtualModActivator, p_tfmFileManager, null);
            IGameSpecificValueInstaller gviGameSpecificValueInstaller = GameMode.GetGameSpecificValueInstaller(Mod, ModInstallLog, p_tfmFileManager, new NexusFileUtil(EnvironmentInfo), null);

            InstallerGroup     ipgInstallers = new InstallerGroup(dfuDataFileUtility, mfiFileInstaller, iniIniInstaller, gviGameSpecificValueInstaller, PluginManager);
            BasicUninstallTask butTask       = new BasicUninstallTask(Mod, VirtualModActivator, ipgInstallers, ModInstallLog, GameMode, ActiveMods);

            OnTaskStarted(butTask);

            bool booResult = butTask.Execute();

            if (mfiFileInstaller.InstallErrors.Count > 0)
            {
                p_strErrorMessage = Environment.NewLine + "There were issues while installing/uninstalling this mod:" + Environment.NewLine;
                foreach (string strPath in mfiFileInstaller.InstallErrors)
                {
                    DetailsErrorMessage += strPath + Environment.NewLine;
                }

                PopupErrorMessage     = p_strErrorMessage;
                PopupErrorMessageType = butTask.strPopupErrorMessageType;
            }

            mfiFileInstaller.FinalizeInstall();
            iniIniInstaller.FinalizeInstall();
            if (gviGameSpecificValueInstaller != null)
            {
                gviGameSpecificValueInstaller.FinalizeInstall();
            }

            return(booResult);
        }
Пример #5
0
 // To be used internally by DummyDataFileUtilFactory
 // Use DummyDataFileUtilFactory.CreateDummyDataFileUtil() to instantiate
 internal DummyDataFileUtil(string installationPath, string gamePath, List <string> installationPaths)
 {
     m_gamePath     = gamePath;
     m_dataFileUtil = new DataFileUtil(installationPath);
     SearchPaths    = installationPaths;
 }