/// <summary>
		/// Prepares the given mod for installation.
		/// </summary>
		/// <remarks>
		/// This task puts the mod into read-only mode.
		/// </remarks>
		/// <returns><c>true</c> if the mod was successfully prepared;
		/// <c>false</c> otherwise.</returns>
		/// <param name="p_modMod">The mod to prepare.</param>
		public bool PrepareMod(IMod p_modMod)
		{
			OverallMessage = "Preparing Mod...";
			ShowItemProgress = false;
			OverallProgressMaximum = 100;
			OverallProgressStepSize = 1;

			try
			{
				p_modMod.ReadOnlyInitProgressUpdated += new CancelProgressEventHandler(Mod_ReadOnlyInitProgressUpdated);
				p_modMod.BeginReadOnlyTransaction(FileUtility);
			}
			catch (Exception)
			{
				Status = TaskStatus.Error;
				OnTaskEnded(false);
				throw;
			}
			finally
			{
				p_modMod.ReadOnlyInitProgressUpdated -= Mod_ReadOnlyInitProgressUpdated;
			}
			bool booSuccess = Status != TaskStatus.Cancelling;
			Status = Status == TaskStatus.Cancelling ? TaskStatus.Cancelled : TaskStatus.Complete;
			OnTaskEnded(booSuccess);
			return booSuccess;
		}
		/// <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">Game using plugin or mods (True for plugins).</param>
		public ModFileUpgradeInstaller(IGameModeEnvironmentInfo p_gmiGameModeInfo, IMod p_modMod, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, IDataFileUtil p_dfuDataFileUtility, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, bool p_UsesPlugins)
            : base(p_gmiGameModeInfo, p_modMod, p_ilgInstallLog, p_pmgPluginManager, p_dfuDataFileUtility, p_tfmFileManager, p_dlgOverwriteConfirmationDelegate, p_UsesPlugins, null)
		{
			OriginallyInstalledFiles = new Set<string>(StringComparer.OrdinalIgnoreCase);
			foreach (string strFile in InstallLog.GetInstalledModFiles(Mod))
				OriginallyInstalledFiles.Add(strFile.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
		}
		/// <summary>
		/// Gets a list of possible mod info tags which match the given mod.
		/// </summary>
		/// <param name="p_modMod">The mod for which to retrieve a list of possible tags.</param>
		/// <returns>A list of possible mod info tags which match the given mod.</returns>
		public IEnumerable<IModInfo> GetTagInfoCandidates(IMod p_modMod)
		{
			//get mod info
			List<IModInfo> lstMods = new List<IModInfo>();
			IModInfo mifInfo = null;
			try
			{
				if (!String.IsNullOrEmpty(p_modMod.Id))
					mifInfo = ModRepository.GetModInfo(p_modMod.Id);
				if (mifInfo == null)
					mifInfo = ModRepository.GetModInfoForFile(p_modMod.Filename);
				if (mifInfo == null)
				{
					//use heuristics to find info
					lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, true));
					if (lstMods.Count == 0)
						lstMods.AddRange(ModRepository.FindMods(Regex.Replace(p_modMod.ModName, "[^a-zA-Z0-9_. ]+", "", RegexOptions.Compiled), true));
					if ((lstMods.Count == 0) && (!String.IsNullOrEmpty(p_modMod.Author)))
						lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, p_modMod.Author));
					if (lstMods.Count == 0)
						lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, false));
				}
				else
					lstMods.Add(mifInfo);

				//if we don't know the mod Id, then we have no way of getting
				// the file-specific info, so only look if we have one mod info
				// candidate.
				if (lstMods.Count == 1)
				{
					mifInfo = lstMods[0];
					lstMods.Clear();
					//get file specific info
					IModFileInfo mfiFileInfo = ModRepository.GetFileInfoForFile(p_modMod.Filename);
					if (mfiFileInfo == null)
					{
						foreach (IModFileInfo mfiModFileInfo in ModRepository.GetModFileInfo(mifInfo.Id))
							lstMods.Add(CombineInfo(mifInfo, mfiModFileInfo));
					}
					else
						lstMods.Add(CombineInfo(mifInfo, mfiFileInfo));
					if (lstMods.Count == 0)
						lstMods.Add(mifInfo);
				}
			}
			catch (RepositoryUnavailableException e)
			{
				TraceUtil.TraceException(e);
				//the repository is not available, so add a dummy value indicating such
				lstMods.Add(new ModInfo(null, String.Format("{0} is unavailable", ModRepository.Name), null, null, false, null, null, 0, -1, null, null, null, null));
			}
			catch (NullReferenceException e)
			{
				TraceUtil.TraceException(e);
				//couldn't find any match, so add a dummy value indicating such
				lstMods.Add(new ModInfo(null, String.Format("{0}", e.Message), null, null, false, null, null, 0, -1, null, null, null, null));
			}
			return lstMods;
		}
		/// <summary>
		/// Compares the given <see cref="IMod"/>s.
		/// </summary>
		/// <param name="x">An object to compare to another object.</param>
		/// <param name="y">An object to compare to another object.</param>
		/// <returns>A value less than 0 if <paramref name="x"/> is less than <paramref name="y"/>.
		/// 0 if this node is equal to the other.
		/// A value greater than 0 if <paramref name="x"/> is greater than <paramref name="y"/>.</returns>
		public override int Compare(IMod x, IMod y)
		{
			if (x == null)
				return (y == null) ? 0 : -1;
			if (y == null)
				return 1;
			return StringComparer.OrdinalIgnoreCase.Compare(x.Filename, y.Filename);
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <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_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>
		public IniInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
		{
			TouchedFiles = new Set<string>(StringComparer.OrdinalIgnoreCase);
			Mod = p_modMod;
			InstallLog = p_ilgInstallLog;
			TransactionalFileManager = p_tfmFileManager;
			m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate ?? ((s, b, m) => OverwriteResult.No);
		}
		/// <summary>
		/// A simple constructor that initializes the object with the required dependencies.
		/// </summary>
		/// <param name="p_modMod">The mod for which the script is running.</param>
		/// <param name="p_gmdGameMode">The game mode currently being managed.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>		
		public XmlScriptExecutor(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, InstallerGroup p_igpInstallers, SynchronizationContext p_scxUIContext)
		{
			m_scxSyncContext = p_scxUIContext;
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			Installers = p_igpInstallers;
		}
		/// <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_igpInstallers">The utility class to use to install the mod items.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_gmdGameMode">The the current game mode.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		public BasicUninstallTask(IMod p_modMod, InstallerGroup p_igpInstallers, IInstallLog p_ilgModInstallLog, IGameMode p_gmdGameMode, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			Mod = p_modMod;
			Installers = p_igpInstallers;
			ModInstallLog = p_ilgModInstallLog;
			GameMode = p_gmdGameMode;
			ActiveMods = p_rolActiveMods;
		}
		/// <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 the current game mode.</param>
		/// <param name="p_mfiFileInstaller">The file installer to use.</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_booSkipReadme">Whether to skip the installation of readme files.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		public BasicInstallTask(IMod p_modMod, IGameMode p_gmdGameMode, IModFileInstaller p_mfiFileInstaller, IPluginManager p_pmgPluginManager, bool p_booSkipReadme, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			FileInstaller = p_mfiFileInstaller;
			PluginManager = p_pmgPluginManager;
			SkipReadme = p_booSkipReadme;
			ActiveMods = p_rolActiveMods;
		}
        public ModController(IMod mod)
            : base(mod) {
            Contract.Requires<ArgumentNullException>(mod != null);
            _contentEngine = CalculatedGameSettings.ContentManager.ContentEngine;
            Mod = mod;
            _modState = new ModState(mod);
            _sixSyncModInstaller = new SixSyncModInstaller(mod, _modState);

            Model.State = _modState.State;
        }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_atgTagger">The tagger to use to tag mods with metadata.</param>
		/// <param name="p_modMod">The mod to be tagged.</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 ModTaggerVM(AutoTagger p_atgTagger, IMod p_modMod, ISettings p_setSettings, Theme p_thmTheme)
		{
			ModTagger = p_atgTagger;
			Mod = p_modMod;
			Settings = p_setSettings;
			CurrentTheme = p_thmTheme;
			m_mifCurrentTagOption = new ModInfo(Mod);
			ModInfoEditorVM = new ModInfoEditorVM(m_mifCurrentTagOption, p_setSettings);
			ModInfoEditorVM.EditedModInfoVM.LoadInfoValues(p_modMod);
		}
        internal ModdingEnvironmentWriter(IMod[] mods_to_use, IMod[] dependencies_to_use, bool useHiDefProfile)
        {

            config = ModdingEnvironmentConfiguration.Create();

            ModEnvironment.RequestSetupDataReset();

            all_mods_to_process = mods_to_use;
            all_possible_dependencies = dependencies_to_use;

            var source_exe = ModManager.GameDirectory.ContainingFile(ModManager.OriginalExecutable);
                //new System.IO.FileInfo(System.IO.Path.Combine(base_directoy.FullName, source_exe_name));
            var modded_exe = ModManager.GameDirectory.ContainingFile(ModManager.ModdedExecutable);
                //new System.IO.FileInfo(System.IO.Path.Combine(base_directoy.FullName, modded_exe_name));
            var source_lib = ModManager.GameDirectory.ContainingFile(ModManager.OriginalLibrary);
            var modded_lib = ModManager.GameDirectory.ContainingFile(ModManager.ModdedLibrary);



            
            game_injector = new GnomoriaExeInjector(source_exe);
            lib_injector = new Injector(source_lib);
            config.Hashes.SourceExecutable = source_exe.GenerateMD5Hash();
            config.Hashes.SourceLibrary = source_lib.GenerateMD5Hash();

            // may switch those 2 later to have it outside...
            game_injector.Inject_SetContentRootDirectoryToCurrentDir_InsertAtStartOfMain();
            game_injector.Inject_CallTo_ModRuntimeController_Initialize_AtStartOfMain(ModManager.GameDirectory.ContainingFile(ModManager.ModController));
            //game_injector.Inject_TryCatchWrapperAroundEverthingInMain_WriteCrashLog();
            //game_injector.Inject_CurrentAppDomain_AddResolveEventAtStartOfMain();
            game_injector.Inject_SaveLoadCalls();
            //game_injector.Inject_TryCatchWrapperAroundGnomanEmpire_LoadGame();
            game_injector.Debug_ManipulateStuff();
            if (useHiDefProfile)
            {
                game_injector.Inject_AddHighDefXnaProfile();
            }


            foreach (var mod in mods_to_use)
            {
                ProcessMod(mod);
            }

            var allLoadedStuff = processedMods.Select(mod => Tuple.Create(mod, mod.Dependencies.Union(mod.InitAfter.Where(befor => processedMods.Contains(befor.GetInstance()))).Select(type => type.GetInstance())));
            var processedMods_sortedByDependencyAndInitAfter = DependencySort.Sort(allLoadedStuff);

            config.SetModReferences(processedMods_sortedByDependencyAndInitAfter.Select(mod => new ModReference(mod)).ToArray());

            //Mono.Cecil.WriterParameters
            game_injector.Write(modded_exe);
            lib_injector.Write(modded_lib);
            config.Hashes.ModdedExecutable = modded_exe.GenerateMD5Hash();
            config.Hashes.ModdedLibrary = modded_lib.GenerateMD5Hash();
        }
 /// <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)
 {
     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;
 }
		/// <summary>
		/// Register mod, if not already registered
		/// </summary>
		/// <param name="mod">Mod to be registered</param>
		public static void RegisterMod(IMod mod)
		{
			if (loadedModTypes.Contains(mod.GetType()))
			{
				return;
			}

			RegisterItems(mod.RegisterItems());
			RegisterRecipes(mod.RegisterRecipes());
			loadedModTypes.Add(mod.GetType());
		}
			/// <summary>
			/// Registers the given mod as being active, and associates it with the given key.
			/// </summary>
			/// <param name="p_modNewMod">The mod to register.</param>
			/// <param name="p_strModKey">The key with which to associate the mod.</param>
			/// <param name="p_booHiddenMod">Whether or not the mod should be included in the
			/// list of active mods.</param>
			public void RegisterMod(IMod p_modNewMod, string p_strModKey, bool p_booHiddenMod)
			{
				if (m_dicModKeys.ContainsValue(p_strModKey))
				{
					IMod modOld = m_dicModKeys.First(x => x.Value.Equals(p_strModKey)).Key;
					DeregisterMod(modOld);
				}
				m_dicModKeys.Add(p_modNewMod, p_strModKey);
				if (!p_booHiddenMod)
					m_oclRegisteredMods.Add(p_modNewMod);
			}
