Beispiel #1
0
        /// <summary>
        /// Gets a list of superceding package files from the DLC of the game. Only files in DLC mods are returned
        /// </summary>
        /// <param name="target">Target to get supercedances for</param>
        /// <returns>Dictionary mapping filename to list of DLCs that contain that file, in order of highest priority to lowest</returns>
        public static Dictionary <string, List <string> > GetFileSupercedances(GameTarget target)
        {
            //make dictionary from basegame files
            var fileListMapping = new CaseInsensitiveDictionary <List <string> >();
            var directories     = MELoadedFiles.GetEnabledDLC(target).OrderBy(dir => MELoadedFiles.GetMountPriority(dir, target.Game));

            foreach (string directory in directories)
            {
                var dlc = Path.GetFileName(directory);
                if (MEDirectories.OfficialDLC(target.Game).Contains(dlc))
                {
                    continue;                                                       //skip
                }
                foreach (string filePath in MELoadedFiles.GetCookedFiles(target.Game, directory, false))
                {
                    string fileName = Path.GetFileName(filePath);
                    if (fileName != null && fileName.RepresentsPackageFilePath())
                    {
                        if (fileListMapping.TryGetValue(fileName, out var supercedingList))
                        {
                            supercedingList.Insert(0, dlc);
                        }
                        else
                        {
                            fileListMapping[fileName] = new List <string>(new[] { dlc });
                        }
                    }
                }
            }

            return(fileListMapping);
        }
Beispiel #2
0
        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);
        }