Exemple #1
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          = "Scanning mod archives for readme files...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_lstModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            foreach (IMod modMod in m_lstModList)
            {
                rmmReadMeManager.VerifyReadMeFile(tfmFileManager, modMod.Filename);
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
                if (m_booCancel)
                {
                    break;
                }
            }

            rmmReadMeManager.SaveReadMeConfig();

            return(null);
        }
        /// <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)
        {
            try
            {
                ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];
                OverallMessage          = "Starting purge downloads...";
                OverallProgress         = 0;
                OverallProgressStepSize = 1;
                ShowItemProgress        = false;
                OverallProgressMaximum  = DownloadTasksList.Count();

                Status = TaskStatus.Running;

                int i = 1;

                if (DownloadTasksList.Count > 0)
                {
                    foreach (AddModTask task in DownloadTasksList)
                    {
                        DownloadMonitor.PurgeDownload((AddModTask)task);
                        OverallMessage = "Purging the downloads: " + i + "/" + DownloadTasksList.Count();
                        StepOverallProgress();
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                this.Status      = TaskStatus.Error;
                this.ItemMessage = ("There was a problem: " + Environment.NewLine + ex.Message);
                return(null);
            }

            return(null);
        }
        /// <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          = "Disabling all the active mods...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_rolModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            foreach (IMod modMod in m_rolModList)
            {
                m_ivaVirtualModActivator.DisableMod(modMod);
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }
            }
            return(null);
        }
        /// <summary>
        /// Runs the managed updaters.
        /// </summary>
        /// <param name="p_lstModList">The mod list.</param>
        /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
        /// <returns>The background task that will run the updaters.</returns>
        public IBackgroundTask SetupReadMeManager(List <IMod> p_lstModList, ConfirmActionMethod p_camConfirm)
        {
            ReadMeSetupTask rmsReadMeManagerSetup = new ReadMeSetupTask(ReadMeManager, p_lstModList);

            rmsReadMeManagerSetup.Update(p_camConfirm);
            return(rmsReadMeManagerSetup);
        }
        /// <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          = "Deleting all the selected mods...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_rolModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            foreach (IMod modMod in m_rolModList)
            {
                OverallMessage = "Deleting: " + modMod.ModName;

                ModDeleter mddDeleter = InstallerFactory.CreateDelete(modMod, ActiveMods);
                mddDeleter.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(Deactivator_TaskSetCompleted);
                mddDeleter.Install();
                DeleteXMLInstalledFile(modMod);

                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }
            }
            return(null);
        }
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 /// <param name="p_ModManager">The current ModManager.</param>
 /// <param name="p_lstMods">The mod list.</param>
 /// <param name="p_intNewValue">The new category id.</param>
 public ModMigrationTask(MainFormVM p_fvmViewModel, ModManagerControl p_mmgModManagerControl, bool p_booMigrate, ConfirmActionMethod p_camConfirm)
 {
     ViewModel           = p_fvmViewModel;
     ModManagerControl   = p_mmgModManagerControl;
     m_booMigrate        = p_booMigrate;
     ConfirmActionMethod = p_camConfirm;
 }
Exemple #7
0
        /// <summary>
        /// Runs the managed updaters.
        /// </summary>
        /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
        /// <param name="p_booIsAutoCheck">Whether the check is automatic or user requested.</param>
        /// <returns>The background task that will run the updaters.</returns>
        public IBackgroundTask Update(ConfirmActionMethod p_camConfirm, bool p_booIsAutoCheck)
        {
            UpdateTask utkUpdaters = new UpdateTask(this, GameMode, EnvironmentInfo, p_booIsAutoCheck);

            utkUpdaters.Update(p_camConfirm);
            return(utkUpdaters);
        }
        /// <summary>
        /// Disables multiple mods.
        /// </summary>
        /// <param name="p_rolModList">The mod list.</param>
        /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
        /// <returns>The background task that will run the updaters.</returns>
        public IBackgroundTask DisableMultipleMods(List <IMod> p_rolModList, ConfirmActionMethod p_camConfirm)
        {
            DisableMultipleModsTask dmmDisableAllMods = new DisableMultipleModsTask(p_rolModList, VirtualModActivator);

            dmmDisableAllMods.Update(p_camConfirm);
            return(dmmDisableAllMods);
        }
Exemple #9
0
        /// <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)
        {
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            //TODO add game mode updaters
            OverallMessage          = "Updating...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;

            m_lstUpdaters.Clear();
            m_lstUpdaters.Add(new ProgrammeUpdater(EnvironmentInfo, m_booIsAutoCheck));
            //IEnumerable<IUpdater> enmUpdaters = GameMode.GetUpdaters();
            //if (enmUpdaters != null)
            //	m_lstUpdaters.AddRange(GameMode.GetUpdaters());
            OverallProgressMaximum = m_lstUpdaters.Count;

            foreach (IUpdater updUpdater in m_lstUpdaters)
            {
                ItemMessage                 = updUpdater.Message;
                ItemProgress                = updUpdater.Progress;
                ItemProgressMaximum         = updUpdater.ProgressMaximum;
                updUpdater.PropertyChanged += new PropertyChangedEventHandler(Updater_PropertyChanged);
                updUpdater.Confirm          = camConfirm;
                if (!updUpdater.Update())
                {
                    m_lstFailedUpdaters.Add(updUpdater);
                }
                StepOverallProgress();
                updUpdater.PropertyChanged -= new PropertyChangedEventHandler(Updater_PropertyChanged);
            }
            return(null);
        }
Exemple #10
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)
        {
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            OverallMessage          = "Updating mod categories...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = ModList.Count;

            foreach (IMod modMod in ModList)
            {
                if (m_booCancel)
                {
                    break;
                }
                ItemMessage  = modMod.ModName;
                ItemProgress = 1;
                ModManager.SwitchModCategory(modMod, CategoryId);
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
                ItemProgress = 0;
            }
            return(null);
        }
        /// <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          = "Deactivating all the active mods...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_rolModList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            foreach (IMod modMod in m_rolModList)
            {
                modMod.InstallDate = null;
                if (!m_iilInstallLog.ActiveMods.Contains(modMod))
                {
                    return(null);
                }
                ModUninstaller munUninstaller = m_mifModInstallerFactory.CreateUninstaller(modMod, m_rolModList);
                munUninstaller.Install();

                while (!munUninstaller.IsCompleted)
                {
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
            }
            return(null);
        }
Exemple #12
0
        /// <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          = String.Format("{0} all the managed plugins...", EnablePlugins ? "Activating" : "Disabling");
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = PluginList.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            foreach (Plugin plugin in PluginList)
            {
                if (EnablePlugins)
                {
                    APL.ActivatePlugin(plugin);
                }
                else
                {
                    APL.DeactivatePlugin(plugin);
                }

                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }
            }
            return(null);
        }
        /// <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);
        }
        /// <summary>
        /// Automatically sorts the managed plugins.
        /// </summary>
        /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
        /// <returns>The background task that will run the sorting.</returns>
        public IBackgroundTask AutoPluginSorting(ConfirmActionMethod p_camConfirm)
        {
            AutoPluginSortingTask pstPluginSortingTask = new AutoPluginSortingTask(GameMode, ManagedPlugins, p_camConfirm);

            pstPluginSortingTask.Update(p_camConfirm);
            return(pstPluginSortingTask);
        }
