Exemplo n.º 1
0
        /// <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)));
        }
Exemplo n.º 2
0
 public MissingModException(ModKey key, string message)
     : base(message)
 {
     ModPath = new ModPath(key, string.Empty);
 }
Exemplo n.º 3
0
 public MissingModException(ModKey key)
 {
     ModPath = new ModPath(key, string.Empty);
 }
Exemplo n.º 4
0
 public MissingModException(ModPath path, string message)
     : base(message)
 {
     ModPath = path;
 }
Exemplo n.º 5
0
 public MissingModException(ModPath path)
 {
     ModPath = path;
 }
Exemplo n.º 6
0
        public static IModGetter Importer(ModPath path, GameRelease release)
        {
            var regis = release.ToCategory().ToModRegistration();

            return(ModInstantiatorReflection.GetOverlay(regis)(path, release));
        }
Exemplo n.º 7
0
 public MissingModException(ModPath path, string?message)
     : base(message)
 {
     ModPaths = path.AsEnumerable().ToArray();
 }
Exemplo n.º 8
0
 public MissingModException(ModPath path)
 {
     ModPaths = path.AsEnumerable().ToArray();
 }