public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { string strPath = p_strPath; if (!strPath.StartsWith("mod", StringComparison.CurrentCulture)) { if (strPath.StartsWith("content", StringComparison.InvariantCultureIgnoreCase)) { string strModName = CleanInput(p_modMod.ModName); if (String.IsNullOrEmpty(strModName)) { strModName = CleanInput(Path.GetFileNameWithoutExtension(p_modMod.Filename)); } strModName = "mod" + strModName; strPath = Path.Combine(strModName, strPath); } else { throw new InvalidDataException("This mod file was not created with the Witcher 3 Modding tools or " + "does not have the correct file structure for a Witcher 3 mod that NMM can use. It will not work with NMM."); } } return(strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; string fileExtension = Path.GetExtension(strPath); if (_unusedExtensions.Contains(fileExtension, StringComparer.InvariantCultureIgnoreCase)) { return(string.Empty); } if (!strPath.StartsWith("Tray", StringComparison.InvariantCultureIgnoreCase) && !strPath.StartsWith("Mods", StringComparison.InvariantCultureIgnoreCase) && !strPath.StartsWith("saves", StringComparison.InvariantCultureIgnoreCase)) { int subCount = strPath.Count(c => c == Path.DirectorySeparatorChar); if (subCount >= 2) { strPath = strPath.Substring(strPath.IndexOf(Path.DirectorySeparatorChar) + 1); } if (_trayExtensions.Contains(fileExtension, StringComparer.InvariantCultureIgnoreCase)) { strPath = Path.Combine("Tray", strPath); } else if (_saveExtensions.Contains(fileExtension, StringComparer.InvariantCultureIgnoreCase)) { strPath = Path.Combine("saves", strPath); } else { strPath = Path.Combine("Mods", strPath); } } return(strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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_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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, bool p_booIgnoreIfPresent) { if ((p_mftModFormat != null) && (p_mftModFormat.Id.Equals("FOMod") || p_mftModFormat.Id.Equals("OMod"))) { if (p_booIgnoreIfPresent && !String.IsNullOrEmpty(p_strPath) && (p_strPath.StartsWith("Data" + Path.DirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase) || p_strPath.StartsWith("Data" + Path.AltDirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase))) { return(p_strPath.Substring(5)); } else if (!p_booIgnoreIfPresent && !String.IsNullOrEmpty(p_strPath) && !p_strPath.StartsWith("Data" + Path.DirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase) && !p_strPath.StartsWith("Data" + Path.AltDirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase)) { return(Path.Combine("Data", p_strPath ?? "")); } else if (!p_booIgnoreIfPresent && String.IsNullOrEmpty(p_strPath)) { return(Path.Combine("Data", p_strPath ?? "")); } } else if (p_mftModFormat == null) { if (p_booIgnoreIfPresent && !String.IsNullOrEmpty(p_strPath) && (p_strPath.StartsWith("Data" + Path.DirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase) || p_strPath.StartsWith("Data" + Path.AltDirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase))) { return(p_strPath.Substring(5)); } else if (!p_booIgnoreIfPresent && !String.IsNullOrEmpty(p_strPath) && !p_strPath.StartsWith("Data" + Path.DirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase) && !p_strPath.StartsWith("Data" + Path.AltDirectorySeparatorChar, System.StringComparison.InvariantCultureIgnoreCase)) { return(Path.Combine("Data", p_strPath ?? "")); } else if (!p_booIgnoreIfPresent && String.IsNullOrEmpty(p_strPath)) { return(Path.Combine("Data", p_strPath ?? "")); } } return(p_strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { if (CheckSecondaryInstall(p_modMod)) { string strPath = String.Empty; string strModFileName = Path.GetFileNameWithoutExtension(p_modMod.Filename); if (m_dicW2ModPaths != null) { strPath = m_dicW2ModPaths.FirstOrDefault(x => x.Key == strModFileName).Value; } if (String.IsNullOrEmpty(strPath)) { strPath = Path.GetDirectoryName(p_strPath); if (String.IsNullOrEmpty(strPath)) { strPath = strModFileName; } strPath = strPath.Replace(" ", ""); m_dicW2ModPaths.Add(strModFileName, strPath); } return((String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) ? Path.Combine(strPath, p_strPath) : p_strPath); } return(p_strPath); }
/// <summary> /// Gets the specified <see cref="IModFormat"/>. /// </summary> /// <param name="p_strModFormatId">The id of the <see cref="IModFormat"/> to retrieve.</param> /// <returns>The <see cref="IModFormat"/> whose id matches the given id. <c>null</c> is returned /// if no <see cref="IModFormat"/> with the given id is in the registry.</returns> public IModFormat GetFormat(string p_strModFormatId) { IModFormat mftFormat = null; ModFormats.TryGetValue(p_strModFormatId, out mftFormat); return(mftFormat); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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 installation 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_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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, bool p_booIgnoreIfPresent) { string strPath = p_strPath; string strFileType = Path.GetExtension(strPath); string[] strSpecialFiles = new[] { "opengl32.dll", "NMSE_steam.dll", "NMSE_Core_1_0.dll" }; if (strFileType.Equals(".pak", StringComparison.InvariantCultureIgnoreCase)) { if (strPath.StartsWith("PCBANKS", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("GAMEDATA", strPath); } else { strPath = Path.Combine("GAMEDATA", "PCBANKS", Path.GetFileName(strPath)); } } else if (strSpecialFiles.Any((s) => Path.GetFileName(strPath).Equals(s, StringComparison.InvariantCultureIgnoreCase) || strFileType.Equals(".exe", StringComparison.InvariantCultureIgnoreCase))) { if (!strPath.StartsWith("Binaries")) { strPath = Path.Combine("Binaries", strPath); } } // the other mods should be handled by special mod install, this just handles the major ones return(strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { string strPath = String.Empty; string strModFileName = Path.GetFileNameWithoutExtension(p_modMod.Filename); string strModFileExtension = Path.GetExtension(p_modMod.Filename); if (strModFileExtension.Equals(".dazip", StringComparison.InvariantCultureIgnoreCase)) { if (Path.GetFileName(p_strPath).Equals("manifest.xml", StringComparison.InvariantCultureIgnoreCase)) { AddManifest(p_modMod); return(String.Empty); } if (p_strPath.StartsWith("contents", StringComparison.InvariantCultureIgnoreCase)) { strPath = p_strPath.Remove(0, 9); } } if (String.IsNullOrEmpty(strPath)) { if (String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) { strPath = strModFileName; } else { strPath = p_strPath; } } return((String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) ? Path.Combine(strPath, p_strPath) : strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath) { if (p_mftModFormat.Id.Equals("FOMod") || p_mftModFormat.Id.Equals("OMod")) { return(Path.Combine("Data", p_strPath ?? "")); } return(p_strPath); }
/// <summary> /// Searches for mod format assemblies in the specified path, and loads /// any mod formats that are found into a registry. /// </summary> /// <remarks> /// A mod format is loaded if the class implements <see cref="IModFormat"/> and is /// not abstract. Once loaded, the format is added to the registry. /// </remarks> /// <param name="p_mcmModCacheManager">The manager being used to manage mod caches.</param> /// <param name="p_stgScriptTypeRegistry">The registry listing the supported script types.</param> /// <param name="p_strSearchPath">The path in which to search for mod format assemblies.</param> /// <returns>A registry containing all of the discovered mod formats.</returns> public static IModFormatRegistry DiscoverFormats(IModCacheManager p_mcmModCacheManager, IScriptTypeRegistry p_stgScriptTypeRegistry, string p_strSearchPath) { Trace.TraceInformation("Discovering Mod Formats..."); Trace.Indent(); Trace.TraceInformation("Looking in: {0}", p_strSearchPath); IModFormatRegistry mfrRegistry = new ModFormatRegistry(); if (!Directory.Exists(p_strSearchPath)) { Trace.TraceError("Format search path does not exist."); Trace.Unindent(); return(mfrRegistry); } string[] strAssemblies = Directory.GetFiles(p_strSearchPath, "*.dll"); foreach (string strAssembly in strAssemblies) { Trace.TraceInformation("Checking: {0}", Path.GetFileName(strAssembly)); Trace.Indent(); Assembly asmGameMode = Assembly.LoadFile(strAssembly); Type[] tpeTypes = asmGameMode.GetExportedTypes(); foreach (Type tpeType in tpeTypes) { if (typeof(IModFormat).IsAssignableFrom(tpeType) && !tpeType.IsAbstract) { Trace.TraceInformation("Initializing: {0}", tpeType.FullName); Trace.Indent(); ConstructorInfo cifConstructor = tpeType.GetConstructor(new Type[] { typeof(IModCacheManager), typeof(IScriptTypeRegistry) }); IModFormat mftModFormat = null; if (cifConstructor != null) { mftModFormat = (IModFormat)cifConstructor.Invoke(new object[] { p_mcmModCacheManager, p_stgScriptTypeRegistry }); } else { cifConstructor = tpeType.GetConstructor(new Type[] { }); if (cifConstructor != null) { mftModFormat = (IModFormat)cifConstructor.Invoke(null); } } if (mftModFormat != null) { mfrRegistry.RegisterFormat(mftModFormat); } Trace.Unindent(); } } Trace.Unindent(); } Trace.Unindent(); return(mfrRegistry); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (!strPath.StartsWith("nativePC", StringComparison.InvariantCultureIgnoreCase) && !CheckIsLoaderFile(strPath)) { strPath = Path.Combine("nativePC", strPath); } return(strPath); }
public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { if (Path.GetFileName(p_strPath).Equals("info.json", StringComparison.InvariantCultureIgnoreCase)) { return(string.Empty); } else { return(p_strPath); } }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (!strPath.StartsWith("Modules")) { strPath = Path.Combine("Modules", strPath); } return(strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (!m_gmdGameModeInfo.StopFolders.Any(strPath.Contains)) { return(null); } return(strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 installation 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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (strPath.StartsWith("Content", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("Main Game", "Ellie_Ball_Project", strPath); } else { strPath = Path.Combine("Main Game", "Ellie_Ball_Project", "Content", strPath); } return(strPath); }
public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { try { // check for single folder mods if (NeedsPathAdjustForContentXml(p_modMod)) { try { // if this throws or returns null, the mod package is invalid var strModInternalName = LoadModNameInternal(p_modMod); if (string.IsNullOrEmpty(strModInternalName)) { throw new ArgumentException( "The attribute 'name' is set improperly in the file 'content.xml'."); } // JAM 2014-02-07 This Path is not taken most of the time return(Path.Combine(strModInternalName, p_strPath)); } catch (FileNotFoundException exFileNotFound) { if (exFileNotFound.FileName.Equals("content.xml")) { // return friendly error message throw new FileNotFoundException("Mod package does not include a content.xml file."); } // we don't know what this is, rethrow it. throw; } } // Used to return null for invalid paths if (!validPathForModifications(p_strPath)) { p_strPath = null; } p_strPath = getAdjustedModPath(p_strPath); return(p_strPath); } // IOEX from NeedsPathAdjust - Multiple content.xml found. catch (InvalidOperationException) { throw new InvalidDataException("This package contains multiple mods, which is not supported."); } }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (strPath.StartsWith("bin") || strPath.StartsWith("x64")) { if (strPath.StartsWith("x64", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("bin", strPath); } } else if (!strPath.StartsWith("archive", StringComparison.InvariantCultureIgnoreCase)) { string modPath = string.Empty; if (!IsOldGameVersion) { strPath = strPath.Replace("patch", "mod"); modPath = "mod"; } else { modPath = "patch"; } if (strPath.StartsWith("pc", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("archive", strPath); } else if (strPath.StartsWith(modPath, StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("archive", "pc", strPath); } else { strPath = Path.Combine("archive", "pc", modPath, strPath); } } else { if (!IsOldGameVersion) { strPath = strPath.Replace("patch", "mod"); } } return(strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = string.Empty; string strCheck = p_strPath; if (m_modLastMod != p_modMod) { m_modLastMod = p_modMod; } for (int i = 0; i <= 1; i++) { if (i == 1) { string strRoot = GetRootFolder(strCheck); int intIndex = strCheck.IndexOf(strRoot); strCheck = (intIndex < 0) ? strCheck : strCheck.Remove(intIndex, strRoot.Length + 1); } if (strCheck.StartsWith("content", StringComparison.InvariantCultureIgnoreCase) && (p_modMod != null)) { string strModName = CleanInput(p_modMod.ModName); if (string.IsNullOrEmpty(strModName)) { strModName = CleanInput(Path.GetFileNameWithoutExtension(p_modMod.Filename)); } strModName = "mod" + strModName; return(Path.Combine(strModName, strCheck)); } else { if (strCheck.StartsWith("mod", StringComparison.CurrentCulture)) { return(Path.Combine("Mods", strCheck)); } else if (strCheck.StartsWith("DLC", StringComparison.CurrentCulture)) { return(Path.Combine("DLC", strCheck)); } } } return(strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, bool p_booIgnoreIfPresent) { if ((p_mftModFormat != null) || (p_mftModFormat.Id.Equals("FOMod") || p_mftModFormat.Id.Equals("OMod"))) { if (p_strPath.StartsWith("DarkSoulsII")) { p_strPath = p_strPath.Substring(12); } else if (p_strPath.StartsWith("textures")) { p_strPath = p_strPath.Substring(21); } else if (!p_strPath.Contains("override")) { return(Path.Combine("override", p_strPath ?? "")); } } return(p_strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; if (!strPath.StartsWith("archive", StringComparison.InvariantCultureIgnoreCase)) { if (strPath.StartsWith("pc", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("archive", strPath); } else if (strPath.StartsWith("patch", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("archive", "pc", strPath); } else { strPath = Path.Combine("archive", "pc", "patch", strPath); } } return(strPath); }
/// <summary> /// Registers the given <see cref="IModFormat"/>. /// </summary> /// <param name="p_mftFormat">A <see cref="IModFormat"/> to register.</param> public void RegisterFormat(IModFormat p_mftFormat) { ModFormats[p_mftFormat.Id] = p_mftFormat; }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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> /// <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) { return(p_strPath); }
/// <summary> /// A simple constructor the sets the exception's message and inner exception. /// </summary> /// <param name="p_mftFormat">The expected mod format.</param> /// <param name="inner">The ineer exception.</param> public ModFormatException(IModFormat p_mftFormat, Exception inner) : base(String.Format(ErrorMessage, p_mftFormat.Name), inner) { }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath) { return p_strPath; }
/// <summary> /// A simple contructor that sets the exception's message. /// </summary> /// <param name="p_mftFormat">The expected mod format.</param> public ModFormatException(IModFormat p_mftFormat) : base(String.Format(ErrorMessage, p_mftFormat.Name)) { }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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> /// Builds mods from an archive. /// </summary> /// <remarks> /// If the specified archive contains mods, they are simply extracted. Otherwise, the archive /// is examined to determine if it is already in a recognized format. If not, or if the archive /// spans multiple volumes, then the archive is repackaged. /// </remarks> /// <param name="p_mfrFormats">The registry of supported mod formats.</param> /// <param name="p_strArchivePath">The archive to build into a mod.</param> /// <param name="p_dlgConfirmOverwrite">The delegate to call to resolve conflicts with existing files.</param> /// <param name="p_strMessage">The message describing the state of the task.</param> /// <returns>The paths to the new mods.</returns> /// <exception cref="ArgumentException">Thrown if the specified path is not an archive.</exception> private IList <string> DoFromArchive(IModFormatRegistry p_mfrFormats, string p_strArchivePath, ConfirmOverwriteCallback p_dlgConfirmOverwrite, out string p_strMessage) { p_strMessage = null; Trace.TraceInformation(String.Format("[{0}] Adding mod from archive.", p_strArchivePath)); if (String.IsNullOrEmpty(p_strArchivePath) || !File.Exists(p_strArchivePath) || !Archive.IsArchive(p_strArchivePath)) { throw new ArgumentException("The specified path is not an archive file.", "p_strArchivePath"); } List <string> lstFoundMods = new List <string>(); List <string> lstModsInArchive = new List <string>(); ItemMessage = "Examining archive..."; ItemProgress = 0; ItemProgressMaximum = p_mfrFormats.Formats.Count; IModFormat mftDestFormat = null; try { using (SevenZipExtractor szeExtractor = Archive.GetExtractor(p_strArchivePath)) { if (Status == TaskStatus.Cancelling) { return(lstFoundMods); } ReadOnlyCollection <string> lstArchiveFiles = szeExtractor.ArchiveFileNames; foreach (IModFormat mftFormat in p_mfrFormats.Formats) { ItemMessage = String.Format("Examining archive for {0} mods...", mftFormat.Name); lstModsInArchive.AddRange(lstArchiveFiles.Where(x => mftFormat.Extension.Equals(Path.GetExtension(x), StringComparison.OrdinalIgnoreCase))); StepItemProgress(); if (Status == TaskStatus.Cancelling) { return(lstFoundMods); } } StepOverallProgress(); } if (lstModsInArchive.Count == 0) { ItemMessage = "Determining archive format..."; ItemProgress = 0; ItemProgressMaximum = p_mfrFormats.Formats.Count; List <KeyValuePair <FormatConfidence, IModFormat> > lstFormats = new List <KeyValuePair <FormatConfidence, IModFormat> >(); foreach (IModFormat mftFormat in p_mfrFormats.Formats) { lstFormats.Add(new KeyValuePair <FormatConfidence, IModFormat>(mftFormat.CheckFormatCompliance(p_strArchivePath), mftFormat)); StepItemProgress(); if (Status == TaskStatus.Cancelling) { return(lstFoundMods); } } lstFormats.Sort((x, y) => y.Key.CompareTo(x.Key)); if ((lstFormats.Count == 0) || (lstFormats[0].Key <= FormatConfidence.Convertible)) { return(lstFoundMods); } mftDestFormat = lstFormats[0].Value; } StepOverallProgress(); } catch (Exception ex) { MessageBox.Show("An error has occured with the following archive: " + p_strArchivePath + "\n\n ERROR: " + ex.Message); return(lstFoundMods); } string strTmpPath = null; try { using (SevenZipExtractor szeExtractor = Archive.GetExtractor(p_strArchivePath)) { if ((mftDestFormat != null) && (szeExtractor.VolumeFileNames.Count > 1) || (lstModsInArchive.Count > 0)) { ItemMessage = "Extracting archive..."; ItemProgress = 0; ItemProgressMaximum = szeExtractor.ArchiveFileNames.Count; strTmpPath = FileUtility.CreateTempDirectory(); szeExtractor.FileExtractionStarted += new EventHandler <FileInfoEventArgs>(Extractor_FileExtractionStarted); szeExtractor.FileExtractionFinished += new EventHandler <FileInfoEventArgs>(Extractor_FileExtractionFinished); try { szeExtractor.ExtractArchive(strTmpPath); } catch (FileNotFoundException ex) { Status = TaskStatus.Error; p_strMessage = ex.Message; return(lstFoundMods); } for (Int32 i = 0; i < lstModsInArchive.Count; i++) { lstModsInArchive[i] = Path.Combine(strTmpPath, lstModsInArchive[i]); } } else { lstModsInArchive.Add(p_strArchivePath); } } StepOverallProgress(); if (!String.IsNullOrEmpty(strTmpPath) && (mftDestFormat != null)) { //if we have extracted the file to do format shifting if (!mftDestFormat.SupportsModCompression) { return(lstFoundMods); } ItemMessage = "Compressing mod..."; ItemProgress = 0; ItemProgressMaximum = Directory.GetFiles(strTmpPath, "*", SearchOption.AllDirectories).Length; IModCompressor mcpCompressor = mftDestFormat.GetModCompressor(EnvironmentInfo); mcpCompressor.FileCompressionFinished += new CancelEventHandler(Compressor_FileCompressionFinished); string strDest = Path.Combine(GameModeInfo.ModDirectory, Path.GetFileName(p_strArchivePath)); strDest = Path.ChangeExtension(strDest, mftDestFormat.Extension); strDest = ConfirmOverwrite(p_dlgConfirmOverwrite, strDest); if (!String.IsNullOrEmpty(strDest)) { mcpCompressor.Compress(strTmpPath, strDest); lstFoundMods.Add(strDest); } } else { ItemMessage = "Copying mods..."; ItemProgress = 0; ItemProgressMaximum = lstModsInArchive.Count; foreach (string strMod in lstModsInArchive) { if (Status == TaskStatus.Cancelling) { return(lstFoundMods); } ItemMessage = String.Format("Copying mod {0}...", Path.GetFileName(strMod)); string strDest = Path.Combine(GameModeInfo.ModDirectory, Path.GetFileName(strMod)); strDest = ConfirmOverwrite(p_dlgConfirmOverwrite, strDest); if (!String.IsNullOrEmpty(strDest)) { if (string.Equals(strMod, strDest, StringComparison.OrdinalIgnoreCase)) { throw new FileNotFoundException("You can't add a mod directly from the NMM Mods folder, please move it somewhere else before adding it to the manager!"); } File.Copy(strMod, strDest, true); lstFoundMods.Add(strDest); } StepItemProgress(); } } StepOverallProgress(); } catch (FileNotFoundException ex) { MessageBox.Show("Archive: " + p_strArchivePath + "\n\n ERROR: " + ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(lstFoundMods); } finally { if (!String.IsNullOrEmpty(strTmpPath)) { FileUtil.ForceDelete(strTmpPath); } } return(lstFoundMods); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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> /// <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) { return(GetModFormatAdjustedPath(p_mftModFormat, p_strPath)); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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 installation 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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod, bool p_booIgnoreIfPresent) { string strPath = p_strPath; string strFileType = Path.GetExtension(strPath); string[] strSpecialFiles = new[] { "opengl32.dll", "NMSE_steam.dll", "NMSE_Core_1_0.dll" }; // do normal stuff to the files if (strFileType.Equals(".pak", StringComparison.InvariantCultureIgnoreCase)) { if (strPath.StartsWith("PCBANKS", StringComparison.InvariantCultureIgnoreCase)) { if (strPath.StartsWith("PCBANKS" + Path.DirectorySeparatorChar + "MODS", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("GAMEDATA", strPath); } else { strPath = strPath.Replace("PCBANKS", Path.Combine("GAMEDATA", "PCBANKS", "MODS")); } } else if (strPath.StartsWith("MODS", StringComparison.InvariantCultureIgnoreCase)) { strPath = Path.Combine("GAMEDATA", "PCBANKS", strPath); } else { strPath = Path.Combine("GAMEDATA", "PCBANKS", "MODS", Path.GetFileName(strPath)); } } else if (strSpecialFiles.Any((s) => Path.GetFileName(strPath).Equals(s, StringComparison.InvariantCultureIgnoreCase) || strFileType.Equals(".exe", StringComparison.InvariantCultureIgnoreCase))) { if (!strPath.StartsWith("Binaries")) { strPath = Path.Combine("Binaries", strPath); } } else if (strFileType.Equals(".dll", StringComparison.InvariantCultureIgnoreCase)) { if (!strPath.StartsWith("Binaries")) { if (!strPath.StartsWith("NMSE")) { strPath = Path.Combine("Binaries", "NMSE", strPath); } else { strPath = Path.Combine("Binaries", strPath); } } } // edit files for load order if (strFileType.Equals(".pak", StringComparison.InvariantCultureIgnoreCase)) { string strFileName = Path.GetFileName(strPath); if (!strFileName.Contains("_MOD")) { strFileName = strFileName.Insert(0, "_MOD"); } bool booIsUninstall = false; // check if this is an uninstall { string strPossibleOldFile; if (p_modMod.PlaceInModLoadOrder != -1) { strPossibleOldFile = Path.Combine(Path.GetDirectoryName(strPath), strFileName.Insert(1, p_modMod.PlaceInModLoadOrder.ToString())); } else { strPossibleOldFile = Path.Combine(Path.GetDirectoryName(strPath), strFileName); } if (File.Exists(Path.Combine(InstallationPath, strPossibleOldFile))) { strPath = strPossibleOldFile; booIsUninstall = true; } } if (!booIsUninstall) { if (p_modMod.NewPlaceInModLoadOrder != -1) { strFileName = strFileName.Insert(1, p_modMod.NewPlaceInModLoadOrder.ToString()); } strPath = Path.Combine(Path.GetDirectoryName(strPath), strFileName); } } // the other mods should be handled by special mod install, this just handles the major ones return(strPath); }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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> /// <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) { return p_strPath; }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath) { if (p_mftModFormat.Id.Equals("FOMod") || p_mftModFormat.Id.Equals("OMod")) return Path.Combine("Data", p_strPath ?? ""); return p_strPath; }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath) { if (p_mftModFormat.Id.Equals("FOMod") || p_mftModFormat.Id.Equals("OMod")) if (p_strPath.StartsWith("DarkSoulsII")) p_strPath = p_strPath.Substring(12); else if (p_strPath.StartsWith("textures")) p_strPath = p_strPath.Substring(21); else if (!p_strPath.Contains("override")) return Path.Combine("override", p_strPath ?? ""); return p_strPath; }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { string strPath = String.Empty; string strModFileName = Path.GetFileNameWithoutExtension(p_modMod.Filename); string strModFileExtension = Path.GetExtension(p_modMod.Filename); if (strModFileExtension.Equals(".dazip", StringComparison.InvariantCultureIgnoreCase)) { if (Path.GetFileName(p_strPath).Equals("manifest.xml", StringComparison.InvariantCultureIgnoreCase)) { AddManifest(p_modMod); return String.Empty; } if (p_strPath.StartsWith("contents", StringComparison.InvariantCultureIgnoreCase)) strPath = p_strPath.Remove(0, 9); } if (String.IsNullOrEmpty(strPath)) { if (String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) strPath = strModFileName; else strPath = p_strPath; } return (String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) ? Path.Combine(strPath, p_strPath) : strPath; }
/// <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 <games>/data, but this new manager specifies /// the installation path to be <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> /// <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) { return GetModFormatAdjustedPath(p_mftModFormat, p_strPath); }
public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { try { // check for single folder mods if (NeedsPathAdjust(p_modMod)) { try { // if this throws or returns null, the mod package is invalid var strModInternalName = LoadModNameInternal(p_modMod); if (string.IsNullOrEmpty(strModInternalName)) throw new ArgumentException( "The attribute 'name' is set improperly in the file 'content.xml'."); return Path.Combine(strModInternalName, p_strPath); } catch (FileNotFoundException exFileNotFound) { if (exFileNotFound.FileName.Equals("content.xml")) // return friendly error message throw new FileNotFoundException("Mod package does not include a content.xml file."); // we don't know what this is, rethrow it. throw; } } return p_strPath; } // IOEX from NeedsPathAdjust - Multiple content.xml found. catch (InvalidOperationException) { throw new InvalidDataException("This package contains multiple mods, which is not supported."); } }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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_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 override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, bool p_booIgnoreIfPresent) { return(p_strPath); }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { if (CheckSecondaryInstall(p_modMod)) { string strPath = String.Empty; string strModFileName = Path.GetFileNameWithoutExtension(p_modMod.Filename); if (m_dicW2ModPaths != null) strPath = m_dicW2ModPaths.FirstOrDefault(x => x.Key == strModFileName).Value; if (String.IsNullOrEmpty(strPath)) { strPath = Path.GetDirectoryName(p_strPath); if (String.IsNullOrEmpty(strPath)) strPath = strModFileName; strPath = strPath.Replace(" ", ""); m_dicW2ModPaths.Add(strModFileName, strPath); } return (String.IsNullOrEmpty(Path.GetDirectoryName(p_strPath))) ? Path.Combine(strPath, p_strPath) : p_strPath; } return p_strPath; }
/// <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 FOMod/OMods to work. Older FOMods assumed /// the installation path of Fallout games to be <games>/data, but this new manager specifies /// the installation path to be <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> /// <returns>The given path, adjusted to be relative to the installation path of the game mode.</returns> public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath) { return(p_strPath); }
public override string GetModFormatAdjustedPath(IModFormat p_mftModFormat, string p_strPath, IMod p_modMod) { string strPath = p_strPath; if (!strPath.StartsWith("mod", StringComparison.CurrentCulture)) { if (strPath.StartsWith("content", StringComparison.InvariantCultureIgnoreCase)) { string strModName = CleanInput(p_modMod.ModName); if (String.IsNullOrEmpty(strModName)) strModName = CleanInput(Path.GetFileNameWithoutExtension(p_modMod.Filename)); strModName = "mod" + strModName; strPath = Path.Combine(strModName, strPath); } else throw new InvalidDataException("This mod file was not created with the Witcher 3 Modding tools or " + "does not have the correct file structure for a Witcher 3 mod that NMM can use. It will not work with NMM."); } return strPath; }