Exemple #15
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 /// <param name="p_ModManager">The current ModManager.</param>
 /// <param name="p_lstMods">The mod list.</param>
 /// <param name="p_intNewValue">The new category id.</param>
 public LinkActivationTask(IPluginManager p_pmgPluginManager, VirtualModActivator p_vmaVirtualModActivator, IMod p_modMod, bool p_booDisable, ConfirmActionMethod p_camConfirm)
 {
     PluginManager       = p_pmgPluginManager;
     VirtualModActivator = p_vmaVirtualModActivator;
     Mod                 = p_modMod;
     Disabling           = p_booDisable;
     ConfirmActionMethod = p_camConfirm;
 }
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 /// <param name="pluginManager">The current <see cref="IPluginManager"/>.</param>
 /// <param name="virtualModActivator">The <see cref="IVirtualModActivator"/></param>
 /// <param name="mod">The mod.</param>
 /// <param name="disable">Whether or not we're disabling the given mod.</param>
 /// <param name="confirmActionMethod">The delegate to call to confirm an action.</param>
 public LinkActivationTask(IPluginManager pluginManager, IVirtualModActivator virtualModActivator, IMod mod, bool disable, ConfirmActionMethod confirmActionMethod)
 {
     PluginManager       = pluginManager;
     VirtualModActivator = virtualModActivator;
     Mod                 = mod;
     Disabling           = disable;
     ConfirmActionMethod = confirmActionMethod;
 }
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public ActivateMultipleModsTask(List <IMod> p_lstModList, bool p_booAllowCancel, IInstallLog p_iilInstallLog, ModInstallerFactory p_mifModInstallerFactory, ConfirmActionMethod p_camConfirm, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
 {
     m_iilInstallLog                    = p_iilInstallLog;
     m_mifModInstallerFactory           = p_mifModInstallerFactory;
     m_lstModList                       = p_lstModList;
     m_camConfirm                       = p_camConfirm;
     m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate;
 }
Exemple #18
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 /// <param name="p_ModManager">The current ModManager.</param>
 /// <param name="p_lstMods">The mod list.</param>
 /// <param name="p_intNewValue">The new category id.</param>
 public AddProfileTask(ModManager p_mmgModManager, IModRepository p_mrModRepository, IEnvironmentInfo p_eiEnvironmentInfo, ProfileManager p_pmProfileManager, Uri p_uUri, ConfirmActionMethod p_camConfirm, string p_strLabel)
 {
     ModManager          = p_mmgModManager;
     ModRepository       = p_mrModRepository;
     EnvironmentInfo     = p_eiEnvironmentInfo;
     ProfileManager      = p_pmProfileManager;
     m_Uri               = p_uUri;
     ConfirmActionMethod = p_camConfirm;
 }
Exemple #19
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public RestoreBackupTask(VirtualModActivator p_vmaActivator, ModManager p_ModManager, ProfileManager p_pmProfileManager, IEnvironmentInfo p_EnvironmentInfo, string p_strBackupFile, bool p_booPurgeFolders, ConfirmActionMethod p_camConfirm)
 {
     m_camConfirm        = p_camConfirm;
     VirtualModActivator = p_vmaActivator;
     ModManager          = p_ModManager;
     EnvironmentInfo     = p_EnvironmentInfo;
     BackupFile          = p_strBackupFile;
     PurgeFolders        = p_booPurgeFolders;
     ProfileManager      = p_pmProfileManager;
 }
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public CreateBackupTask(VirtualModActivator p_vmaActivator, ModManager p_ModManager, IEnvironmentInfo p_EnvironmentInfo, PluginManagerVM p_pmPluginManagerVM, IPluginManager p_pmPluginManager, ProfileManager p_pmProfileManager, string p_strSelectedPath, BackupManager p_bmBackupManager, ConfirmActionMethod p_camConfirm)
 {
     m_camConfirm        = p_camConfirm;
     VirtualModActivator = p_vmaActivator;
     ModManager          = p_ModManager;
     EnvironmentInfo     = p_EnvironmentInfo;
     SelectedPath        = p_strSelectedPath;
     BackupManager       = p_bmBackupManager;
     PluginManagerVM     = p_pmPluginManagerVM;
     PluginManager       = p_pmPluginManager;
     ProfileManager      = p_pmProfileManager;
 }
 /// <summary>
 /// Runs the managed updaters.
 /// </summary>
 /// <param name="p_lstModList">The list of mods we need to update.</param>
 /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
 /// <param name="p_booOverrideCategorySetup">Whether to force a global update.</param>
 /// <returns>The background task that will run the updaters.</returns>
 public IBackgroundTask UpdateMods(List <IMod> p_lstModList, ConfirmActionMethod p_camConfirm, bool p_booOverrideCategorySetup)
 {
     if (ModRepository.UserStatus != null)
     {
         ModUpdateCheckTask mutModUpdateCheck = new ModUpdateCheckTask(AutoUpdater, ModRepository, p_lstModList, p_booOverrideCategorySetup);
         mutModUpdateCheck.Update(p_camConfirm);
         return(mutModUpdateCheck);
     }
     else
     {
         throw new Exception("Login required");
     }
 }
Exemple #22
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);
        }
Exemple #23
0
        /// <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)
        {
            List <string>       ModList    = new List <string>();
            List <IMod>         ModCheck   = new List <IMod>();
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            string ModInstallDirectory = CurrentGameModeModDirectory.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).Trim(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;

            OverallMessage          = "Updating categories info: setup search..";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = false;
            OverallProgressMaximum  = 2;

            OverallMessage = "Retrieving the categories list... 1/2";
            StepOverallProgress();
            try
            {
                List <CategoriesInfo> lstCategories = ModRepository.GetCategories(ModRepository.RemoteGameId);

                int i = 1;
                if (lstCategories.Count > 0)
                {
                    foreach (CategoriesInfo category in lstCategories)
                    {
                        OverallMessage = "Saving the categories list... " + i + "/" + lstCategories.Count();
                        StepOverallProgress();

                        IModCategory modCategory = CategoryManager.FindCategory(category.Id);
                        if ((modCategory != null) && (modCategory.Id != 0))
                        {
                            CategoryManager.RenameCategory(modCategory.Id, category.Name);
                        }
                        else
                        {
                            CategoryManager.AddCategory(new ModCategory(category.Id, category.Name, category.Name));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(null);
        }
Exemple #24
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public ProfileSwitchSetupTask(ReadOnlyObservableList <IMod> modsToDeactivate, List <IMod> modsToInstall, IProfileManager profileManager, IModProfile profileToInstall,
                               IModProfile profileToSwitch, IInstallLog installLog, ModInstallerFactory modInstallerFactory, VirtualModActivator virtualModActivator, string scriptedLogPath, bool filesOnly,
                               ConfirmActionMethod confirmActionMethod, ConfirmItemOverwriteDelegate overwriteConfirmationDelegate)
 {
     _installLog                    = installLog;
     _modInstallerFactory           = modInstallerFactory;
     _modsToDeactivate              = modsToDeactivate;
     VirtualModActivator            = virtualModActivator;
     _logPath                       = scriptedLogPath;
     _filesOnly                     = filesOnly;
     _profileToInstall              = profileToInstall;
     _profileToSwitch               = profileToSwitch;
     _profileManager                = profileManager;
     _modsToInstall                 = modsToInstall;
     _confirmMethod                 = confirmActionMethod;
     _overwriteConfirmationDelegate = overwriteConfirmationDelegate;
 }
        /// <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          = "Toggling mod update checks...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            OverallProgressMaximum  = m_hashMods.Count;
            ShowItemProgress        = false;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            foreach (IMod modMod in m_hashMods)
            {
                ModInfo mifUpdatedMod = new ModInfo(modMod);
                if (m_booEnable == null)
                {
                    mifUpdatedMod.UpdateChecksEnabled = !modMod.UpdateChecksEnabled;
                }
                else
                {
                    if (modMod.UpdateChecksEnabled == m_booEnable.Value)
                    {
                        continue;
                    }
                    else
                    {
                        mifUpdatedMod.UpdateChecksEnabled = m_booEnable.Value;
                    }
                }
                modMod.UpdateInfo(mifUpdatedMod, false);

                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }
            }

            return(null);
        }
        /// <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)
        {
            try
            {
                ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];
                OverallMessage          = "Starting missing mods download...";
                OverallProgress         = 0;
                OverallProgressStepSize = 1;
                ShowItemProgress        = false;
                OverallProgressMaximum  = MissingMods.Count();

                Status = TaskStatus.Running;

                int i = 1;

                if (MissingMods.Count > 0)
                {
                    foreach (string URI in MissingMods)
                    {
                        if (m_booCancel)
                        {
                            break;
                        }
                        OverallMessage = "Adding the Mods to download: " + i + "/" + MissingMods.Count();
                        StepOverallProgress();
                        i++;

                        ModManager.AddMod(URI, ConfirmOverwriteCallback);
                        Thread.Sleep(100);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Status      = TaskStatus.Error;
                this.ItemMessage = ("There was a problem communicating with the Nexus server: " + Environment.NewLine + ex.Message);
                return(null);
            }

            return(null);
        }
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <param name="p_booIsAutoCheck">Whether the check is automatic or user requested.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask Update(ConfirmActionMethod p_camConfirm, bool p_booIsAutoCheck)
		{
			UpdateTask utkUpdaters = new UpdateTask(GameMode, EnvironmentInfo, p_booIsAutoCheck);
			utkUpdaters.Update(p_camConfirm);
			return utkUpdaters;
		}
		/// <summary>
		/// Starts the update.
		/// </summary>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		public void Update(ConfirmActionMethod p_camConfirm)
		{
			Start(p_camConfirm);
		}
 /// <summary>
 /// Starts the update.
 /// </summary>
 /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
 public void Update(ConfirmActionMethod p_camConfirm)
 {
     Start(p_camConfirm);
 }
 public IBackgroundTask ManageMultiplePluginsTask(List<Plugin> p_lstPlugins, bool p_booEnable, ConfirmActionMethod p_camConfirm)
 {
     return null;
 }
 public IBackgroundTask FixConfigFiles(List<string> p_lstFiles, IModProfile p_mprProfile, ConfirmActionMethod p_camConfirm)
 {
     throw new NotImplementedException();
 }
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		public ToggleUpdateWarningTask(HashSet<IMod> p_hashMods, bool? p_booEnable, ConfirmActionMethod p_camConfirm)
		{
			m_hashMods = p_hashMods;
			m_booEnable = p_booEnable;
		}
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_lstModList">The list of mods we need to update.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <param name="p_booOverrideCategorySetup">Whether to force a global update.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask UpdateMods(List<IMod> p_lstModList, ConfirmActionMethod p_camConfirm, bool p_booOverrideCategorySetup)
		{
			if (ModRepository.UserStatus != null)
			{
				ModUpdateCheckTask mutModUpdateCheck = new ModUpdateCheckTask(AutoUpdater, ModRepository, p_lstModList, p_booOverrideCategorySetup);
				mutModUpdateCheck.Update(p_camConfirm);
				return mutModUpdateCheck;
			}
			else
				throw new Exception("Login required");
		}
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_rolModList">The mod list.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask DeactivateMultipleMods(ReadOnlyObservableList<IMod> p_rolModList, ConfirmActionMethod p_camConfirm)
		{
			DeactivateMultipleModsTask dmmDeactivateAllMods = new DeactivateMultipleModsTask(p_rolModList, this.InstallationLog, this.InstallerFactory);
			dmmDeactivateAllMods.Update(p_camConfirm);
			return dmmDeactivateAllMods;
		}
 /// <summary>
 /// Runs the managed updaters.
 /// </summary>
 /// <param name="p_lstModList">The list of mods we need to update.</param>
 /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
 /// <param name="p_booOverrideCategorySetup">Whether to force a global update.</param>
 /// <returns>The background task that will run the updaters.</returns>
 public void AsyncUpdateMods(List<IMod> p_lstModList, ConfirmActionMethod p_camConfirm, bool p_booOverrideCategorySetup)
 {
     ModUpdateCheckTask mutModUpdateCheck = new ModUpdateCheckTask(AutoUpdater, ModRepository, p_lstModList, p_booOverrideCategorySetup);
     AsyncUpdateModsTask(mutModUpdateCheck, p_camConfirm);
 }
        public async Task AsyncUpdateModsTask(ModUpdateCheckTask p_mutModUpdateCheck, ConfirmActionMethod p_camConfirm)
        {
            int intRetry = 0;

            while (intRetry < 5)
            {
                await Task.Delay(3000);
                if (LoginTask.LoggedIn)
                {
                    p_mutModUpdateCheck.Update(p_camConfirm);
                    UpdateCheckStarted(this, new EventArgs<IBackgroundTask>(p_mutModUpdateCheck));
                    break;
                }
                else
                    intRetry++;
            }
        }
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_ModManager">The Mod Manager.</param>
		/// <param name="p_lstMods">The list of mods to update.</param>
		/// <param name="p_intNewValue">The new category id value.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask Update(ModManager p_ModManager, IList<IMod> p_lstMods, Int32 p_intNewValue, ConfirmActionMethod p_camConfirm)
		{
			CategorySwitchTask cstCategorySwitch = new CategorySwitchTask(p_ModManager, p_lstMods, p_intNewValue);
			cstCategorySwitch.Update(p_camConfirm);
			return cstCategorySwitch;
		}
		/// <summary>
		/// Automatically sorts the managed plugins.
		/// </summary>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the sorting.</returns>
		public IBackgroundTask AutoPluginSorting(ConfirmActionMethod p_camConfirm)
		{
			AutoPluginSortingTask pstPluginSortingTask = new AutoPluginSortingTask(GameMode, ManagedPlugins, p_camConfirm);
			pstPluginSortingTask.Update(p_camConfirm);
			return pstPluginSortingTask;
		}
Exemple #39
0
        /// <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)
        {
            List <string>       ModList    = new List <string>();
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            OverallMessage          = "Updating mods info: setup search...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgress            = 0;
            ItemProgressStepSize    = 1;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = 1;

            OverallProgressMaximum = m_lstModList.Count * 2;
            ItemProgressMaximum    = (m_lstModList.Count > 250) ? 250 : m_lstModList.Count;

            for (int i = 0; i < m_lstModList.Count; i++)
            {
                string modID          = String.Empty;
                Int32  isEndorsed     = 0;
                string strLastVersion = String.Empty;
                ItemMessage = m_lstModList[i].ModName;

                if (m_booCancel)
                {
                    break;
                }

                if (!String.IsNullOrEmpty(m_lstModList[i].Id))
                {
                    modID          = m_lstModList[i].Id;
                    isEndorsed     = m_lstModList[i].IsEndorsed == true ? 1 : (m_lstModList[i].IsEndorsed == false ? -1 : 0);
                    strLastVersion = m_lstModList[i].LastKnownVersion;
                }
                else
                {
                    try
                    {
                        IModInfo mifInfo = ModRepository.GetModInfoForFile(m_lstModList[i].Filename);

                        if (mifInfo != null)
                        {
                            modID = mifInfo.Id;
                            m_lstModList[i].Id = modID;
                            strLastVersion     = m_lstModList[i].LastKnownVersion;
                            AutoUpdater.AddNewVersionNumberForMod(m_lstModList[i], mifInfo);
                        }
                    }
                    catch (RepositoryUnavailableException)
                    {
                        //the repository is not available, so don't bother
                    }
                }

                if (!String.IsNullOrEmpty(modID))
                {
                    if ((m_booOverrideCategorySetup) || (String.IsNullOrEmpty(strLastVersion)))
                    {
                        ModList.Add(String.Format("{0}", modID));
                    }
                    else
                    {
                        ModList.Add(String.Format("{0}|{1}|{2}", modID, m_lstModList[i].HumanReadableVersion, isEndorsed));
                    }
                }

                if (ItemProgress < ItemProgressMaximum)
                {
                    StepItemProgress();
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }

                // Prevents the repository request string from becoming too long.
                if (ModList.Count == 250)
                {
                    CheckForModListUpdate(ModList);
                    ModList.Clear();
                    OverallMessage      = "Updating mods info: setup search...";
                    ItemProgress        = 0;
                    ItemProgressMaximum = (m_lstModList.Count == 250) ? 1 : (m_lstModList.Count - (i + 1));
                }
            }

            if (!m_booCancel && (ModList.Count > 0))
            {
                CheckForModListUpdate(ModList);
            }

            m_lstModList.Clear();

            return(null);
        }
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_hashMods">The hash of mods.</param>
		/// <param name="p_booEnable">Enable/Disable/Toggle.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask ManageMultiplePluginsTask(List<Plugin> p_lstPlugins, bool p_booEnable, ConfirmActionMethod p_camConfirm)
		{
			ManageMultiplePluginsTask mptManageMultiplePlugins = new ManageMultiplePluginsTask(p_lstPlugins, ActivePluginLog, p_booEnable);
			mptManageMultiplePlugins.Update(p_camConfirm);
			return mptManageMultiplePlugins;
		}
        /// <summary>
        /// Runs the managed updaters.
        /// </summary>
        /// <param name="p_hashMods">The hash of mods.</param>
        /// <param name="p_booEnable">Enable/Disable/Toggle.</param>
        /// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
        /// <returns>The background task that will run the updaters.</returns>
        public IBackgroundTask ManageMultiplePluginsTask(List <Plugin> p_lstPlugins, bool p_booEnable, ConfirmActionMethod p_camConfirm)
        {
            ManageMultiplePluginsTask mptManageMultiplePlugins = new ManageMultiplePluginsTask(p_lstPlugins, ActivePluginLog, p_booEnable);

            mptManageMultiplePlugins.Update(p_camConfirm);
            return(mptManageMultiplePlugins);
        }
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		public AutoPluginSortingTask(IGameMode p_gmdCurrentGameMode, IList<Plugin> p_lstPlugins, ConfirmActionMethod p_camConfirm)
		{
			GameMode = p_gmdCurrentGameMode;
			Plugins = p_lstPlugins;
		}
 public IBackgroundTask AutoPluginSorting(ConfirmActionMethod p_camConfirm)
 {
     return null;
 }
Exemple #44
0
        /// <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)
        {
            try
            {
                ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];
                OverallMessage          = "Checking the Profile Online Integrity...";
                OverallProgress         = 0;
                OverallProgressStepSize = 1;
                ShowItemProgress        = false;
                OverallProgressMaximum  = 1;

                List <ProfileMissingModInfo> lstMissingInfo   = null;
                Dictionary <string, string>  dctMissingMods   = new Dictionary <string, string>();
                Dictionary <string, string>  dctNewDownloadID = new Dictionary <string, string>();

                if (ModProfile != null)
                {
                    lstMissingInfo = ModRepository.GetMissingFiles(ModRepository.RemoteGameId, int.Parse(ModProfile.OnlineID));
                }

                foreach (KeyValuePair <string, string> kvp in MissingModsList)
                {
                    IVirtualModInfo Mod = ModProfile.ModList.Find(x => x.DownloadId == kvp.Value);

                    if (Mod != null)
                    {
                        ProfileMissingModInfo pmModInfo = lstMissingInfo.Find(x => x.FileId.ToString().Equals(kvp.Value));

                        if (pmModInfo != null)
                        {
                            if ((!string.IsNullOrEmpty(pmModInfo.NewFileId.ToString())) && (pmModInfo.NewFileId.ToString() != "-1"))
                            {
                                dctNewDownloadID.Add(kvp.Key, pmModInfo.NewFileId.ToString());
                                dctMissingMods.Add(kvp.Key, @"@nxm://" + GameModeID + "/mods/" + Mod.ModId + "/files/" + pmModInfo.NewFileId.ToString());
                            }
                            else if (string.IsNullOrEmpty(pmModInfo.ModName))
                            {
                                dctMissingMods.Add(kvp.Key, null);
                            }
                            else if (pmModInfo.NewFileId.ToString().Equals("-1", StringComparison.OrdinalIgnoreCase))
                            {
                                dctMissingMods.Add(kvp.Key, null);
                            }
                        }
                        else
                        {
                            dctMissingMods.Add(kvp.Key, @"nxm://" + GameModeID + "/mods/" + Mod.ModId + "/files/" + Mod.DownloadId);
                        }
                    }
                }


                ProfileManager.UpdateProfileDownloadId(ModProfile, dctNewDownloadID);

                return(dctMissingMods);
            }
            catch (Exception ex)
            {
                return("ERROR - There was a problem communicating with the Nexus server: " + Environment.NewLine + ex.Message);
            }

            return(null);
        }
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_hashMods">The hash of mods.</param>
		/// <param name="p_booEnable">Enable/Disable/Toggle.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask ToggleUpdateWarningTask(HashSet<IMod> p_hashMods, bool? p_booEnable, ConfirmActionMethod p_camConfirm)
		{
			ToggleUpdateWarningTask tuwToggleWarning = new ToggleUpdateWarningTask(p_hashMods, p_booEnable, p_camConfirm);
			tuwToggleWarning.Update(p_camConfirm);
			return tuwToggleWarning;
		}
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_lstModList">The mod list.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask SetupReadMeManager(List<IMod> p_lstModList, ConfirmActionMethod p_camConfirm)
		{
			ReadMeSetupTask rmsReadMeManagerSetup = new ReadMeSetupTask(ReadMeManager, p_lstModList);
			rmsReadMeManagerSetup.Update(p_camConfirm);
			return rmsReadMeManagerSetup;
		}