コード例 #1
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to activate.</param>
        public void ActivateMod(IMod p_modMod)
        {
            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (String.IsNullOrEmpty(strErrorMessage))
            {
                IBackgroundTaskSet btsInstall = ModManager.ActivateMod(p_modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                if (btsInstall != null)
                {
                    ModManager.ActivateModsMonitor.AddActivity(btsInstall);
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #2
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_lstMod">The mods to activate.</param>
        public void ActivateMods(List <IMod> p_lstMod)
        {
            if (VirtualModActivator.MultiHDMode && !UacUtil.IsElevated)
            {
                MessageBox.Show("It looks like MultiHD mode is enabled but you're not running NMM as Administrator, you will be unable to install/activate mods or switch profiles." + Environment.NewLine + Environment.NewLine + "Close NMM and run it as Administrator to fix this.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string strMessage;
            bool   booRequiresConfig = ModManager.GameMode.RequiresExternalConfig(out strMessage);

            if (booRequiresConfig)
            {
                ExtendedMessageBox.Show(this.ParentForm, strMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (String.IsNullOrEmpty(strErrorMessage))
            {
                foreach (IMod modMod in p_lstMod)
                {
                    if (!ActiveMods.Contains(modMod))
                    {
                        IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                        if (btsInstall != null)
                        {
                            ModManager.ModActivationMonitor.AddActivity(btsInstall);
                        }
                    }
                    else
                    {
                        EnableMod(modMod);
                    }
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #3
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_lstMod">The mods to activate.</param>
        public void ActivateMods(List <IMod> p_lstMod)
        {
            if (VirtualModActivator.MultiHDMode && !UacUtil.IsElevated)
            {
                MessageBox.Show("It looks like MultiHD mode is enabled but you're not running NMM as Administrator, you will be unable to install/activate mods or switch profiles." + Environment.NewLine + Environment.NewLine + "Close NMM and run it as Administrator to fix this.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string strMessage;
            bool   booRequiresConfig = ModManager.GameMode.RequiresExternalConfig(out strMessage);

            if (booRequiresConfig)
            {
                ExtendedMessageBox.Show(this.ParentForm, strMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (string.IsNullOrEmpty(strErrorMessage))
            {
                foreach (IMod modMod in p_lstMod)
                {
                    if (!ActiveMods.Contains(modMod))
                    {
                        ModMatcher mmcMatcher    = new ModMatcher(ModManager.InstallationLog.ActiveMods, true);
                        IMod       modOldVersion = mmcMatcher.FindAlternateVersion(modMod, true);

                        if (modOldVersion != null)
                        {
                            string strUpgradeMessage = "A different version of {0} has been detected. The installed version is {1}, the new version is {2}. Would you like to upgrade?" + Environment.NewLine + "Selecting No will install the new Mod normally.";
                            strUpgradeMessage = String.Format(strUpgradeMessage, modOldVersion.ModName, modOldVersion.HumanReadableVersion, modMod.HumanReadableVersion);
                            switch (MessageBox.Show(strUpgradeMessage, "Upgrade", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                                ReinstallMod(modOldVersion, modMod);
                                break;

                            case DialogResult.No:
                                IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                                if (btsInstall != null)
                                {
                                    ModManager.ModActivationMonitor.AddActivity(btsInstall);
                                }
                                break;

                            case DialogResult.Cancel:
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                            if (btsInstall != null)
                            {
                                ModManager.ModActivationMonitor.AddActivity(btsInstall);
                            }
                        }
                    }
                    else
                    {
                        EnableMod(modMod);
                    }
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }