The class the encapsulates managing mods.
The list of managed mods needs to be centralized to ensure integrity; having multiple mod managers, each with a potentially different list of managed mods, would be disastrous. As such, this object is a singleton to help enforce that policy. Note, however, that the singleton nature of the manager is not meant to provide global access to the object. As such, there is no static accessor to retrieve the singleton instance. Instead, the Initialize method returns the only instance that should be used.
Beispiel #1
0
		/// <summary>
		/// Initializes the singleton intances of the mod manager.
		/// </summary>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_mrpModRepository">The mod repository from which to get mods and mod metadata.</param>
		/// <param name="p_dmrMonitor">The download monitor to use to track task progress.</param>
		/// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
		/// of supported <see cref="IModFormat"/>s.</param>
		/// <param name="p_mrgModRegistry">The <see cref="ModRegistry"/> that contains the list
		/// of managed <see cref="IMod"/>s.</param>
		/// <param name="p_futFileUtility">The file utility class.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
		/// <param name="p_ilgInstallLog">The install log tracking mod activations for the current game mode.</param>
		/// <param name="p_pmgPluginManager">The plugin manager to use to work with plugins.</param>
		/// <returns>The initialized mod manager.</returns>
		/// <exception cref="InvalidOperationException">Thrown if the mod manager has already
		/// been initialized.</exception>
        public static ModManager Initialize(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IModRepository p_mrpModRepository, DownloadMonitor p_dmrMonitor, ActivateModsMonitor p_ammMonitor, IModFormatRegistry p_frgFormatRegistry, ModRegistry p_mrgModRegistry, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager)	
		{
			if (m_mmgCurrent != null)
				throw new InvalidOperationException("The Mod Manager has already been initialized.");
            m_mmgCurrent = new ModManager(p_gmdGameMode, p_eifEnvironmentInfo, p_mrpModRepository, p_dmrMonitor, p_ammMonitor, p_frgFormatRegistry, p_mrgModRegistry, p_futFileUtility, p_scxUIContext, p_ilgInstallLog, p_pmgPluginManager);
			return m_mmgCurrent;
		}
		/// <summary>
		/// A simple constructor that initializes the factory with the required dependencies.
		/// </summary>
		/// <param name="p_gmdGameMode">The game mode for which the created installer will be installing mods.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_futFileUtility">The file utility class.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
		/// <param name="p_ilgInstallLog">The install log that tracks mod install info
		/// for the current game mode.</param>
		/// <param name="p_pmgPluginManager">The plugin manager to use to work with plugins.</param>
        public ModInstallerFactory(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, ModManager p_mmModManager)
		{
			m_gmdGameMode = p_gmdGameMode;
			m_eifEnvironmentInfo = p_eifEnvironmentInfo;
			m_futFileUtility = p_futFileUtility;
			m_scxUIContext = p_scxUIContext;
			m_ilgInstallLog = p_ilgInstallLog;
			m_pmgPluginManager = p_pmgPluginManager;
            m_mmModManager = p_mmModManager;
		}
		/// <summary>
		/// Starts up the IPC listner channel to wait for message from other instances.
		/// </summary>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_gmdGameModeInfo">The descriptor of the game mode for which mods are being managed.</param>
		/// <param name="p_mmgModManager">The mod manager to use to manage mods.</param>
		/// <param name="p_frmMainForm">The main application form.</param>
		public static IMessager InitializeListener(EnvironmentInfo p_eifEnvironmentInfo, IGameModeDescriptor p_gmdGameModeInfo, ModManager p_mmgModManager, MainForm p_frmMainForm)
		{
			if (m_schMessagerChannel != null)
				throw new InvalidOperationException("The IPC Channel has already been created as a SERVER.");

			string strUri = String.Format("{0}-{1}IpcServer", p_eifEnvironmentInfo.Settings.ModManagerName, p_gmdGameModeInfo.ModeId);
			m_schMessagerChannel = new IpcServerChannel(strUri);
			ChannelServices.RegisterChannel(m_schMessagerChannel, true);
			MessagerServer msgMessager = new MessagerServer(p_mmgModManager, p_frmMainForm);
			string strEndpoint = String.Format("{0}Listener", p_gmdGameModeInfo.ModeId);
			RemotingServices.Marshal(msgMessager, strEndpoint, typeof(IMessager));

			strUri += "/" + strEndpoint;
			string strTraceInfo = String.Format("Setting up listener on {0} at {1}", strUri, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
			Trace.TraceInformation(strTraceInfo);

			return msgMessager;
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_amnDownloadMonitor">The Download manager to use to manage the monitored activities.</param>
		/// <param name="p_setSettings">The application and user settings.</param>
		public DownloadMonitorVM(DownloadMonitor p_amnDownloadMonitor, ISettings p_setSettings, ModManager p_mmgModManager, IModRepository p_mrpModRepository)
		{
			DownloadMonitor = p_amnDownloadMonitor;
			Settings = p_setSettings;
			m_mmgModManager = p_mmgModManager;
			ModRepository = p_mrpModRepository;
			ModRepository.UserStatusUpdate += new System.EventHandler(ModRepository_UserStatusUpdate);
			DownloadMonitor.PropertyChanged += new PropertyChangedEventHandler(ActiveTasks_PropertyChanged);

			CancelTaskCommand = new Command<AddModTask>("Cancel", "Cancels the selected Download.", CancelTask);
			RemoveTaskCommand = new Command<AddModTask>("Remove", "Removes the selected Download.", RemoveTask);
			PauseTaskCommand = new Command<AddModTask>("Pause", "Pauses the selected Download.", PauseTask);
			ResumeTaskCommand = new Command<AddModTask>("Resume", "Resumes the selected Download.", ResumeTask);
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_ModManager">The current ModManager.</param>
		public LoginFormTask(ModManager p_mmModManager)
		{
			Status = TaskStatus.Paused;
			ModManager = p_mmModManager;
		}
		/// <summary>
		/// A simpell constructor that initializes the object with the given services.
		/// </summary>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info for the current game mode.</param>
		/// <param name="p_aplActivePluginLog">The <see cref="ActivePluginLog"/> tracking plugin activations for the current game mode.</param>
		/// <param name="p_polPluginOrderLog">The <see cref="IPluginOrderLog"/> tracking plugin order for the current game mode.</param>
		/// <param name="p_mrpModRepository">The repository we are logging in to.</param>
		/// <param name="p_mmgModManager">The mod manager to use to manage mods.</param>
		/// <param name="p_pmgPluginManager">The manager to use to manage plugins.</param>
		/// <param name="p_amtMonitor">The download monitor to use to manage the monitored activities.</param>
		/// <param name="p_umgUpdateManager">The update manager to use to perform updates.</param>
        public ServiceManager(IInstallLog p_ilgModInstallLog, ActivePluginLog p_aplActivePluginLog, IPluginOrderLog p_polPluginOrderLog, IModRepository p_mrpModRepository, ModManager p_mmgModManager, IPluginManager p_pmgPluginManager, DownloadMonitor p_amtMonitor, ActivateModsMonitor p_ammMonitor, UpdateManager p_umgUpdateManager)
		{
			ModInstallLog = p_ilgModInstallLog;
			ActivePluginLog = p_aplActivePluginLog;
			PluginOrderLog = p_polPluginOrderLog;
			ModRepository = p_mrpModRepository;
			ModManager = p_mmgModManager;
			PluginManager = p_pmgPluginManager;
			DownloadMonitor = p_amtMonitor;
			UpdateManager = p_umgUpdateManager;
            ActivateModsMonitor = p_ammMonitor;
		}
Beispiel #7
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 CategorySwitchTask(ModManager p_ModManager, IList <IMod> p_lstMods, Int32 p_intNewValue)
 {
     ModManager = p_ModManager;
     ModList    = p_lstMods;
     CategoryId = p_intNewValue;
 }
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_amnActivateModsMonitor">The Activate Mods  manager to use to manage the monitored activities.</param>
		/// <param name="p_setSettings">The application and user settings.</param>
		public ActivateModsMonitorVM(ActivateModsMonitor p_amnActivateModsMonitor, ISettings p_setSettings, ModManager p_mmgModManager)
		{
			ActivateModsMonitor = p_amnActivateModsMonitor;
			Settings = p_setSettings;
			m_mmgModManager = p_mmgModManager;
			ActivateModsMonitor.PropertyChanged += new PropertyChangedEventHandler(ActiveTasks_PropertyChanged);
		}
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_gmdGameMode">The current game mode.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_ilgModInstallLog">The install log that tracks mod install info
 /// for the current game mode</param>
 /// <param name="p_pmgPluginManager">The plugin manager.</param>
 /// <param name="p_rolActiveMods">The list of active mods.</param>
 public ModUninstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ReadOnlyObservableList <IMod> p_rolActiveMods, ModManager p_mmModManager)
 {
     Mod             = p_modMod;
     GameMode        = p_gmdGameMode;
     EnvironmentInfo = p_eifEnvironmentInfo;
     ModInstallLog   = p_ilgModInstallLog;
     PluginManager   = p_pmgPluginManager;
     ActiveMods      = p_rolActiveMods;
     m_mmModManager  = p_mmModManager;
 }
Beispiel #10
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 /// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
 /// <param name="p_pmgPluginManager">The plugin manager.</param>
 /// <param name="p_dfuDataFileUtility">The utility class to use to work with data files.</param>
 /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
 /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
 /// <param name="p_UsesPlugins">Whether the file is a mod or a plugin.</param>
 public ModFileInstaller(IGameModeEnvironmentInfo p_gmiGameModeInfo, IMod p_modMod, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, IDataFileUtil p_dfuDataFileUtility, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, bool p_UsesPlugins, ModManager p_mmModManager)
 {
     GameModeInfo                       = p_gmiGameModeInfo;
     Mod                                = p_modMod;
     InstallLog                         = p_ilgInstallLog;
     PluginManager                      = p_pmgPluginManager;
     DataFileUtility                    = p_dfuDataFileUtility;
     TransactionalFileManager           = p_tfmFileManager;
     m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate ?? ((s, b, m) => OverwriteResult.No);
     IsPlugin                           = p_UsesPlugins;
     m_mmModManager                     = p_mmModManager;
 }
		/// <summary>
		/// A simple constructor the initializes the object with the required dependencies.
		/// </summary>
		/// <param name="p_mmgModManager">The mod manager to use to manage mods.</param>
		/// <param name="p_frmMainForm">The main form of the client for which we listening for messages.</param>
		private MessagerServer(ModManager p_mmgModManager, MainForm p_frmMainForm)
		{
			ModManager = p_mmgModManager;
			MainForm = p_frmMainForm;
		}
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_gmdGameMode">The current game mode.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
 /// <param name="p_ilgModInstallLog">The install log that tracks mod install info
 /// for the current game mode</param>
 /// <param name="p_pmgPluginManager">The plugin manager.</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>
 public ModInstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods, ModManager p_mmModManager)
 {
     Mod             = p_modMod;
     GameMode        = p_gmdGameMode;
     EnvironmentInfo = p_eifEnvironmentInfo;
     FileUtility     = p_futFileUtility;
     UIContext       = p_scxUIContext;
     ModInstallLog   = p_ilgModInstallLog;
     PluginManager   = p_pmgPluginManager;
     m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate;
     ActiveMods     = p_rolActiveMods;
     m_mmModManager = p_mmModManager;
 }
Beispiel #13
0
		/// <summary>
		/// This disposes of the singleton object, allowing it to be re-initialized.
		/// </summary>
		public void Release()
		{
			ModAdditionQueue.Dispose();
			ModAdditionQueue = null;
			m_mmgCurrent = null;
		}
 /// <summary>
 /// A simple constructor that initializes the factory with the required dependencies.
 /// </summary>
 /// <param name="p_gmdGameMode">The game mode for which the created installer will be installing mods.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
 /// <param name="p_ilgInstallLog">The install log that tracks mod install info
 /// for the current game mode.</param>
 /// <param name="p_pmgPluginManager">The plugin manager to use to work with plugins.</param>
 public ModInstallerFactory(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, ModManager p_mmModManager)
 {
     m_gmdGameMode        = p_gmdGameMode;
     m_eifEnvironmentInfo = p_eifEnvironmentInfo;
     m_futFileUtility     = p_futFileUtility;
     m_scxUIContext       = p_scxUIContext;
     m_ilgInstallLog      = p_ilgInstallLog;
     m_pmgPluginManager   = p_pmgPluginManager;
     m_mmModManager       = p_mmModManager;
 }
 /// <summary>
 /// A sipmle constructor that initializes that object with the required dependencies.
 /// </summary>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_mmgModManager">The mod manager for which we are queing mods to be added.</param>
 public AddModQueue(IEnvironmentInfo p_eifEnvironmentInfo, ModManager p_mmgModManager)
 {
     m_eifEnvironmentInfo = p_eifEnvironmentInfo;
     m_mmgModManager      = p_mmgModManager;
 }
		/// <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>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public DeleteMultipleModsTask(ReadOnlyObservableList <IMod> p_rolModList, VirtualModActivator p_ivaVirtualModActivator, ModRegistry p_ManagedModRegistry, ModManager p_ModManager, ReadOnlyObservableList <IMod> p_rolActiveMods, ModInstallerFactory p_InstallerFactory)
 {
     m_ivaVirtualModActivator = p_ivaVirtualModActivator;
     m_rolModList             = p_rolModList;
     ManagedModRegistry       = p_ManagedModRegistry;
     ModManager       = p_ModManager;
     ActiveMods       = p_rolActiveMods;
     InstallerFactory = p_InstallerFactory;
 }
		/// <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 CategorySwitchTask(ModManager p_ModManager, IList<IMod> p_lstMods, Int32 p_intNewValue)
		{
			ModManager = p_ModManager;
			ModList = p_lstMods;
			CategoryId = p_intNewValue;
		}
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_futFileUtility">The file utility class.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</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>
        public ModInstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods, ModManager p_mmModManager)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			FileUtility = p_futFileUtility;
			UIContext = p_scxUIContext;
			ModInstallLog = p_ilgModInstallLog;
			PluginManager = p_pmgPluginManager;
			m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate;
			ActiveMods = p_rolActiveMods;
            m_mmModManager = p_mmModManager;
		}
		/// <summary>
		/// Uninstalls mods that have been manually removed since the last time the mod manager
		/// ran.
		/// </summary>
		/// <param name="p_gmdGameMode">The game mode currently being managed.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_mmgModManager">The mod manager to use to uninstall any missing mods.</param>
		protected bool UninstallMissingMods(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, ModManager p_mmgModManager)
		{
			Trace.TraceInformation("Uninstalling missing Mods...");
			Trace.Indent();
			foreach (IMod modMissing in new List<IMod>(p_mmgModManager.ActiveMods))
			{
				if (!File.Exists(modMissing.Filename))
				{
					Trace.TraceInformation("{0} is missing...", modMissing.Filename);
					Trace.Indent();

					//look for another version of the mod
					List<IMod> lstInactiveMods = new List<IMod>();
					foreach (IMod modRegistered in p_mmgModManager.ManagedMods)
						if (!p_mmgModManager.ActiveMods.Contains(modRegistered))
							lstInactiveMods.Add(modRegistered);
					ModMatcher mmcMatcher = new ModMatcher(lstInactiveMods, false);
					IMod modNewVersion = mmcMatcher.FindAlternateVersion(modMissing, true);
					if (modNewVersion != null)
					{
						Trace.TraceInformation("Found alternate version...");
						string strUpgradeMessage = String.Format("'{0}' cannot be found. " + Environment.NewLine +
										"However, a different version has been detected. The installed, missing, version is {1}; the new version is {2}." + Environment.NewLine +
										"You can either upgrade the mod or uninstall it. If you Cancel, {3} will close and you will " +
										"have to put the Mod ({4}) back in the mods folder." + Environment.NewLine +
										"Would you like to upgrade the mod?", modMissing.ModName, modMissing.HumanReadableVersion, modNewVersion.HumanReadableVersion, p_eifEnvironmentInfo.Settings.ModManagerName, modMissing.Filename);

						switch ((DialogResult)ShowMessage(new ViewMessage(strUpgradeMessage, "Missing Mod", ExtendedMessageBoxButtons.Yes | ExtendedMessageBoxButtons.No | ExtendedMessageBoxButtons.Cancel, MessageBoxIcon.Warning)))
						{
							case DialogResult.Yes:
								Trace.TraceInformation("Upgrading.");
								IBackgroundTaskSet btsUpgrader = p_mmgModManager.ForceUpgrade(modMissing, modNewVersion, ConfirmItemOverwrite);
								WaitForSet(btsUpgrader, true);
								Trace.Unindent();
								continue;
							case DialogResult.Cancel:
								Trace.TraceInformation("Aborting.");
								Trace.Unindent();
								Trace.Unindent();
								return false;
							case DialogResult.No:
								break;
							default:
								throw new Exception(String.Format("Unexpected value for cofnirmation of upgrading missing mod {0}.", modMissing.ModName));
						}
					}

					string strMessage = String.Format("'{0}' cannot be found. " + Environment.NewLine + Environment.NewLine +
										"This could be caused by setting the wrong 'Mods' folder or an old config file being used." + Environment.NewLine + Environment.NewLine +
										"If you haven't deleted or moved any of your mods on your hard-drive and they're still on your hard-drive somewhere then select YES and input the proper location of your Mods folder." + Environment.NewLine + Environment.NewLine +
										"If you select NO {1} will automatically uninstall the missing mod's files." + Environment.NewLine + Environment.NewLine +
										"NOTE: The mods folder is where NMM stores your mod archives, it is not the same location as your game's mod folder.", modMissing.Filename, p_eifEnvironmentInfo.Settings.ModManagerName);
					if ((DialogResult)ShowMessage(new ViewMessage(strMessage, "Missing Mod", ExtendedMessageBoxButtons.Yes | ExtendedMessageBoxButtons.No, MessageBoxIcon.Warning)) == DialogResult.No)
					{
						Trace.TraceInformation("Removing.");
						IBackgroundTaskSet btsDeactivator = p_mmgModManager.DeactivateMod(modMissing, p_mmgModManager.ActiveMods);
						WaitForSet(btsDeactivator, true);
					}
					else
					{
						Status = TaskStatus.Retrying;
						Trace.TraceInformation("Reset Paths.");
						Trace.Unindent();
						Trace.Unindent();
						return false;
					}

					Trace.TraceInformation("Uninstalled.");
					Trace.Unindent();
				}
			}
			Trace.Unindent();
			return true;
		}
		/// <summary>
		/// Upgrade mods that have been manually replaced since the last time the mod
		/// manager ran.
		/// </summary>
		/// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
		/// <param name="p_mmgModManager">The mod manager to use to upgrade any replaced mods.</param>
		protected void UpgradeMismatchedVersionMods(IInstallLog p_ilgInstallLog, ModManager p_mmgModManager)
		{
			UpgradeMismatchedVersionScanner uvsScanner = new UpgradeMismatchedVersionScanner(p_ilgInstallLog, p_mmgModManager, ConfirmMismatchedVersionModUpgrade, ConfirmItemOverwrite);
			uvsScanner.TaskStarted += new EventHandler<EventArgs<IBackgroundTask>>(TaskSet_TaskStarted);
			uvsScanner.Scan();
			WaitForSet(uvsScanner, false);
			uvsScanner.TaskStarted -= new EventHandler<EventArgs<IBackgroundTask>>(TaskSet_TaskStarted);
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_mmdModManager">The mod manager to use to manage mods.</param>
		/// <param name="p_setSettings">The application and user settings.</param>
		/// <param name="p_thmTheme">The current theme to use for the views.</param>
		public ModManagerVM(ModManager p_mmdModManager, ISettings p_setSettings, Theme p_thmTheme)
		{
			ModManager = p_mmdModManager;
			ModRepository = p_mmdModManager.ModRepository;
			Settings = p_setSettings;
			CurrentTheme = p_thmTheme;
			CategoryManager = new CategoryManager(ModManager.CurrentGameModeModDirectory, "categories");
			if (this.CategoryManager.IsValidPath)
			{
				this.CategoryManager.LoadCategories(String.Empty);
				m_booIsCategoryInitialized = true;
			}
			else
				this.CategoryManager.Backup();
			AddModCommand = new Command<string>("Add Mod", "Adds a mod to the manager.", AddMod);
			DeleteModCommand = new Command<IMod>("Delete Mod", "Deletes the selected mod.", DeleteMod);
			ActivateModCommand = new Command<List<IMod>>("Activate Mod", "Activates the selected mods.", ActivateMods);
			DeactivateModCommand = new Command<List<IMod>>("Deactivate Mod", "Deactivates the selected mod.", DeactivateMods);
			TagModCommand = new Command<IMod>("Tag Mod", "Gets missing mod info.", TagMod);

			ModManager.UpdateCheckStarted += new EventHandler<EventArgs<IBackgroundTask>>(ModManager_UpdateCheckStarted);
		}
 /// <summary>
 /// This disposes of the singleton object, allowing it to be re-initialized.
 /// </summary>
 public void Release()
 {
     ModAdditionQueue.Dispose();
     ModAdditionQueue = null;
     m_mmgCurrent     = null;
 }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
        public ModUninstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ReadOnlyObservableList<IMod> p_rolActiveMods, ModManager p_mmModManager)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			ModInstallLog = p_ilgModInstallLog;
			PluginManager = p_pmgPluginManager;
			ActiveMods = p_rolActiveMods;
            m_mmModManager = p_mmModManager;
		}
        /// <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)
        {
            string strOverallRoot = "Fixing config file";

            OverallMessage          = "Parsing config file...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = false;
            int i = 0;

            ConfirmActionMethod camConfirm = (ConfirmActionMethod)args[0];

            foreach (string FilePath in ConfigFilePaths)
            {
                List <string>          lstAddedModInfo = new List <string>();
                List <IVirtualModLink> lstVirtualLinks = new List <IVirtualModLink>();
                List <IVirtualModInfo> lstVirtualMods  = new List <IVirtualModInfo>();

                if (File.Exists(FilePath))
                {
                    XDocument docVirtual;
                    using (var sr = new StreamReader(FilePath))
                    {
                        docVirtual = XDocument.Load(sr);
                    }

                    strOverallRoot = string.Format("Fixing config file {0}/{1}", ++i, ConfigFilePaths.Count());

                    try
                    {
                        XElement xelModList = docVirtual.Descendants("modList").FirstOrDefault();
                        if ((xelModList != null) && xelModList.HasElements)
                        {
                            OverallProgressMaximum = xelModList.Elements("modId").Count();

                            foreach (XElement xelMod in xelModList.Elements("modInfo"))
                            {
                                string strModId             = xelMod.Attribute("modId").Value;
                                string strDownloadId        = string.Empty;
                                string strUpdatedDownloadId = string.Empty;
                                string strNewFileName       = string.Empty;
                                string strFileVersion       = string.Empty;

                                if (OverallProgress < OverallProgressMaximum)
                                {
                                    StepOverallProgress();
                                }
                                OverallMessage = string.Format("{0} - element: {1}/{2}", strOverallRoot, OverallProgress, OverallProgressMaximum);

                                try
                                {
                                    strDownloadId = xelMod.Attribute("downloadId").Value;
                                }
                                catch { }

                                try
                                {
                                    strUpdatedDownloadId = xelMod.Attribute("updatedDownloadId").Value;
                                }
                                catch { }

                                string strModName     = xelMod.Attribute("modName").Value;
                                string strModFileName = xelMod.Attribute("modFileName").Value;

                                if (lstAddedModInfo.Contains(strModFileName, StringComparer.InvariantCultureIgnoreCase))
                                {
                                    continue;
                                }

                                try
                                {
                                    strNewFileName = xelMod.Attribute("modNewFileName").Value;
                                }
                                catch { }

                                string strModFilePath = xelMod.Attribute("modFilePath").Value;

                                try
                                {
                                    strFileVersion = xelMod.Attribute("FileVersion").Value;
                                }
                                catch
                                {
                                    IMod mod = ModManager.GetModByFilename(strModFileName);
                                    strFileVersion = mod.HumanReadableVersion;
                                }

                                VirtualModInfo vmiMod = new VirtualModInfo(strModId, strDownloadId, strUpdatedDownloadId, strModName, strModFileName, strNewFileName, strModFilePath, strFileVersion);

                                bool booNoFileLink = true;

                                foreach (XElement xelLink in xelMod.Elements("fileLink"))
                                {
                                    string strRealPath    = xelLink.Attribute("realPath").Value;
                                    string strVirtualPath = xelLink.Attribute("virtualPath").Value;
                                    Int32  intPriority    = 0;
                                    try
                                    {
                                        intPriority = Convert.ToInt32(xelLink.Element("linkPriority").Value);
                                    }
                                    catch { }
                                    bool booActive = false;
                                    try
                                    {
                                        booActive = Convert.ToBoolean(xelLink.Element("isActive").Value);
                                    }
                                    catch { }

                                    if (booNoFileLink)
                                    {
                                        booNoFileLink = false;
                                        lstVirtualMods.Add(vmiMod);
                                        lstAddedModInfo.Add(strModFileName);
                                    }

                                    lstVirtualLinks.Add(new VirtualModLink(strRealPath, strVirtualPath, intPriority, booActive, vmiMod));
                                }
                            }
                        }
                    }
                    catch { }
                }

                if ((lstVirtualLinks.Count > 0) && (lstVirtualMods.Count > 0))
                {
                    OverallMessage = "Saving fixed config file...";
                    VirtualModActivator.SaveModList(FilePath, lstVirtualMods, lstVirtualLinks);
                }
            }

            return(ModProfile);
        }
			/// <summary>
			/// A sipmle constructor that initializes that object with the required dependencies.
			/// </summary>
			/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
			/// <param name="p_mmgModManager">The mod manager for which we are queing mods to be added.</param>
			public AddModQueue(IEnvironmentInfo p_eifEnvironmentInfo, ModManager p_mmgModManager)
			{
				m_eifEnvironmentInfo = p_eifEnvironmentInfo;
				m_mmgModManager = p_mmgModManager;
			}
		/// <summary>
		/// A simple constructor that initializes the object with the given dependencies.
		/// </summary>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_gmrInstalledGames">The registry of insalled games.</param>
		/// <param name="p_gmdGameMode">The game mode currently being managed.</param>
		/// <param name="p_mrpModRepository">The repository we are logging in to.</param>
		/// <param name="p_dmtMonitor">The download monitor to use to track task progress.</param>
		/// <param name="p_umgUpdateManager">The update manager to use to perform updates.</param>
		/// <param name="p_mmgModManager">The <see cref="ModManager"/> to use to manage mods.</param>
		/// <param name="p_pmgPluginManager">The <see cref="PluginManager"/> to use to manage plugins.</param>
        public MainFormVM(IEnvironmentInfo p_eifEnvironmentInfo, GameModeRegistry p_gmrInstalledGames, IGameMode p_gmdGameMode, IModRepository p_mrpModRepository, DownloadMonitor p_dmtMonitor, ActivateModsMonitor p_ammMonitor, UpdateManager p_umgUpdateManager, ModManager p_mmgModManager, IPluginManager p_pmgPluginManager)
		{
			EnvironmentInfo = p_eifEnvironmentInfo;
			GameMode = p_gmdGameMode;
			GameMode.GameLauncher.GameLaunching += new CancelEventHandler(GameLauncher_GameLaunching);
			ModManager = p_mmgModManager;
			ModRepository = p_mrpModRepository;
			UpdateManager = p_umgUpdateManager;
			ModManagerVM = new ModManagerVM(p_mmgModManager, p_eifEnvironmentInfo.Settings, p_gmdGameMode.ModeTheme);
			DownloadMonitorVM = new DownloadMonitorVM(p_dmtMonitor, p_eifEnvironmentInfo.Settings, p_mmgModManager, p_mrpModRepository);
			ModActivationMonitor = p_ammMonitor;
			ActivateModsMonitorVM = new ActivateModsMonitorVM(p_ammMonitor, p_eifEnvironmentInfo.Settings, p_mmgModManager);
			if (GameMode.UsesPlugins)
				PluginManagerVM = new PluginManagerVM(p_pmgPluginManager, p_eifEnvironmentInfo.Settings, p_gmdGameMode, p_ammMonitor);

			HelpInfo = new HelpInformation(p_eifEnvironmentInfo);

			GeneralSettingsGroup gsgGeneralSettings = new GeneralSettingsGroup(p_eifEnvironmentInfo);
			foreach (IModFormat mftFormat in p_mmgModManager.ModFormats)
				gsgGeneralSettings.AddFileAssociation(mftFormat.Extension, mftFormat.Name);

			ModOptionsSettingsGroup mosModOptions = new ModOptionsSettingsGroup(p_eifEnvironmentInfo);

			List<ISettingsGroupView> lstSettingGroups = new List<ISettingsGroupView>();
			lstSettingGroups.Add(new GeneralSettingsPage(gsgGeneralSettings));
			lstSettingGroups.Add(new ModOptionsPage(mosModOptions));
			DownloadSettingsGroup dsgDownloadSettings = new DownloadSettingsGroup(p_eifEnvironmentInfo, ModRepository);
			lstSettingGroups.Add(new DownloadSettingsPage(dsgDownloadSettings));

			if (p_gmdGameMode.SettingsGroupViews != null)
				lstSettingGroups.AddRange(p_gmdGameMode.SettingsGroupViews);

			SettingsFormVM = new SettingsFormVM(p_gmdGameMode, p_eifEnvironmentInfo, lstSettingGroups);

			UpdateCommand = new Command("Update", String.Format("Update {0}", EnvironmentInfo.Settings.ModManagerName), UpdateProgramme);
			LogoutCommand = new Command("Logout", "Logout", Logout);

			List<Command> lstChangeGameModeCommands = new List<Command>();
			List<IGameModeDescriptor> lstSortedModes = new List<IGameModeDescriptor>(p_gmrInstalledGames.RegisteredGameModes);
			lstSortedModes.Sort((x, y) => x.Name.CompareTo(y.Name));
			foreach (IGameModeDescriptor gmdInstalledGame in lstSortedModes)
			{
				string strId = gmdInstalledGame.ModeId;
				string strName = gmdInstalledGame.Name;
				string strDescription = String.Format("Change game to {0}", gmdInstalledGame.Name);
				Image imgCommandIcon = new Icon(gmdInstalledGame.ModeTheme.Icon, 32, 32).ToBitmap();
				lstChangeGameModeCommands.Add(new Command(strId, strName, strDescription, imgCommandIcon, () => ChangeGameMode(strId), true));
			}
			lstChangeGameModeCommands.Add(new Command("Change Default Game...", "Change Default Game", () => ChangeGameMode(CHANGE_DEFAULT_GAME_MODE)));
			lstChangeGameModeCommands.Add(new Command("Rescan Installed Games...", "Rescan Installed Games", () => ChangeGameMode(RESCAN_INSTALLED_GAMES)));
			ChangeGameModeCommands = lstChangeGameModeCommands;
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_dfuDataFileUtility">The utility class to use to work with data files.</param>
		/// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
		/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
		/// <param name="p_UsesPlugins">Whether the file is a mod or a plugin.</param>
        public ModFileInstaller(IGameModeEnvironmentInfo p_gmiGameModeInfo, IMod p_modMod, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, IDataFileUtil p_dfuDataFileUtility, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, bool p_UsesPlugins, ModManager p_mmModManager)
		{
			GameModeInfo = p_gmiGameModeInfo;
			Mod = p_modMod;
			InstallLog = p_ilgInstallLog;
			PluginManager = p_pmgPluginManager;
			DataFileUtility = p_dfuDataFileUtility;
			TransactionalFileManager = p_tfmFileManager;
			m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate ?? ((s, b, m) => OverwriteResult.No);
			IsPlugin = p_UsesPlugins;
            m_mmModManager = p_mmModManager;
		}