/// <summary> /// A simple constructor that initializes the object with the given dependencies. /// </summary> /// <param name="p_strModCacheDirectory">The path of the directory where the current Game Mode's mods' cache files are stored.</param> /// <param name="p_strModDirectory">The path of the directory where the current Game Mode's mod files are stored.</param> /// <param name="p_futFileUtility">The file utility class.</param> public NexusModCacheManager(string p_strModCacheDirectory, string p_strModDirectory, FileUtil p_futFileUtility) { ModCacheDirectory = p_strModCacheDirectory; ModDirectory = p_strModDirectory; FileUtility = p_futFileUtility; CheckModCache(); }
/// <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 construtor that initializes the object with the reqruied dependencies. /// </summary> /// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param> /// <param name="p_futFileUtility">The file utility class.</param> /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param> public ModBuilder(IGameModeEnvironmentInfo p_gmiGameModeInfo, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility) { GameModeInfo = p_gmiGameModeInfo; EnvironmentInfo = p_eifEnvironmentInfo; FileUtility = p_futFileUtility; OverallProgressMaximum = 4; }
/// <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 simple constructor that initializes the object with its dependencies. /// </summary> /// <param name="p_futFileUtilities">The file utility class.</param> public ModPackager(FileUtil p_futFileUtilities) { FileUtilities = p_futFileUtilities; }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_futFileUtility">The file utility class.</param> public PrepareModTask(FileUtil p_futFileUtility) { FileUtility = p_futFileUtility; }
/// <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); }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_eifEnvironmentInfo">The application's environment info.</param> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> public GamebryoGameModeBase(IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility) : base(p_eifEnvironmentInfo) { SettingsFiles = CreateSettingsFileContainer(); SetupSettingsFiles(); SettingsGroupViews = new List<ISettingsGroupView>(); GeneralSettingsGroup gsgGeneralSettings = new GeneralSettingsGroup(p_eifEnvironmentInfo, this); ((List<ISettingsGroupView>)SettingsGroupViews).Add(new GeneralSettingsPage(gsgGeneralSettings)); SetupPluginManagement(p_futFileUtility); }
/// <summary> /// Instantiates the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <returns>The game mode for which this is a factory.</returns> protected GrimrockGameMode InstantiateGameMode(FileUtil p_futFileUtility) { return new GrimrockGameMode(EnvironmentInfo, p_futFileUtility); }
/// <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 override IGameSpecificValueInstaller GetGameSpecificValueInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate) { return null; }
/// <summary> /// Instantiates the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <returns>The game mode for which this is a factory.</returns> protected DarkSouls2GameMode InstantiateGameMode(FileUtil p_futFileUtility) { return new DarkSouls2GameMode(EnvironmentInfo, p_futFileUtility); }
/// <summary> /// Instantiates the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <returns>The game mode for which this is a factory.</returns> protected Witcher2GameMode InstantiateGameMode(FileUtil p_futFileUtility) { return new Witcher2GameMode(EnvironmentInfo, p_futFileUtility); }
/// <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> /// 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 the given values. /// </summary> /// <param name="p_modOldMod">The mod from which to upgrade.</param> /// <param name="p_modNewMod">The mod to which to upgrade.</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> public ModUpgrader(IMod p_modOldMod, IMod p_modNewMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate) : base(p_modNewMod, p_gmdGameMode, p_eifEnvironmentInfo, p_futFileUtility, p_scxUIContext, p_ilgModInstallLog, p_pmgPluginManager, p_dlgOverwriteConfirmationDelegate, null, null) { OldMod = p_modOldMod; }
/// <summary> /// Starts a read-only transaction. /// </summary> /// <remarks> /// This puts the Mod into read-only mode. /// /// Read-only mode can greatly increase the speed at which multiple file are extracted. /// </remarks> public void BeginReadOnlyTransaction(FileUtil p_futFileUtil) { ReadOnlyInitProgressUpdated(this, new CancelProgressEventArgs(1f)); }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_eifEnvironmentInfo">The application's environment info.</param> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> public DarkSouls2GameMode(IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility) : base(p_eifEnvironmentInfo) { SettingsGroupViews = new List<ISettingsGroupView>(); GeneralSettingsGroup gsgGeneralSettings = new GeneralSettingsGroup(p_eifEnvironmentInfo, this); ((List<ISettingsGroupView>)SettingsGroupViews).Add(new GeneralSettingsPage(gsgGeneralSettings)); }
/// <summary> /// Starts a read-only transaction. /// </summary> /// <remarks> /// This puts the archive into read-only mode. /// </remarks> /// <param name="p_futFileUtil">An instance of a <see cref="FileUtil"/> class.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="p_futFileUtil"/> is <c>null</c>.</exception> public void BeginReadOnlyTransaction(FileUtil p_futFileUtil) { if (m_szeReadOnlyExtractor == null) { if (p_futFileUtil == null) throw new ArgumentNullException("p_futFileUtil"); m_szeReadOnlyExtractor = GetThreadSafeExtractor(m_strPath); if (m_szeReadOnlyExtractor.IsSolid) { m_szeReadOnlyExtractor.Dispose(); m_szeReadOnlyExtractor = null; m_strReadOnlyTempDirectory = p_futFileUtil.CreateTempDirectory(); using (SevenZipExtractor szeExtractor = Archive.GetExtractor(m_strPath)) { szeExtractor.FileExtractionFinished += new EventHandler<FileInfoEventArgs>(FileExtractionFinished); szeExtractor.ExtractArchive(m_strReadOnlyTempDirectory); } } } }
/// <summary> /// Builds the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <param name="p_imsWarning">The resultant warning resultant from the creation of the game mode. /// <c>null</c> if there are no warnings.</param> /// <returns>The game mode.</returns> public IGameMode BuildGameMode(FileUtil p_futFileUtility, out ViewMessage p_imsWarning) { if (EnvironmentInfo.Settings.CustomGameModeSettings[GameModeDescriptor.ModeId] == null) EnvironmentInfo.Settings.CustomGameModeSettings[GameModeDescriptor.ModeId] = new PerGameModeSettings<object>(); if (!EnvironmentInfo.Settings.CustomGameModeSettings[GameModeDescriptor.ModeId].ContainsKey("AskAboutReadOnlySettingsFiles")) { EnvironmentInfo.Settings.CustomGameModeSettings[GameModeDescriptor.ModeId]["AskAboutReadOnlySettingsFiles"] = true; EnvironmentInfo.Settings.CustomGameModeSettings[GameModeDescriptor.ModeId]["UnReadOnlySettingsFiles"] = true; EnvironmentInfo.Settings.Save(); } GrimrockGameMode gmdGameMode = InstantiateGameMode(p_futFileUtility); p_imsWarning = null; return gmdGameMode; }
/// <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_tfmFileManager">The transactional file manager to use to interact with the file system.</param> /// <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 GamebryoGameSpecificValueInstaller(IMod p_modMod, IGameModeEnvironmentInfo p_gmiGameModeInfo, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate) { TouchedFiles = new Set<string>(StringComparer.OrdinalIgnoreCase); Mod = p_modMod; GameModeInfo = p_gmiGameModeInfo; InstallLog = p_ilgInstallLog; TransactionalFileManager = p_tfmFileManager; FileUtility = p_futFileUtility; m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate; }
/// <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 abstract IGameSpecificValueInstaller GetGameSpecificValueUpgradeInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate);
/// <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_tfmFileManager">The transactional file manager to use to interact with the file system.</param> /// <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 GamebryoGameSpecificValueUpgradeInstaller(IMod p_modMod, IGameModeEnvironmentInfo p_gmiGameModeInfo, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, FileUtil p_futFileUtility, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate) :base(p_modMod, p_gmiGameModeInfo, p_ilgInstallLog, p_tfmFileManager, p_futFileUtility, p_dlgOverwriteConfirmationDelegate) { OriginallyInstalledEdits = new Set<string>(); OriginallyInstalledEdits.AddRange(InstallLog.GetInstalledGameSpecificValueEdits(Mod)); }
/// <summary> /// Setup for the plugin management libraries. /// </summary> protected virtual void SetupPluginManagement(FileUtil p_futFileUtility) { string strPath = EnvironmentInfo.ApplicationPersonalDataFolderPath; strPath = Path.Combine(Path.Combine(Path.Combine(strPath, "loot"), ModeId), "masterlist.yaml"); if (SupportsPluginAutoSorting) { if (!File.Exists(strPath)) { if (!Directory.Exists(strPath)) Directory.CreateDirectory(Path.GetDirectoryName(strPath)); using (Stream masterlist = new MemoryStream(Properties.Resources.masterlist)) { using (ZipArchive archive = new ZipArchive(masterlist, ZipArchiveMode.Read)) { archive.GetEntry(String.Format("{0}.yaml", ModeId.ToLower())).ExtractToFile(strPath); } } } PluginSorter = new PluginSorter(EnvironmentInfo, this, p_futFileUtility, strPath); } PluginOrderManager = new PluginOrderManager(EnvironmentInfo, this, p_futFileUtility); }
/// <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_gmdGameMode">The game mode for which plugins are being managed.</param> /// <param name="p_futFileUtility">The file utility class.</param> /// <param name="p_strMasterlistPath">The path to the masterlist file to use.</param> public PluginOrderManager(IEnvironmentInfo p_eifEnvironmentInfo, GamebryoGameModeBase p_gmdGameMode, FileUtil p_futFileUtility) { EnvironmentInfo = p_eifEnvironmentInfo; GameMode = p_gmdGameMode; FileUtility = p_futFileUtility; InitializeManager(); }
/// <summary> /// Instantiates the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <returns>The game mode for which this is a factory.</returns> protected override GamebryoGameModeBase InstantiateGameMode(FileUtil p_futFileUtility) { return new MorrowindGameMode(EnvironmentInfo, p_futFileUtility); }
/// <summary> /// Starts a read-only transaction. /// </summary> /// <remarks> /// This puts the OMod into read-only mode. /// /// Read-only mode can greatly increase the speed at which multiple file are extracted. /// </remarks> public void BeginReadOnlyTransaction(FileUtil p_futFileUtil) { if (!IsPacked) { m_arcFile.ReadOnlyInitProgressUpdated += new CancelProgressEventHandler(ArchiveFile_ReadOnlyInitProgressUpdated); m_arcFile.BeginReadOnlyTransaction(p_futFileUtil); return; } m_strReadOnlyTempDirectory = p_futFileUtil.CreateTempDirectory(); string[] strFileStreamNames = { "plugins", "data" }; List<FileInfo> lstFiles = null; byte[] bteUncompressedFileData = null; m_intReadOnlyInitFileBlockExtractionCurrentStage = 0; m_fltReadOnlyInitCurrentBaseProgress = 0; foreach (string strFileStreamName in strFileStreamNames) { //extract the compressed file block... using (Stream stmCompressedFiles = new MemoryStream()) { using (SevenZipExtractor szeOmod = new SevenZipExtractor(m_strFilePath)) { if (!szeOmod.ArchiveFileNames.Contains(strFileStreamName)) continue; m_intReadOnlyInitFileBlockExtractionCurrentStage++; szeOmod.ExtractFile(strFileStreamName, stmCompressedFiles); switch (strFileStreamName) { case "plugins": lstFiles = PluginList; break; case "data": lstFiles = DataFileList; break; default: throw new Exception("Unexpected value for file stream name: " + strFileStreamName); } } stmCompressedFiles.Position = 0; Int64 intTotalLength = lstFiles.Sum(x => x.Length); bteUncompressedFileData = new byte[intTotalLength]; switch (CompressionType) { case InArchiveFormat.SevenZip: byte[] bteProperties = new byte[5]; stmCompressedFiles.Read(bteProperties, 0, 5); Decoder dcrDecoder = new Decoder(); dcrDecoder.SetDecoderProperties(bteProperties); DecoderProgressWatcher dpwWatcher = new DecoderProgressWatcher(stmCompressedFiles.Length); dpwWatcher.ProgressUpdated += new EventHandler<EventArgs<int>>(dpwWatcher_ProgressUpdated); using (Stream stmUncompressedFiles = new MemoryStream(bteUncompressedFileData)) dcrDecoder.Code(stmCompressedFiles, stmUncompressedFiles, stmCompressedFiles.Length - stmCompressedFiles.Position, intTotalLength, dpwWatcher); break; case InArchiveFormat.Zip: using (SevenZipExtractor szeZip = new SevenZipExtractor(stmCompressedFiles)) { szeZip.Extracting += new EventHandler<ProgressEventArgs>(szeZip_Extracting); using (Stream stmFile = new MemoryStream(bteUncompressedFileData)) { szeZip.ExtractFile(0, stmFile); } } break; default: throw new Exception("Cannot get files: unsupported compression type: " + CompressionType.ToString()); } } float fltFileStreamPercentBlockSize = FILE_BLOCK_EXTRACTION_PROGRESS_BLOCK_SIZE / m_intReadOnlyInitFileBlockExtractionStages; float fltFileWritingPercentBlockSize = FILE_WRITE_PROGRESS_BLOCK_SIZE / m_intReadOnlyInitFileBlockExtractionStages; m_fltReadOnlyInitCurrentBaseProgress += fltFileStreamPercentBlockSize; //...then write each file to the temporary location Int64 intFileStart = 0; byte[] bteFile = null; Crc32 crcChecksum = new Crc32(); for (Int32 i = 0; i < lstFiles.Count; i++) { FileInfo ofiFile = lstFiles[i]; bteFile = new byte[ofiFile.Length]; Array.Copy(bteUncompressedFileData, intFileStart, bteFile, 0, ofiFile.Length); intFileStart += ofiFile.Length; FileUtil.WriteAllBytes(Path.Combine(m_strReadOnlyTempDirectory, ofiFile.Name), bteFile); crcChecksum.Initialize(); crcChecksum.ComputeHash(bteFile); if (crcChecksum.CrcValue != ofiFile.CRC) throw new Exception(String.Format("Unable to extract {0}: checksums did not match. OMod is corrupt.", ofiFile.Name)); UpdateReadOnlyInitProgress(m_fltReadOnlyInitCurrentBaseProgress, fltFileWritingPercentBlockSize, i / lstFiles.Count); } m_fltReadOnlyInitCurrentBaseProgress += fltFileWritingPercentBlockSize; } m_fltReadOnlyInitCurrentBaseProgress = FILE_BLOCK_EXTRACTION_PROGRESS_BLOCK_SIZE + FILE_WRITE_PROGRESS_BLOCK_SIZE; Int32 intRemainingSteps = (m_booHasInstallScript ? 1 : 0) + (m_booHasReadme ? 1 : 0) + (m_booHasScreenshot ? 1 : 0); Int32 intStepCounter = 1; if (m_booHasScreenshot) { File.WriteAllBytes(Path.Combine(m_strReadOnlyTempDirectory, ScreenshotPath), GetSpecialFile(ScreenshotPath)); UpdateReadOnlyInitProgress(m_fltReadOnlyInitCurrentBaseProgress, 1f - m_fltReadOnlyInitCurrentBaseProgress, 1f / intRemainingSteps * intStepCounter++); } if (m_booHasInstallScript) { File.WriteAllBytes(Path.Combine(m_strReadOnlyTempDirectory, "script"), GetSpecialFile("script")); UpdateReadOnlyInitProgress(m_fltReadOnlyInitCurrentBaseProgress, 1f - m_fltReadOnlyInitCurrentBaseProgress, 1f / intRemainingSteps * intStepCounter++); } if (m_booHasReadme) { File.WriteAllBytes(Path.Combine(m_strReadOnlyTempDirectory, "readme"), GetSpecialFile("readme")); UpdateReadOnlyInitProgress(m_fltReadOnlyInitCurrentBaseProgress, 1f - m_fltReadOnlyInitCurrentBaseProgress, 1f / intRemainingSteps * intStepCounter); } }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_eifEnvironmentInfo">The application's environment info.</param> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> public Fallout3GameMode(IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility) : base(p_eifEnvironmentInfo, p_futFileUtility) { }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param> /// <param name="p_futFileUtility">The file utility class.</param> public SDPArchives(IGameModeEnvironmentInfo p_gmiGameModeInfo, FileUtil p_futFileUtility) { m_gmiGameModeInfo = p_gmiGameModeInfo; m_futFileUtility = p_futFileUtility; }
/// <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_gmdGameMode">The game mode for which plugins are being managed.</param> /// <param name="p_futFileUtility">The file utility class.</param> /// <param name="p_strMasterlistPath">The path to the masterlist file to use.</param> public PluginSorter(IEnvironmentInfo p_eifEnvironmentInfo, GamebryoGameModeBase p_gmdGameMode, FileUtil p_futFileUtility, string p_strMasterlistPath) { EnvironmentInfo = p_eifEnvironmentInfo; GameMode = p_gmdGameMode; FileUtility = p_futFileUtility; string strSorterAPIPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "data"), p_eifEnvironmentInfo.Is64BitProcess ? "loot64.dll" : "loot32.dll"); m_ptrSorterApi = LoadLibrary(strSorterAPIPath); if (m_ptrSorterApi == IntPtr.Zero) throw new SorterException(String.Format("Could not load BAPI library: {0}", strSorterAPIPath)); LoadMethods(); m_ptrSorterDb = CreateSorterDb(); if (m_ptrSorterDb == IntPtr.Zero) m_booInitialized = false; else { MasterlistPath = p_strMasterlistPath; string strUserList = Path.Combine(Path.GetDirectoryName(p_strMasterlistPath), "userlist.yaml"); if (File.Exists(strUserList)) UserlistPath = strUserList; else UserlistPath = null; if (!String.IsNullOrEmpty(MasterlistPath) && File.Exists(MasterlistPath)) Load(MasterlistPath, UserlistPath); m_booInitialized = true; } }
/// <summary> /// Instantiates the game mode. /// </summary> /// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param> /// <returns>The game mode for which this is a factory.</returns> protected DragonAge2GameMode InstantiateGameMode(FileUtil p_futFileUtility) { return new DragonAge2GameMode(EnvironmentInfo, p_futFileUtility); }