internal static List <string> GetInstalledDLC(GameTarget target, bool includeDisabled = false) { var dlcDirectory = MEDirectories.DLCPath(target); if (Directory.Exists(dlcDirectory)) { return(Directory.GetDirectories(dlcDirectory).Where(x => Path.GetFileName(x).StartsWith("DLC_") || (includeDisabled && Path.GetFileName(x).StartsWith("xDLC_"))).Select(x => Path.GetFileName(x)).ToList()); } return(new List <string>()); }
public static Dictionary <string, int> GetMountPriorities(GameTarget selectedTarget) { //make dictionary from basegame files var dlcmods = VanillaDatabaseService.GetInstalledDLCMods(selectedTarget); var mountMapping = new Dictionary <string, int>(); foreach (var dlc in dlcmods) { var mountpath = Path.Combine(MEDirectories.DLCPath(selectedTarget), dlc); try { mountMapping[dlc] = MELoadedFiles.GetMountPriority(mountpath, selectedTarget.Game); } catch (Exception e) { Log.Error($"Exception getting mount priority from file: {mountpath}: {e.Message}"); } } return(mountMapping); }
/// <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 Dictionary <string, string> GetFilesLoadedInGame(Mod.MEGame game, bool forceReload = false, bool includeTFC = false) { if (!forceReload) { if (game == Mod.MEGame.ME1 && cachedME1LoadedFiles != null) { return(cachedME1LoadedFiles); } if (game == Mod.MEGame.ME2 && cachedME2LoadedFiles != null) { return(cachedME2LoadedFiles); } if (game == Mod.MEGame.ME3 && cachedME3LoadedFiles != null) { return(cachedME3LoadedFiles); } } //make dictionary from basegame files var loadedFiles = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase); foreach (string directory in GetEnabledDLC(game).OrderBy(dir => GetMountPriority(dir, game)).Prepend(MEDirectories.BioGamePath(game))) { foreach (string filePath in GetCookedFiles(game, directory, includeTFC)) { string fileName = Path.GetFileName(filePath); if (fileName != null) { loadedFiles[fileName] = filePath; } } } if (game == Mod.MEGame.ME1) { cachedME1LoadedFiles = loadedFiles; } if (game == Mod.MEGame.ME2) { cachedME2LoadedFiles = loadedFiles; } if (game == Mod.MEGame.ME3) { cachedME3LoadedFiles = loadedFiles; } return(loadedFiles); }
/// <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> GetEnabledDLC(GameTarget target, string directoryOverride = null) => Directory.Exists(MEDirectories.DLCPath(target)) ? Directory.EnumerateDirectories(directoryOverride ?? MEDirectories.DLCPath(target)).Where(dir => IsEnabledDLC(dir, target.Game)) : Enumerable.Empty <string>();
/// <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> GetEnabledDLC(Mod.MEGame game, string directoryOverride = null) => Directory.Exists(MEDirectories.DLCPath(game)) ? Directory.EnumerateDirectories(directoryOverride ?? MEDirectories.DLCPath(game)).Where(dir => IsEnabledDLC(dir, game)) : Enumerable.Empty <string>();
public static IEnumerable <string> GetAllFiles(Mod.MEGame game) => GetEnabledDLC(game).Prepend(MEDirectories.BioGamePath(game)).SelectMany(directory => GetCookedFiles(game, directory));