This installs mods.
Inheritance: ModInstallerBase
        /// <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);
        }
Exemple #2
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="args">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] args)
        {
            OverallMessage          = "Installing selected mods...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_lstModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[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);
        }
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <remarks>
        /// The given mod is either installed or upgraded, as appropriate.
        /// </remarks>
        /// <param name="p_modMod">The mod to install.</param>
        /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param>
        /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
        /// <param name="p_rolActiveMods">The list of active mods.</param>
        /// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
        public IBackgroundTaskSet Activate(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods, bool p_booOverrideUpgrade)
        {
            ModMatcher           mmcMatcher    = new ModMatcher(InstallationLog.ActiveMods, true);
            IMod                 modOldVersion = mmcMatcher.FindAlternateVersion(p_modMod, true);
            ConfirmUpgradeResult curAction     = ConfirmUpgradeResult.NormalActivation;

            if (!p_booOverrideUpgrade)
            {
                curAction = (modOldVersion == null) ? ConfirmUpgradeResult.NormalActivation : p_dlgUpgradeConfirmationDelegate(modOldVersion, p_modMod);
            }

            switch (curAction)
            {
            case ConfirmUpgradeResult.Upgrade:
                ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(modOldVersion, p_modMod, p_dlgOverwriteConfirmationDelegate);
                return(muiUpgrader);

            case ConfirmUpgradeResult.NormalActivation:
                ModInstaller minInstaller = InstallerFactory.CreateInstaller(p_modMod, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods);
                return(minInstaller);

            case ConfirmUpgradeResult.Cancel:
                return(null);

            default:
                throw new Exception(String.Format("Unrecognized value for ConfirmUpgradeResult: {0}", curAction));
            }
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
		/// <summary>
		/// Removes the given task (the task is already in queue or running).
		/// </summary>
		/// <param name="p_tskTask">BasicInstallTask task to remove.</param>
		public void RemoveUselessTask(ModInstaller p_tskTask)
		{
			ActivateModsMonitor.RemoveUselessTask(p_tskTask);
		}
		/// <summary>
		/// Removes the given task.
		/// </summary>
		/// <param name="p_tskTask">BasicInstallTask task to remove.</param>
		public void RemoveSelectedTask(ModInstaller p_tskTask)
		{
			if (ActivateModsMonitor.CanRemoveSelected(p_tskTask))
			{
				if (p_tskTask.IsCompleted)
					ActivateModsMonitor.RemoveTask(p_tskTask);
				else if (p_tskTask.IsQueued)
					ActivateModsMonitor.RemoveQueuedTask(p_tskTask);
			}
		}
		/// <summary>
		/// Removes the given task.
		/// </summary>
		/// <param name="p_tskTask">BasicInstallTask task to remove.</param>
		public void RemoveQueuedTask(ModInstaller p_tskTask)
		{
			if (ActivateModsMonitor.CanRemoveQueued(p_tskTask))
				ActivateModsMonitor.RemoveQueuedTask(p_tskTask);
		}
		/// <summary>
		/// Determines if the given <see cref="BasicInstallTask"/> selected can be removed from
		/// the monitor.
		/// </summary>
		/// <param name="p_tskTask">The task for which it is to be determined
		/// if it can be removed from the monitor.</param>
		/// <returns><c>true</c> if the p_tskTask can be removed;
		/// <c>false</c> otherwise.</returns>
		public bool CanRemoveSelected(ModInstaller p_tskTask)
		{
			if (p_tskTask.IsQueued || p_tskTask.IsCompleted)
				return true;
			else
				return false;
		}
		/// <summary>
		/// Determines if the given <see cref="BasicInstallTask"/> queued can be removed from
		/// the monitor.
		/// </summary>
		/// <param name="p_tskTask">The task for which it is to be determined
		/// if it can be removed from the monitor.</param>
		/// <returns><c>true</c> if the p_tskTask can be removed;
		/// <c>false</c> otherwise.</returns>
		public bool CanRemoveQueued(ModInstaller p_tskTask)
		{
			return p_tskTask.IsQueued;
		}
		/// <summary>
		/// Determines if the given <see cref="BasicInstallTask"/> can be removed from
		/// the monitor.
		/// </summary>
		/// <param name="p_tskTask">The task for which it is to be determined
		/// if it can be removed from the monitor.</param>
		/// <returns><c>true</c> if the p_tskTask can be removed;
		/// <c>false</c> otherwise.</returns>
		public bool CanRemove(ModInstaller p_tskTask)
		{
			return p_tskTask.IsCompleted;
		}
		/// <summary>
		/// Removes a useless task (the task is already in queue or running).
		/// </summary>
		public void RemoveUselessTask(ModInstaller p_tskTask)
		{
			m_oclTasks.Remove(p_tskTask);
		}
		/// <summary>
		/// Removes a task from the monitor.
		/// </summary>
		/// <remarks>
		/// Tasks can only be removed if they are not running.
		/// </remarks>
		/// <param name="p_tskTask">The task to remove.</param>
		public void RemoveQueuedTask(ModInstaller p_tskTask)
		{
			m_oclTasks.Remove(p_tskTask);
		}