Example #15
0
		/// <summary>
		/// This finds any mod in the candidate list that appears to be another version of the given mod.
		/// </summary>
		/// <param name="p_modMod">The mod for which to find another version.</param>
		/// <param name="p_booExistingOnly">Whether the matcher should only match candidate mods that exist.</param>
		/// <returns>The active mod that appears to be another version of the given mod,
		/// or <c>null</c> if no such mod was found.</returns>
		public IMod FindAlternateVersion(IMod p_modMod, bool p_booExistingOnly)
		{
			IEnumerable<IMod> lstMatches = from m in Candidates
										   where !String.IsNullOrEmpty(m.Id)
												&& m.Id.Equals(p_modMod.Id)
												&& !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
												&& (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
										   select m;
			string strNewModName = p_modMod.ModName;
			if (String.IsNullOrEmpty(p_modMod.Id))
			{
				if (lstMatches.Count() == 0)
				{
					lstMatches = from m in Candidates
								 where m.ModName.Equals(strNewModName, StringComparison.InvariantCultureIgnoreCase)
									 && !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
									 && (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
								 select m;
				}
				if (lstMatches.Count() == 0)
				{
					string strNewModNamePrefix = strNewModName.Split('-')[0].Trim();
					lstMatches = from m in Candidates
								 where m.ModName.Split('-')[0].Trim().Equals(strNewModNamePrefix, StringComparison.InvariantCultureIgnoreCase)
									 && !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
									 && (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
								 select m;
				}
			}
			IMod modMatch = null;
			Int64 intFilesize = 0;
			foreach (IMod modCandidate in lstMatches)
			{
				if (File.Exists(modCandidate.Filename))
				{
					FileInfo fifInfo = new FileInfo(modCandidate.Filename);
					if (fifInfo.Length > intFilesize)
					{
						intFilesize = fifInfo.Length;
						modMatch = modCandidate;
					}
				}
			}
			if (modMatch == null)
				modMatch = lstMatches.FirstOrDefault();
			return modMatch;
		}
        public DummyPluginManager(string pluginsFile, IGameMode gameMode, IMod mod)
        {
            StreamReader reader = new StreamReader(pluginsFile);

            string installationPath = Path.Combine(gameMode.GameModeEnvironmentInfo.InstallationPath, gameMode.GetModFormatAdjustedPath(mod.Format, null, false));

            string line;
            while ((line = reader.ReadLine()) != null)
            {
                if (line[0] != '#')
                {
                    m_Plugins.Add(new Plugin(Path.Combine(installationPath, line.ToLower()), line, null));
                }
            }
            ((INotifyCollectionChanged)m_Plugins).CollectionChanged += new NotifyCollectionChangedEventHandler(ActivePlugins_CollectionChanged);
            m_ROOLPlugins = new ReadOnlyObservableList<Plugin>(m_Plugins);
        }
 /// <summary>
 /// Creates a cache file for the given mod, containing the specified files.
 /// </summary>
 /// <param name="p_modMod">The mod for which to create the cache file.</param>
 /// <param name="p_strFilesToCacheFolder">The folder containing the files to put into the cache.</param>
 /// <returns>The cache file for the specified mod, or <c>null</c>
 /// if there were no files to cache.</returns>
 public Archive CreateCacheFile(IMod p_modMod, string p_strFilesToCacheFolder)
 {
     if (!String.IsNullOrEmpty(p_strFilesToCacheFolder))
     {
         string[] strFilesToCompress = Directory.GetFiles(p_strFilesToCacheFolder, "*.*", SearchOption.AllDirectories);
         if (strFilesToCompress.Length > 0)
         {
             string strCachePath = GetCacheFilePath(p_modMod);
             SevenZipCompressor szcCompressor = new SevenZipCompressor();
             szcCompressor.ArchiveFormat = OutArchiveFormat.Zip;
             szcCompressor.CompressionLevel = CompressionLevel.Ultra;
             szcCompressor.CompressDirectory(p_strFilesToCacheFolder, strCachePath);
             return new Archive(strCachePath);
         }
     }
     return null;
 }
		/// <summary>
		/// Activates the given mod.
		/// </summary>
		/// <remarks>
		/// The given mod is either installed or upgraded, as appropriate.
		/// </remarks>
		/// <param name="p_modMod">The mod to install.</param>
		/// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param>
		/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
		public IBackgroundTaskSet Activate(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			ModMatcher mmcMatcher = new ModMatcher(InstallationLog.ActiveMods, true);
			IMod modOldVersion = mmcMatcher.FindAlternateVersion(p_modMod, true);
			ConfirmUpgradeResult curAction = (modOldVersion == null) ? ConfirmUpgradeResult.NormalActivation : p_dlgUpgradeConfirmationDelegate(modOldVersion, p_modMod);
			switch (curAction)
			{
				case ConfirmUpgradeResult.Upgrade:
					ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(modOldVersion, p_modMod, p_dlgOverwriteConfirmationDelegate);
                    return muiUpgrader;
				case ConfirmUpgradeResult.NormalActivation:
					ModInstaller minInstaller = InstallerFactory.CreateInstaller(p_modMod, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods);
					return minInstaller;
				case ConfirmUpgradeResult.Cancel:
					return null;
				default:
					throw new Exception(String.Format("Unrecognized value for ConfirmUpgradeResult: {0}", curAction));
			}
		}
 private void ProcessMod(IMod mod)
 {
     if (processedMods.Contains(mod))
     {
         return;
     }
     if (currentlyProcessing.Contains(mod))
     {
         throw new InvalidOperationException("Can't process mod [" + mod.Name + "], already processing it. Circular dependency?");
     }
     currentlyProcessing.Add(mod);
     mod.Initialize_PreGeneration();
     if (mod.InitBefore.Count() > 0)
     {
         throw new NotImplementedException("Mod.InitAfter and Mod.InitBefore are not yet supported. Sorry.");
     }
     foreach (var dependency in mod.Dependencies)
     {
         ProcessMod(all_mods_to_process.Union(all_possible_dependencies).Single(depModInstance => depModInstance.GetType() == dependency.Type));
     }
     foreach (var change in mod.Modifications)
     {
         if (game_injector.AssemblyContainsType(change.TargetType))
         {
             game_injector.Inject_Modification(change);
         }
         else if (lib_injector.AssemblyContainsType(change.TargetType))
         {
             lib_injector.Inject_Modification(change);
         }
         else
         {
             throw new InvalidOperationException("Cannot change behavoir of type [" + change.TargetType + "]!");
         }
     }
     processedMods.Add(mod);
     currentlyProcessing.Remove(mod);
 }
        public CalculatedGameSettings(Game game) {
            _eventBus = Common.App.Events;
            _game = game;
            CurrentMods = new IMod[0];
            _supportsModding = _game.SupportsMods();
            _supportsMissions = _game.SupportsMissions();
            _supportsServers = _game.SupportsServers();
            if (_supportsModding)
                _modding = _game.Modding();

            Signatures = new string[0];
            if (!Execute.InDesignMode) {
                var collectionChanged = this.WhenAnyValue(x => x.Collection)
                    .Skip(1);
                collectionChanged
                    .Subscribe(HandleModSetSwitch);

                // TODO: Ignore out of band responses, cancel previous etc...
                collectionChanged
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(x => UpdateSignatures());

                this.WhenAnyValue(x => x.Server)
                    .Skip(1)
                    .Subscribe(HandleServerSwitch);

                this.WhenAnyValue(x => x.Server.Mods)
                    .Skip(1)
                    .Subscribe(HandleServerModsChanged);

                this.WhenAnyValue(x => x.Mission)
                    .Skip(1)
                    .Subscribe(HandleMissionSwitch);
            }

            _first = true;
        }
			/// <summary>
			/// Replaces the edited value of the specified game specific value edit installed by the given mod.
			/// </summary>
			/// <param name="p_modInstallingMod">The mod whose game specific value edit value is to be replaced.</param>
			/// <param name="p_strKey">The key of the game spcified value whose edited value is to be replaced.</param>
			/// <param name="p_bteValue">The value with which to replace the edited value of the specified game specific value edit installed by the given mod.</param>
			public void ReplaceGameSpecificValueEdit(IMod p_modInstallingMod, string p_strKey, byte[] p_bteValue)
			{
				string strInstallingModKey = GetModKey(p_modInstallingMod);
				m_dicReplacedGameSpecificValueEdits[p_strKey].Push(strInstallingModKey, p_bteValue);
				if (m_dicUninstalledGameSpecificValueEdits.ContainsItem(p_strKey))
					m_dicUninstalledGameSpecificValueEdits[p_strKey].Remove(strInstallingModKey);
				if (CurrentTransaction == null)
					Commit();
				else
					Enlist();
			}
Example #22
0
 /// <summary>
 /// Removes the specified ini edit as having been installed by the given mod.
 /// </summary>
 /// <param name="p_modInstallingMod">The mod for which to remove the specified ini edit.</param>
 /// <param name="p_strSettingsFileName">The name of the edited INI file containing the INI edit being removed for the given mod.</param>
 /// <param name="p_strSection">The section containting the INI edit being removed for the given mod.</param>
 /// <param name="p_strKey">The key of the edited INI value whose edit is being removed for the given mod.</param>
 public void RemoveIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey)
 {
     GetEnlistment().RemoveIniEdit(p_modInstallingMod, p_strSettingsFileName, p_strSection, p_strKey);
 }
			/// <summary>
			/// Logs the specified INI edit as having been installed by the given mod.
			/// </summary>
			/// <param name="p_modInstallingMod">The mod installing the specified INI edit.</param>
			/// <param name="p_strSettingsFileName">The name of the edited INI file.</param>
			/// <param name="p_strSection">The section containing the INI edit.</param>
			/// <param name="p_strKey">The key of the edited INI value.</param>
			/// <param name="p_strValue">The value installed by the mod.</param>
			public void AddIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
			{
				string strInstallingModKey = AddActiveMod(p_modInstallingMod, false);
				IniEdit iedEdit = new IniEdit(p_strSettingsFileName, p_strSection, p_strKey);
				m_dicInstalledIniEdits[iedEdit].Push(strInstallingModKey, p_strValue);
				if (m_dicUninstalledIniEdits.ContainsItem(iedEdit))
					m_dicUninstalledIniEdits[iedEdit].Remove(strInstallingModKey);
				if (CurrentTransaction == null)
					Commit();
				else
					Enlist();
			}
Example #24
0
        /// <summary>
        /// Gets the key of the mod that owns the specified Game Specific Value edit.
        /// </summary>
        /// <param name="p_strKey">The key of the edited Game Specific Value.</param>
        /// <returns>The key of the mod that owns the specified Game Specific Value edit.</returns>
        public string GetCurrentGameSpecificValueEditOwnerKey(string p_strKey)
        {
            IMod modCurrentOwner = GetCurrentGameSpecificValueEditOwner(p_strKey);

            return((modCurrentOwner == null) ? null : GetModKey(modCurrentOwner));
        }
Example #25
0
 /// <summary>
 /// Creates a <see cref="ConditionStateManager"/> to use when running an XML script.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_gmdGameMode">The game mode currently bieng managed.</param>
 /// <param name="p_pmgPluginManager">The plugin manager.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <returns>A <see cref="ConditionStateManager"/> to use when running an XML script.</returns>
 public override ConditionStateManager CreateConditionStateManager(IMod p_modMod, IGameMode p_gmdGameMode, IPluginManager p_pmgPluginManager, IEnvironmentInfo p_eifEnvironmentInfo)
 {
     return(new SkyrimSEConditionStateManager(p_modMod, p_gmdGameMode, p_pmgPluginManager, p_eifEnvironmentInfo));
 }
		/// <summary>
		/// Creates a <see cref="ConditionStateManager"/> to use when running an XML script.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The game mode currently bieng managed.</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <returns>A <see cref="ConditionStateManager"/> to use when running an XML script.</returns>
		public override ConditionStateManager CreateConditionStateManager(IMod p_modMod, IGameMode p_gmdGameMode, IPluginManager p_pmgPluginManager, IEnvironmentInfo p_eifEnvironmentInfo)
		{
			return new SkyrimConditionStateManager(p_modMod, p_gmdGameMode, p_pmgPluginManager, p_eifEnvironmentInfo);
		}
Example #27
0
 /// <summary>
 /// Gets the path to the specified mod's cache file.
 /// </summary>
 /// <param name="p_modMod">The mod for which to get the cache filename.</param>
 /// <returns>The path to the specified mod's cache file.</returns>
 private string GetCacheFilePath(IMod p_modMod)
 {
     return(Path.Combine(ModCacheDirectory, Path.GetFileName(p_modMod.ModArchivePath) + ".zip"));
 }
Example #28
0
 public bool Equals(IMod other) => Acronym == other?.Acronym;
 public bool Equals(IMod other) => GetType() == other?.GetType();
Example #30
0
 /// <summary>
 /// Returns a proxy that implements the functions available to Mod Script scripts.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_gmdGameMode">The game mode currently bieng managed.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
 /// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
 /// <returns>A proxy that implements the functions available to Mod Script scripts.</returns>
 protected override ModScriptFunctionProxy GetScriptFunctionProxy(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, InstallerGroup p_igpInstallers, SynchronizationContext p_scxUIContext)
 {
     return(new Witcher2ModScriptFunctionProxy(p_modMod, p_gmdGameMode, p_eifEnvironmentInfo, p_igpInstallers, new ModScriptUIUtil(p_gmdGameMode, p_eifEnvironmentInfo, p_scxUIContext)));
 }
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_modMod">The mod for which the script is running.</param>
 /// <param name="p_gmdGameMode">The game mode currently being managed.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_ivaVirtualModActivator">The virtual mod activator.</param>
 /// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
 /// <param name="p_uipUIProxy">The UI manager to use to interact with UI elements.</param>
 public CSharpScriptFunctionProxy(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IVirtualModActivator p_ivaVirtualModActivator, InstallerGroup p_igpInstallers, UIUtil p_uipUIProxy)
     : base(p_modMod, p_gmdGameMode, p_eifEnvironmentInfo, p_ivaVirtualModActivator, p_igpInstallers, p_uipUIProxy)
 {
 }
Example #32
0
 /// <summary>
 /// Gets the installer to use to upgrade game specific values.
 /// </summary>
 /// <param name="p_modMod">The mod being upgraded.</param>
 /// <param name="p_ilgInstallLog">The install log to use to log the installation of the game specific values.</param>
 /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
 /// <returns>The installer to use to manage game specific values, or <c>null</c> if the game mode does not
 /// install any game specific values.</returns>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
 public override IGameSpecificValueInstaller GetGameSpecificValueUpgradeInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
 {
     return(null);
 }
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_modMod">The mod for which the script is running.</param>
 /// <param name="p_gmdGameMode">The game mode currently being managed.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
 /// <param name="p_uipUIProxy">The UI manager to use to interact with UI elements.</param>
 public WoTModScriptFunctionProxy(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, InstallerGroup p_igpInstallers, ModScriptUIUtil p_uipUIProxy)
     : base(p_modMod, p_gmdGameMode, p_eifEnvironmentInfo, p_igpInstallers, p_uipUIProxy)
 {
 }
 public ModContentSource(IMod mod) : this(mod.Helper) { }
			/// <summary>
			/// Gets the list of Game Specific Value edited keys that were installed by the given mod.
			/// </summary>
			/// <param name="p_modInstaller">The mod whose isntalled edits are to be returned.</param>
			/// <returns>The list of edited keys that was installed by the given mod.</returns>
			public IList<string> GetInstalledGameSpecificValueEdits(IMod p_modInstaller)
			{
				Set<string> setGameSpecificValues = new Set<string>();
				string strInstallerKey = GetModKey(p_modInstaller);
				if (String.IsNullOrEmpty(strInstallerKey) || m_setRemovedModKeys.Contains(strInstallerKey))
					return setGameSpecificValues;
				setGameSpecificValues.AddRange(from itm in m_dicInstalledGameSpecificValueEdits
											   where itm.Installers.Contains(strInstallerKey)
											   select itm.Item);
				setGameSpecificValues.AddRange(from itm in EnlistedInstallLog.m_dicInstalledGameSpecificValueEdits
											   where itm.Installers.Contains(strInstallerKey)
											   select itm.Item);
				setGameSpecificValues.RemoveRange(from itm in m_dicUninstalledGameSpecificValueEdits
												  where itm.Installers.Contains(strInstallerKey)
												  select itm.Item);
				return setGameSpecificValues;
			}
Example #36
0
 protected AGroup()
 {
     this.SourceMod = null !;
 }
		/// <summary>
		/// This asks the use to confirm the upgrading of the given old mod to the given new mod.
		/// </summary>
		/// <param name="p_modOld">The old mod to be upgrade to the new mod.</param>
		/// <param name="p_modNew">The new mod to which to upgrade from the old.</param>
		/// <returns>The user's choice.</returns>
		private ConfirmUpgradeResult ConfirmModUpgrade(IMod p_modOld, IMod p_modNew)
		{
			if (InvokeRequired)
				return (ConfirmUpgradeResult)Invoke((ConfirmModUpgradeDelegate)ConfirmModUpgrade, p_modOld, p_modNew);
			else
			{
				string strUpgradeMessage = "A different version of {0} has been detected. The installed version is {1}, the new version is {2}. Would you like to upgrade?" + Environment.NewLine + "Selecting No will install the new Mod normally.";
				strUpgradeMessage = String.Format(strUpgradeMessage, p_modOld.ModName, p_modOld.HumanReadableVersion, p_modNew.HumanReadableVersion);
				switch (MessageBox.Show(this, strUpgradeMessage, "Upgrade", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
				{
					case DialogResult.Yes:
						return ConfirmUpgradeResult.Upgrade;
					case DialogResult.No:
						return ConfirmUpgradeResult.NormalActivation;
					case DialogResult.Cancel:
						return ConfirmUpgradeResult.Cancel;
					default:
						throw new Exception("Unrecognized result from YesNoCancel message box.");
				}
			}
		}
Example #38
0
 /// <summary>
 /// Logs the specified INI edit as having been installed by the given mod.
 /// </summary>
 /// <param name="p_modInstallingMod">The mod installing the specified INI edit.</param>
 /// <param name="p_strSettingsFileName">The name of the edited INI file.</param>
 /// <param name="p_strSection">The section containting the INI edit.</param>
 /// <param name="p_strKey">The key of the edited INI value.</param>
 /// <param name="p_strValue">The value installed by the mod.</param>
 public void AddIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
 {
     GetEnlistment().AddIniEdit(p_modInstallingMod, p_strSettingsFileName, p_strSection, p_strKey, p_strValue);
 }
Example #39
0
 public SeasonToken(IMod mod)
 {
     mod.Helper.Events.GameLoop.DayStarted += (sender, args) => this.CheckSeason();
 }
Example #40
0
 /// <summary>
 /// Replaces the edited value of the specified game specific value edit installed by the given mod.
 /// </summary>
 /// <param name="p_modInstallingMod">The mod whose game specific value edit value is to be replaced.</param>
 /// <param name="p_strKey">The key of the game spcified value whose edited value is to be replaced.</param>
 /// <param name="p_bteValue">The value with which to replace the edited value of the specified game specific value edit installed by the given mod.</param>
 public void ReplaceGameSpecificValueEdit(IMod p_modInstallingMod, string p_strKey, byte[] p_bteValue)
 {
     GetEnlistment().ReplaceGameSpecificValueEdit(p_modInstallingMod, p_strKey, p_bteValue);
 }
Example #41
0
 /// <summary>
 /// Gets the list of Game Specific Value edited keys that were installed by the given mod.
 /// </summary>
 /// <param name="p_modInstaller">The mod whose isntalled edits are to be returned.</param>
 /// <returns>The list of edited keys that was installed by the given mod.</returns>
 public IList <string> GetInstalledGameSpecificValueEdits(IMod p_modInstaller)
 {
     return(GetEnlistment().GetInstalledGameSpecificValueEdits(p_modInstaller));
 }
Example #42
0
        /// <summary>
        /// Gets the key of the mod that owns the specified INI edit.
        /// </summary>
        /// <param name="p_strSettingsFileName">The name of the edited INI file.</param>
        /// <param name="p_strSection">The section containting the INI edit.</param>
        /// <param name="p_strKey">The key of the edited INI value.</param>
        /// <returns>The key of the mod that owns the specified INI edit.</returns>
        public string GetCurrentIniEditOwnerKey(string p_strSettingsFileName, string p_strSection, string p_strKey)
        {
            IMod modCurrentOwner = GetCurrentIniEditOwner(p_strSettingsFileName, p_strSection, p_strKey);

            return((modCurrentOwner == null) ? null : GetModKey(modCurrentOwner));
        }
Example #43
0
 /// <summary>
 /// Removes the specified Game Specific Value edit as having been installed by the given mod.
 /// </summary>
 /// <param name="p_modInstallingMod">The mod for which to remove the specified Game Specific Value edit.</param>
 /// <param name="p_strKey">The key of the Game Specific Value whose edit is being removed for the given mod.</param>
 public void RemoveGameSpecificValueEdit(IMod p_modInstallingMod, string p_strKey)
 {
     GetEnlistment().RemoveGameSpecificValueEdit(p_modInstallingMod, p_strKey);
 }
Example #44
0
 /// <summary>
 /// Gets the installer to use to upgrade game specific values.
 /// </summary>
 /// <param name="p_modMod">The mod being upgraded.</param>
 /// <param name="p_ilgInstallLog">The install log to use to log the installation of the game specific values.</param>
 /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
 /// <returns>The installer to use to manage game specific values, or <c>null</c> if the game mode does not
 /// install any game specific values.</returns>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
 public override IGameSpecificValueInstaller GetGameSpecificValueUpgradeInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
 {
     return(new GamebryoGameSpecificValueInstaller(p_modMod, GameModeEnvironmentInfo, p_ilgInstallLog, p_tfmFileManager, p_futFileUtility, p_dlgOverwriteConfirmationDelegate));
 }
Example #45
0
 /// <summary>
 /// Gets the list of INI edits that were installed by the given mod.
 /// </summary>
 /// <param name="p_modInstaller">The mod whose isntalled edits are to be returned.</param>
 /// <returns>The list of edits that was installed by the given mod.</returns>
 public IList <IniEdit> GetInstalledIniEdits(IMod p_modInstaller)
 {
     return(GetEnlistment().GetInstalledIniEdits(p_modInstaller));
 }
 public string AddFileLink(IMod p_modMod, string p_strBaseFilePath, string p_strSourceFile, bool p_booIsSwitching)
 {
     return(AddFileLink(p_modMod, p_strBaseFilePath, p_strSourceFile, p_booIsSwitching, false));
 }
 protected override TextFileSharedFormKeyAllocator CreateAllocator(IMod mod, string path) => new(mod, path, DefaultName, preload : true);
 /// <summary>
 /// Handles special file installation
 /// </summary>
 /// <param name="p_strFiles">List of files to handle</param>
 /// <returns>The list of new files to install</returns>
 public virtual IEnumerable <string> SpecialFileInstall(IMod p_modSelectedMod)
 {
     return(null);
 }
			/// <summary>
			/// Gets the list of files that was installed by the given mod.
			/// </summary>
			/// <param name="p_modInstaller">The mod whose isntalled files are to be returned.</param>
			/// <returns>The list of files that was installed by the given mod.</returns>
			public IList<string> GetInstalledModFiles(IMod p_modInstaller)
			{
				Set<string> setFiles = new Set<string>(StringComparer.OrdinalIgnoreCase);
				string strInstallerKey = GetModKey(p_modInstaller);
				if (String.IsNullOrEmpty(strInstallerKey) || m_setRemovedModKeys.Contains(strInstallerKey))
					return setFiles;
				setFiles.AddRange(from itm in m_dicInstalledFiles
								  where itm.Installers.Contains(strInstallerKey)
								  select itm.Item);
				setFiles.AddRange(from itm in EnlistedInstallLog.m_dicInstalledFiles
								  where itm.Installers.Contains(strInstallerKey)
								  select itm.Item);
				setFiles.RemoveRange(from itm in m_dicUninstalledFiles
									 where itm.Installers.Contains(strInstallerKey)
									 select itm.Item);
				return setFiles;
			}
 /// <summary>
 /// Checks whether to use the secondary mod install method.
 /// </summary>
 /// <returns>Whether to use the secondary mod install method.</returns>
 /// <param name="p_modMod">The mod to be installed.</param>
 public virtual bool CheckSecondaryInstall(IMod p_modMod)
 {
     return(false);
 }
			/// <summary>
			/// Removes the specified ini edit as having been installed by the given mod.
			/// </summary>
			/// <param name="p_modUninstallingMod">The mod for which to remove the specified ini edit.</param>
			/// <param name="p_strSettingsFileName">The name of the edited INI file containing the INI edit being removed for the given mod.</param>
			/// <param name="p_strSection">The section containting the INI edit being removed for the given mod.</param>
			/// <param name="p_strKey">The key of the edited INI value whose edit is being removed for the given mod.</param>
			public void RemoveIniEdit(IMod p_modUninstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey)
			{
				string strUninstallingModKey = GetModKey(p_modUninstallingMod);
				if (String.IsNullOrEmpty(strUninstallingModKey))
					return;
				IniEdit iedEdit = new IniEdit(p_strSettingsFileName, p_strSection, p_strKey);
				m_dicUninstalledIniEdits[iedEdit].Push(strUninstallingModKey, null);
				if (m_dicInstalledIniEdits.ContainsItem(iedEdit))
					m_dicInstalledIniEdits[iedEdit].Remove(strUninstallingModKey);
				if (m_dicReplacedIniEdits.ContainsItem(iedEdit))
					m_dicReplacedIniEdits[iedEdit].Remove(strUninstallingModKey);
				if (CurrentTransaction == null)
					Commit();
				else
					Enlist();
			}
 /// <summary>
 /// Merges the mod files if requested by the game.
 /// </summary>
 /// <returns>Merges the mod files if requested by the game.</returns>
 /// <param name="p_lstActiveMods">The list of active mods.</param>
 /// <param name="p_modMod">The current mod.</param>
 /// <param name="p_booRemove">Whether we're adding or removing the mod.</param>
 public virtual void ModFileMerge(IList <IMod> p_lstActiveMods, IMod p_modMod, bool p_booRemove)
 {
 }
			/// <summary>
			/// Removes the specified Game Specific Value edit as having been installed by the given mod.
			/// </summary>
			/// <param name="p_modUninstallingMod">The mod for which to remove the specified Game Specific Value edit.</param>
			/// <param name="p_strKey">The key of the Game Specific Value whose edit is being removed for the given mod.</param>
			public void RemoveGameSpecificValueEdit(IMod p_modUninstallingMod, string p_strKey)
			{
				string strUninstallingModKey = GetModKey(p_modUninstallingMod);
				if (String.IsNullOrEmpty(strUninstallingModKey))
					return;
				m_dicUninstalledGameSpecificValueEdits[p_strKey].Push(strUninstallingModKey, null);
				if (m_dicInstalledGameSpecificValueEdits.ContainsItem(p_strKey))
					m_dicInstalledGameSpecificValueEdits[p_strKey].Remove(strUninstallingModKey);
				if (m_dicReplacedGameSpecificValueEdits.ContainsItem(p_strKey))
					m_dicReplacedGameSpecificValueEdits[p_strKey].Remove(strUninstallingModKey);
				if (CurrentTransaction == null)
					Commit();
				else
					Enlist();
			}
 /// <summary>
 /// Adjusts the given path to be relative to the installation path of the game mode.
 /// </summary>
 /// <remarks>
 /// This is basically a hack to allow older FOMods to work. Older FOMods assumed
 /// the installation path of Fallout games to be &lt;games>/data, but this new manager specifies
 /// the installation path to be &lt;games>. This breaks the older FOMods, so this method can detect
 /// the older FOMods (or other mod formats that needs massaging), and adjusts the given path
 /// to be relative to the new instaalation path to make things work.
 /// </remarks>
 /// <param name="p_mftModFormat">The mod format for which to adjust the path.</param>
 /// <param name="p_strPath">The path to adjust.</param>
 /// <param name="p_modMod">The mod.</param>
 /// <param name="p_booIgnoreIfPresent">Whether to ignore the path if the specific root is already present</param>
 /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns>
 public virtual string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent)
 {
     return(GetModFormatAdjustedPath(p_mftModFormat, p_strPath, p_booIgnoreIfPresent));
 }
		/// <summary>
		/// This asks the use to confirm the deleting of the given mod file.
		/// </summary>
		/// <param name="p_modMod">The mod whose deletion is to be confirmed.</param>
		/// <returns><c>true</c> if the mod should be deleted;
		/// <c>false</c> otherwise.</returns>
		private bool ConfirmModFileDeletion(IMod p_modMod)
		{
			if (InvokeRequired)
			{
				bool booResult = false;
				Invoke((MethodInvoker)(() => booResult = ConfirmModFileDeletion(p_modMod)));
				return booResult;
			}
			return MessageBox.Show(this, String.Format("Are you sure you want to delete {0}?", p_modMod.ModName), "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
		}
 /// <summary>
 /// Gets the installer to use to install game specific values.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_ilgInstallLog">The install log to use to log the installation of the game specific values.</param>
 /// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
 /// <returns>The installer to use to manage game specific values, or <c>null</c> if the game mode does not
 /// install any game specific values.</returns>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
 public abstract IGameSpecificValueInstaller GetGameSpecificValueInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate);
		/// <summary>
		/// Updates the displayed summary information to reflect the
		/// given mod.
		/// </summary>
		/// <param name="p_modMod">The mod for which to display the summary information.</param>
		protected void UpdateSummary(IMod p_modMod)
		{
			ipbScreenShot.Image = (p_modMod == null) ? null : p_modMod.Screenshot;
			flbInfo.Text = (p_modMod == null) ? null : p_modMod.Description;
			HidePanels();
		}
Example #58
0
 public TabMenu(IMod env, int x, int y, int width, int height, bool showUpperRightCloseButton = false) : base(env, x, y, width, height, showUpperRightCloseButton)
 {
     m_drawBlackFade = false;
     m_drawMenuFrame = false;
 }
Example #59
0
 /// <summary>
 /// Gets the list of files that were installed by the given mod.
 /// </summary>
 /// <param name="p_modInstaller">The mod whose isntalled files are to be returned.</param>
 /// <returns>The list of files that were installed by the given mod.</returns>
 public IList <string> GetInstalledModFiles(IMod p_modInstaller)
 {
     return(GetEnlistment().GetInstalledModFiles(p_modInstaller));
 }
        private bool?TestOverwriteFileLink(IMod p_modMod, string p_strBaseFilePath, out Int32 p_intPriority, out List <IVirtualModLink> p_lstFileLinks)
        {
            IMod  modCheck;
            Int32 intPriority = VirtualModActivator.CheckFileLink(p_strBaseFilePath, out modCheck, out p_lstFileLinks);

            p_intPriority = intPriority;
            string strLoweredPath = p_strBaseFilePath.ToLowerInvariant();

            if (intPriority >= 0)
            {
                if (m_lstOverwriteFolders.Contains(Path.GetDirectoryName(strLoweredPath)))
                {
                    return(true);
                }
                if (m_lstDontOverwriteFolders.Contains(Path.GetDirectoryName(strLoweredPath)))
                {
                    return(false);
                }
                if (m_booOverwriteAll)
                {
                    return(true);
                }
                if (m_booDontOverwriteAll)
                {
                    return(false);
                }
            }

            if (modCheck == p_modMod)
            {
                return(null);
            }

            string strModFile   = String.Empty;
            string strModFileID = String.Empty;
            string strMessage   = null;

            if (modCheck == VirtualModActivator.DummyMod)
            {
                VirtualModActivator.OverwriteLooseFile(p_strBaseFilePath, Path.GetFileName(p_modMod.Filename));
                return(true);
            }
            else if (modCheck != null)
            {
                strModFile   = modCheck.Filename;
                strModFileID = modCheck.Id;
                if (!String.IsNullOrEmpty(strModFileID))
                {
                    if (m_lstOverwriteMods.Contains(strModFileID))
                    {
                        return(true);
                    }
                    if (m_lstDontOverwriteMods.Contains(strModFileID))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (m_lstOverwriteMods.Contains(strModFile))
                    {
                        return(true);
                    }
                    if (m_lstDontOverwriteMods.Contains(strModFile))
                    {
                        return(false);
                    }
                }
                strMessage  = String.Format("Data file '{{0}}' has already been installed by '{1}'", p_strBaseFilePath, modCheck.ModName);
                strMessage += Environment.NewLine + "Activate this mod's file instead?";

                switch (OverwriteForm.ShowDialog(String.Format(strMessage, p_strBaseFilePath), true, (modCheck != null)))
                {
                case OverwriteResult.Yes:
                    return(true);

                case OverwriteResult.No:
                    return(false);

                case OverwriteResult.NoToAll:
                    m_booDontOverwriteAll = true;
                    return(false);

                case OverwriteResult.YesToAll:
                    m_booOverwriteAll = true;
                    return(true);

                case OverwriteResult.NoToGroup:
                    Queue <string> folders = new Queue <string>();
                    folders.Enqueue(Path.GetDirectoryName(strLoweredPath));
                    while (folders.Count > 0)
                    {
                        strLoweredPath = folders.Dequeue();
                        if (!m_lstOverwriteFolders.Contains(strLoweredPath))
                        {
                            m_lstDontOverwriteFolders.Add(strLoweredPath);
                            if (Directory.Exists(strLoweredPath))
                            {
                                foreach (string s in Directory.GetDirectories(strLoweredPath))
                                {
                                    folders.Enqueue(s.ToLowerInvariant());
                                }
                            }
                        }
                    }
                    return(false);

                case OverwriteResult.YesToGroup:
                    folders = new Queue <string>();
                    folders.Enqueue(Path.GetDirectoryName(strLoweredPath));
                    while (folders.Count > 0)
                    {
                        strLoweredPath = folders.Dequeue();
                        if (!m_lstDontOverwriteFolders.Contains(strLoweredPath))
                        {
                            m_lstOverwriteFolders.Add(strLoweredPath);
                            if (Directory.Exists(strLoweredPath))
                            {
                                foreach (string s in Directory.GetDirectories(strLoweredPath))
                                {
                                    folders.Enqueue(s.ToLowerInvariant());
                                }
                            }
                        }
                    }
                    return(true);

                case OverwriteResult.NoToMod:
                    strModFile   = modCheck.Filename;
                    strModFileID = modCheck.Id;
                    if (!String.IsNullOrEmpty(strModFileID))
                    {
                        if (!m_lstOverwriteMods.Contains(strModFileID))
                        {
                            m_lstDontOverwriteMods.Add(strModFileID);
                        }
                    }
                    else
                    {
                        if (!m_lstOverwriteMods.Contains(strModFile))
                        {
                            m_lstDontOverwriteMods.Add(strModFile);
                        }
                    }
                    return(false);

                case OverwriteResult.YesToMod:
                    strModFile   = modCheck.Filename;
                    strModFileID = modCheck.Id;
                    if (!String.IsNullOrEmpty(strModFileID))
                    {
                        if (!m_lstDontOverwriteMods.Contains(strModFileID))
                        {
                            m_lstOverwriteMods.Add(strModFileID);
                        }
                    }
                    else
                    {
                        if (!m_lstDontOverwriteMods.Contains(strModFile))
                        {
                            m_lstOverwriteMods.Add(strModFile);
                        }
                    }
                    return(true);

                default:
                    throw new Exception("Sanity check failed: OverwriteDialog returned a value not present in the OverwriteResult enum");
                }
            }
            else
            {
                return(true);
            }
        }