/// <summary> /// Constructs a load order from a list of mods and a data folder. /// Load Order is sorted to the order the game will load the mod files: by file's date modified timestamp. /// </summary> /// <param name="incomingLoadOrder">Mods to include</param> /// <param name="dataPath">Path to data folder</param> /// <param name="throwOnMissingMods">Whether to throw and exception if mods are missing</param> /// <returns>Enumerable of modkeys in load order, excluding missing mods</returns> /// <exception cref="MissingModException">If throwOnMissingMods true and file is missing</exception> public static IEnumerable <LoadOrderListing> AlignToTimestamps( IEnumerable <LoadOrderListing> incomingLoadOrder, DirectoryPath dataPath, bool throwOnMissingMods = true) { var list = new List <(bool Enabled, ModKey ModKey, DateTime Write)>(); foreach (var key in incomingLoadOrder) { ModPath modPath = new ModPath(key.ModKey, Path.Combine(dataPath.Path, key.ModKey.FileName)); if (!File.Exists(modPath.Path)) { if (throwOnMissingMods) { throw new MissingModException(modPath); } continue; } list.Add((key.Enabled, key.ModKey, File.GetLastWriteTime(modPath.Path))); } var comp = new LoadOrderTimestampComparer(incomingLoadOrder.Select(i => i.ModKey).ToList()); return(list .OrderBy(i => (i.ModKey, i.Write), comp) .Select(i => new LoadOrderListing(i.ModKey, i.Enabled))); }
public MissingModException(ModKey key, string message) : base(message) { ModPath = new ModPath(key, string.Empty); }
public MissingModException(ModKey key) { ModPath = new ModPath(key, string.Empty); }
public MissingModException(ModPath path, string message) : base(message) { ModPath = path; }
public MissingModException(ModPath path) { ModPath = path; }
public static IModGetter Importer(ModPath path, GameRelease release) { var regis = release.ToCategory().ToModRegistration(); return(ModInstantiatorReflection.GetOverlay(regis)(path, release)); }
public MissingModException(ModPath path, string?message) : base(message) { ModPaths = path.AsEnumerable().ToArray(); }
public MissingModException(ModPath path) { ModPaths = path.AsEnumerable().ToArray(); }