A registry of all mods being managed by the mod manager.
Esempio n. 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;
		}
Esempio n. 2
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </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_mamMonitor">The mod activation 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_mdrManagedModRegistry">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>
 private ModManager(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IModRepository p_mrpModRepository, DownloadMonitor p_dmrMonitor, ModActivationMonitor p_mamMonitor, IModFormatRegistry p_frgFormatRegistry, ModRegistry p_mdrManagedModRegistry, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager)
 {
     GameMode                 = p_gmdGameMode;
     EnvironmentInfo          = p_eifEnvironmentInfo;
     m_rmmReadMeManager       = new ReadMeManager(EnvironmentInfo.Settings.ModFolder[GameMode.ModeId]);
     ModRepository            = p_mrpModRepository;
     FormatRegistry           = p_frgFormatRegistry;
     ManagedModRegistry       = p_mdrManagedModRegistry;
     InstallationLog          = p_ilgInstallLog;
     m_vmaVirtualModActivator = new VirtualModActivator(this, p_pmgPluginManager, p_gmdGameMode, p_ilgInstallLog, p_eifEnvironmentInfo, EnvironmentInfo.Settings.ModFolder[GameMode.ModeId]);
     m_vmaVirtualModActivator.Initialize();
     InstallerFactory     = new ModInstallerFactory(p_gmdGameMode, p_eifEnvironmentInfo, p_futFileUtility, p_scxUIContext, p_ilgInstallLog, p_pmgPluginManager, m_vmaVirtualModActivator);
     DownloadMonitor      = p_dmrMonitor;
     ModActivationMonitor = p_mamMonitor;
     ModAdditionQueue     = new AddModQueue(p_eifEnvironmentInfo, this);
     AutoUpdater          = new AutoUpdater(p_mrpModRepository, p_mdrManagedModRegistry, p_eifEnvironmentInfo);
     LoginTask            = new AuthenticationFormTask(this);
 }
