Exemplo n.º 1
0
 // 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));
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }