private int ProcessMods(Cache cache, MergeOrder order, List <string> modFilter = null) { mLogger.Information("Processing mods"); var filteredMods = new List <(int Index, ModInfo ModInfo)>(); // Iterate over mods foreach (var mod in mModDb.Mods) { // TODO: maybe use a GUID instead of the title for matching if (modFilter == null || modFilter.Contains(mod.Title)) { var index = modFilter.FindIndex(x => x.Equals(mod.Title, StringComparison.InvariantCultureIgnoreCase)); filteredMods.Add((index, mod)); } } // Order the mods we collected based on their index in the filter list var orderedMods = order == MergeOrder.TopToBottom ? filteredMods.OrderBy(x => x.Index) : filteredMods.OrderByDescending(x => x.Index); foreach (var mod in orderedMods) { mLogger.Information($"Processing mod {mod.ModInfo.Title}"); var modFilesDir = new DirectoryFileSystem(mLogger, mod.ModInfo.FilesDir); ProcessModDir(mod.ModInfo, modFilesDir, cache, ".", ModDirectoryType.Normal); } return(filteredMods.Count); }
public Patcher(ILogger logger, PatcherConfig configuration, ModDb modDb) { mLogger = logger; mConfiguration = configuration; mModDb = modDb; mLogger.Information("Validating configuration"); if (!ValidateConfig()) { throw new ArgumentException("Invalid configuration", nameof(configuration)); } mOutDir = new DirectoryFileSystem(mLogger, mConfiguration.OutDir); mFilesDir = new DirectoryFileSystem(mLogger, mConfiguration.FilesDir); mCacheFilesDir = new DirectoryFileSystem(mLogger, Path.GetFullPath(Path.Combine(mConfiguration.CacheDir, "files"))); mBinDir = new DirectoryFileSystem(mLogger, mConfiguration.BinDir); }