Install() public method

Installs the mod.
public Install ( ) : void
return void
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="p_objArgs">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] p_objArgs)
        {
            OverallMessage          = "Installing selected mods...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_lstModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            foreach (IMod modMod in m_lstModList)
            {
                OverallMessage = "Installing selected mods: " + modMod.ModName;

                if (m_iilInstallLog.ActiveMods.Contains(modMod))
                {
                    continue;
                }

                ModInstaller minInstaller = m_mifModInstallerFactory.CreateInstaller(modMod, m_dlgOverwriteConfirmationDelegate, null);
                minInstaller.Install();

                while (!minInstaller.IsCompleted)
                {
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Reactivates the given mod.
        /// </summary>
        /// <remarks>
        /// A reactivation is an upgrade of a mod to itself. It re-runs the activation,
        /// without changing the installed precedence of its files and installed values.
        /// </remarks>
        /// <param name="p_modMod">The mod to reactivate.</param>
        /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
        /// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
        public IBackgroundTaskSet Reactivate(IMod p_modMod, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
        {
            ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(p_modMod, p_modMod, p_dlgOverwriteConfirmationDelegate);

            muiUpgrader.Install();
            return(muiUpgrader);
        }
Esempio n. 3
0
        /// <summary>
        /// Forces an upgrade from one mod to another.
        /// </summary>
        /// <remarks>
        /// No checks as to whether the two mods are actually related are performed. The new mod is reactivated
        /// as if it were the old mod, and the old mod is replaced by the new mod.
        /// </remarks>
        /// <param name="p_modOldMod">The mod from which to upgrade.</param>
        /// <param name="p_modNewMod">The mod to which to upgrade.</param>
        /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
        /// <exception cref="InvalidOperationException">Thrown if <paramref name="p_modNewMod"/> is already active.</exception>
        /// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
        public IBackgroundTaskSet ForceUpgrade(IMod p_modOldMod, IMod p_modNewMod, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
        {
            if (InstallationLog.ActiveMods.Contains(p_modNewMod))
            {
                throw new InvalidOperationException(String.Format("Cannot upgrade to a mod that is already active. (Trying to upgrade {0} {1} to {2} {3})", p_modOldMod.ModName, p_modOldMod.HumanReadableVersion, p_modNewMod.ModName, p_modNewMod.HumanReadableVersion));
            }
            ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(p_modOldMod, p_modNewMod, p_dlgOverwriteConfirmationDelegate);

            muiUpgrader.Install();
            return(muiUpgrader);
        }
Esempio n. 4
0
        private bool InstallMods(object[] args)
        {
            int modCounter = 0;

            if (_modsToInstall != null && _modsToInstall.Count > 0)
            {
                modCounter = _modsToInstall.Count;
            }

            OverallMessage          = string.Format("Profile Switch Setup: Installing selected mods ({0})...", modCounter);
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = _modsToInstall.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            if (_profileToInstall != null && _profileManager != null)
            {
                _profileManager.SetCurrentProfile(_profileToInstall);
            }


            foreach (IMod modMod in _modsToInstall)
            {
                OverallMessage = "Profile Switch Setup: Installing selected mods: " + modMod.ModName;

                if (_installLog.ActiveMods.Contains(modMod))
                {
                    continue;
                }

                ModInstaller minInstaller = _modInstallerFactory.CreateInstaller(modMod, _overwriteConfirmationDelegate, null);
                minInstaller.Install();

                while (!minInstaller.IsCompleted)
                {
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
            }

            if (_profileToSwitch != null && _profileManager != null)
            {
                _profileManager.SetCurrentProfile(_profileToSwitch);
            }

            return(true);
        }