public static IEnumerable <string> GetDLCFiles(MEGame game, string dlcName) { var dlcPath = MEDirectories.GetDLCPath(game); if (dlcPath != null) { string specificDlcPath = Path.Combine(dlcPath, dlcName); if (Directory.Exists(specificDlcPath)) { return(GetCookedFiles(game, specificDlcPath)); } } return(Enumerable.Empty <string>()); }
/// <summary> /// Gets a Dictionary of all loaded files in the given game. Key is the filename, value is file path /// </summary> /// <param name="game"></param> /// <returns></returns> public static CaseInsensitiveDictionary <string> GetFilesLoadedInGame(MEGame game, bool forceReload = false, bool includeTFCs = false, bool includeAFCs = false) { if (!forceReload) { if (game == MEGame.ME1 && cachedME1LoadedFiles != null) { return(cachedME1LoadedFiles); } if (game == MEGame.ME2 && cachedME2LoadedFiles != null) { bool useCached = true; useCached &= !includeTFCs || !cachedME2LoadedFiles.Keys.Any(x => x.EndsWith(".tfc")); useCached &= !includeAFCs || !cachedME2LoadedFiles.Keys.Any(x => x.EndsWith(".afc")); if (useCached) { return(cachedME2LoadedFiles); } } if (game == MEGame.ME3 && cachedME3LoadedFiles != null) { bool useCached = true; useCached &= !includeTFCs || !cachedME3LoadedFiles.Keys.Any(x => x.EndsWith(".tfc")); useCached &= !includeAFCs || !cachedME3LoadedFiles.Keys.Any(x => x.EndsWith(".afc")); if (useCached) { return(cachedME3LoadedFiles); } } } //make dictionary from basegame files var loadedFiles = new CaseInsensitiveDictionary <string>(); if (game == MEGame.UDK) { return(loadedFiles); } var bgPath = MEDirectories.GetBioGamePath(game); if (bgPath != null) { foreach (string directory in GetEnabledDLCFolders(game).OrderBy(dir => GetMountPriority(dir, game)).Prepend(bgPath)) { foreach (string filePath in GetCookedFiles(game, directory, includeTFCs, includeAFCs)) { string fileName = Path.GetFileName(filePath); if (fileName != null) { loadedFiles[fileName] = filePath; } } } } if (game == MEGame.ME1) { cachedME1LoadedFiles = loadedFiles; } else if (game == MEGame.ME2) { cachedME2LoadedFiles = loadedFiles; } else if (game == MEGame.ME3) { cachedME3LoadedFiles = loadedFiles; } return(loadedFiles); }
public static bool IsOfficialDLC(string dir, MEGame game) { string dlcName = Path.GetFileName(dir); return(MEDirectories.OfficialDLC(game).Contains(dlcName)); }
public static IEnumerable <string> GetOfficialDLCFolders(MEGame game) => Directory.Exists(MEDirectories.GetDLCPath(game)) ? Directory.EnumerateDirectories(MEDirectories.GetDLCPath(game)).Where(dir => IsOfficialDLC(dir, game)) : Enumerable.Empty <string>();
// These methods should check DLCPath to avoid throwing exception /// <summary> /// Gets the base DLC directory of each unpacked DLC/mod that will load in game (eg. C:\Program Files (x86)\Origin Games\Mass Effect 3\BIOGame\DLC\DLC_EXP_Pack001) /// Directory Override is used to use a custom path, for things like TFC Compactor, where the directory ME3Exp is pointing to may not be the one you want to use. /// </summary> /// <returns></returns> public static IEnumerable <string> GetEnabledDLCFolders(MEGame game, string gameDirectoryOverride = null) => Directory.Exists(MEDirectories.GetDLCPath(game, gameDirectoryOverride)) ? Directory.EnumerateDirectories(MEDirectories.GetDLCPath(game, gameDirectoryOverride)).Where(dir => IsEnabledDLC(dir, game)) : Enumerable.Empty <string>();
// this should have a null check on Biogamepath to void throwing an exception public static IEnumerable <string> GetOfficialFiles(MEGame game, bool includeTFCs = false, bool includeAFCs = false) => GetOfficialDLCFolders(game).Prepend(MEDirectories.GetBioGamePath(game)).SelectMany(directory => GetCookedFiles(game, directory, includeTFCs, includeAFCs));
/// <summary> /// Gets a Dictionary of all loaded files in the given game. Key is the filename, value is file path /// </summary> /// <param name="game"></param> /// <returns></returns> public static List <string> GetAllGameFiles(string gamePath, MEGame game, bool forceReload = false, bool includeTFC = false) { if (!forceReload) { if (game == MEGame.ME1 && cachedME1TargetFiles != null) { return(cachedME1TargetFiles); } if (game == MEGame.ME2 && cachedME2TargetFiles != null) { return(cachedME2TargetFiles); } if (game == MEGame.ME3 && cachedME3TargetFiles != null) { return(cachedME3TargetFiles); } } //make dictionary from basegame files var loadedFiles = new List <string>(2000); foreach (string directory in MELoadedFiles.GetEnabledDLCFolders(game, gamePath).OrderBy(dir => GetMountPriority(dir, game)).Prepend(MEDirectories.GetBioGamePath(game, gamePath))) { foreach (string filePath in GetCookedFiles(game, directory, includeTFC)) { string fileName = Path.GetFileName(filePath); if (fileName != null) { loadedFiles.Add(filePath); } } } if (game == MEGame.ME1) { cachedME1TargetFiles = loadedFiles; } if (game == MEGame.ME2) { cachedME2TargetFiles = loadedFiles; } if (game == MEGame.ME3) { cachedME3TargetFiles = loadedFiles; } return(loadedFiles); }