Esempio n. 3
0
        /// <summary>
        /// Searches for mods in the specified path, and loads
        /// any mods that are found into a registry.
        /// </summary>
        /// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
        /// of supported <see cref="IModFormat"/>s.</param>
        /// <param name="p_strSearchPath">The path in which to search for mod format assemblies.</param>
        /// <param name="p_booRecurse">Whether to check sub folders of <paramref name="p_strSearchPath"/> for mods.</param>
        /// <param name="p_gmdGameMode">The game mode for which to discover mods.</param>
        /// <param name="p_strExcludedSubDirectories">The list of subdirectories not to examine for mods.</param>
        /// <returns>A registry containing all of the discovered mods.</returns>
        public static ModRegistry DiscoverManagedMods(IModFormatRegistry p_frgFormatRegistry, IModCacheManager p_frgCacheManager, string p_strSearchPath, bool p_booRecurse, IEnvironmentInfo p_eiEnvironmentInfo, IGameMode p_gmdGameMode, params string[] p_strExcludedSubDirectories)
        {
            Trace.TraceInformation("Discovering Managed Mods...");
            Trace.Indent();

            Trace.TraceInformation("Looking in: {0}", p_strSearchPath);

            List <string> lstExludedPaths = new List <string>();

            for (Int32 i = 0; i < p_strExcludedSubDirectories.Length; i++)
            {
                lstExludedPaths.Add((p_strExcludedSubDirectories[i].Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar).ToLower());
            }

            ModRegistry mdrRegistry = new ModRegistry(p_frgFormatRegistry, p_gmdGameMode);

            string[]      strMods     = Directory.GetFiles(p_strSearchPath, "*", p_booRecurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
            IMod          modMod      = null;
            List <string> modList     = new List <String>();
            bool          booExcluded = false;

            foreach (string strMod in strMods)
            {
                string strModPath = strMod.ToLower();
                booExcluded = false;

                if (strModPath.EndsWith(".meta"))
                {
                    continue;
                }

                foreach (string strExclusion in lstExludedPaths)
                {
                    if (strModPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).StartsWith(strExclusion))
                    {
                        booExcluded = true;
                        break;
                    }
                }
                if (booExcluded)
                {
                    continue;
                }
                Trace.TraceInformation("Found: {0}", strMod);

                try
                {
                    string strCachePath = p_frgCacheManager.GetCacheFilePath(strMod);
                    modMod = mdrRegistry.CreateMod(strMod, strCachePath, p_gmdGameMode, p_eiEnvironmentInfo);
                }
                catch
                {
                    modList.Add(strMod);
                    modMod = null;
                }

                if (modMod == null)
                {
                    continue;
                }
                mdrRegistry.m_oclRegisteredMods.Add(modMod);
                Trace.Indent();
                Trace.TraceInformation("Registered.");
                Trace.Unindent();
            }

            p_eiEnvironmentInfo.Settings.CacheOverhaulSetup = true;
            p_eiEnvironmentInfo.Settings.Save();

            if (modList.Count > 0)
            {
                string strErrorMessage = "Error loading the following mods: " + Environment.NewLine;
                foreach (string modstr in modList)
                {
                    strErrorMessage += modstr + Environment.NewLine;
                }
                MessageBox.Show(strErrorMessage, "Mod loading error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Trace.Unindent();
            return(mdrRegistry);
        }
Esempio n. 4
0
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_gmdGameMode">The game mode for which mods are being managed.</param>
		/// <param name="p_rmmReadMeManager">The ReadMe Manager info.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_mrgModRegistry">The <see cref="ModRegistry"/> that contains the list of managed <see cref="IMod"/>s.</param>
		/// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
		/// of supported <see cref="IModFormat"/>s.</param>
		/// <param name="p_mrpModRepository">The mod repository from which to get mods and mod metadata.</param>
		/// <param name="p_uriPath">The path to the mod to add.</param>
		/// <param name="p_cocConfirmOverwrite">The delegate to call to resolve conflicts with existing files.</param>
		public AddModTask(IGameMode p_gmdGameMode, ReadMeManager p_rmmReadMeManager, IEnvironmentInfo p_eifEnvironmentInfo, ModRegistry p_mrgModRegistry, IModFormatRegistry p_frgFormatRegistry, IModRepository p_mrpModRepository, Uri p_uriPath, ConfirmOverwriteCallback p_cocConfirmOverwrite)
		{
			m_gmdGameMode = p_gmdGameMode;
			m_eifEnvironmentInfo = p_eifEnvironmentInfo;
			m_mrgModRegistry = p_mrgModRegistry;
			m_mfrModFormatRegistry = p_frgFormatRegistry;
			m_mrpModRepository = p_mrpModRepository;
			m_uriPath = p_uriPath;
			m_cocConfirmOverwrite = p_cocConfirmOverwrite;
			m_rmmReadMeManager = p_rmmReadMeManager;
			m_intLocalID = m_intCounter++;
		}
Esempio n. 5
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_mamMonitor">The mod activation 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, ModActivationMonitor p_mamMonitor, 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_mamMonitor, p_frgFormatRegistry, p_mrgModRegistry, p_futFileUtility, p_scxUIContext, p_ilgInstallLog, p_pmgPluginManager);
     return(m_mmgCurrent);
 }
Esempio n. 6
0
		/// <summary>
		/// Searches for mods in the specified path, and loads
		/// any mods that are found into a registry.
		/// </summary>
		/// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
		/// of supported <see cref="IModFormat"/>s.</param>
		/// <param name="p_strSearchPath">The path in which to search for mod format assemblies.</param>
		/// <param name="p_booRecurse">Whether to check sub folders of <paramref name="p_strSearchPath"/> for mods.</param>
		/// <param name="p_gmdGameMode">The game mode for which to discover mods.</param>
		/// <param name="p_strExcludedSubDirectories">The list of subdirectories not to examine for mods.</param>
		/// <returns>A registry containing all of the discovered mods.</returns>
		public static ModRegistry DiscoverManagedMods(IModFormatRegistry p_frgFormatRegistry, IModCacheManager p_frgCacheManager, string p_strSearchPath, bool p_booRecurse, IGameMode p_gmdGameMode, params string[] p_strExcludedSubDirectories)
		{
			Trace.TraceInformation("Discovering Managed Mods...");
			Trace.Indent();

			Trace.TraceInformation("Looking in: {0}", p_strSearchPath);

			List<string> lstExludedPaths = new List<string>();
			for (Int32 i = 0; i < p_strExcludedSubDirectories.Length; i++)
				lstExludedPaths.Add((p_strExcludedSubDirectories[i].Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).Trim(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar).ToLower());

			ModRegistry mdrRegistry = new ModRegistry(p_frgFormatRegistry, p_gmdGameMode);
			string[] strMods = Directory.GetFiles(p_strSearchPath, "*", p_booRecurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
			IMod modMod = null;
			List<string> modList = new List<String>();
			bool booExcluded = false;
			foreach (string strMod in strMods)
			{
				string strModPath = strMod.ToLower();
				booExcluded = false;
				foreach (string strExclusion in lstExludedPaths)
					if (strModPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).StartsWith(strExclusion))
					{
						booExcluded = true;
						break;
					}
				if (booExcluded)
					continue;
				Trace.TraceInformation("Found: {0}", strMod);

				try
				{
					string strCachePath = p_frgCacheManager.GetCacheFilePath(strMod);
					modMod = mdrRegistry.CreateMod(strMod, strCachePath, p_gmdGameMode);
				}
				catch
				{
					modList.Add(strMod);
					modMod = null;
				}

				if (modMod == null)
					continue;
				mdrRegistry.m_oclRegisteredMods.Add(modMod);
				Trace.Indent();
				Trace.TraceInformation("Registered.");
				Trace.Unindent();
			}

			if (modList.Count > 0)
			{
				string strErrorMessage = "Error loading the following mods: " + Environment.NewLine;
				foreach (string modstr in modList)
				{
					strErrorMessage += modstr + Environment.NewLine;
				}
				MessageBox.Show(strErrorMessage, "Mod loading error", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}

			Trace.Unindent();
			return mdrRegistry;
		}
Esempio n. 7
0
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </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_mdrManagedModRegistry">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>
        private ModManager(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IModRepository p_mrpModRepository, DownloadMonitor p_dmrMonitor, ActivateModsMonitor p_ammMonitor, IModFormatRegistry p_frgFormatRegistry, ModRegistry p_mdrManagedModRegistry, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager)
		{
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			m_rmmReadMeManager = new ReadMeManager(EnvironmentInfo.Settings.ModFolder[GameMode.ModeId]);
			ModRepository = p_mrpModRepository;
			FormatRegistry = p_frgFormatRegistry;
			ManagedModRegistry = p_mdrManagedModRegistry;
			InstallationLog = p_ilgInstallLog;
            InstallerFactory = new ModInstallerFactory(p_gmdGameMode, p_eifEnvironmentInfo, p_futFileUtility, p_scxUIContext, p_ilgInstallLog, p_pmgPluginManager, this);
			DownloadMonitor = p_dmrMonitor;
            ActivateModsMonitor = p_ammMonitor;
			ModAdditionQueue = new AddModQueue(p_eifEnvironmentInfo, this);
			AutoUpdater = new AutoUpdater(p_mrpModRepository, p_mdrManagedModRegistry, p_eifEnvironmentInfo);
            LoginTask = new LoginFormTask(this);
		}
 /// <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;
 }
Esempio n. 9
0
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_mrpModRepository">The mod repository from which to get mods and mod metadata.</param>
		/// <param name="p_mrgModRegistry">The <see cref="ModRegistry"/> that contains the list
		/// of managed <see cref="IMod"/>s.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		public AutoUpdater(IModRepository p_mrpModRepository, ModRegistry p_mrgModRegistry, IEnvironmentInfo p_eifEnvironmentInfo)
		{
			ModRepository = p_mrpModRepository;
			ManagedModRegistry = p_mrgModRegistry;
			EnvironmentInfo = p_eifEnvironmentInfo;
			ManagedModRegistry.RegisteredMods.CollectionChanged += new NotifyCollectionChangedEventHandler(RegisteredMods_CollectionChanged);
			NewestModInfo = new ReadOnlyObservableList<UpdateInfo>(m_oclNewInfo);
		}