Пример #1
0
        public static void ValidateAndFix(CustomLoadOrder loadOrder)
        {
            if (!loadOrder.Mods.Any())
            {
                return;
            }

            var mergedModName = Paths.RetrieveMergedModName();
            var mergedMod     = loadOrder.Mods.Find(m => m.ModName.EqualsIgnoreCase(mergedModName));

            if (mergedMod != null && mergedMod == loadOrder.GetTopPriorityEnabledMod())
            {
                return;
            }

            var choice = PromptToPrioritizeMergedMod(loadOrder.FilePath);

            if (choice == DialogResult.Yes)
            {
                PrioritizeMergedMod(loadOrder, mergedMod);
            }
            else if (choice == DialogResult.Cancel)  // Never
            {
                Program.Settings.Set("ValidateCustomLoadOrder", false);
                Program.Settings.Save();
            }
        }
Пример #2
0
        static void IncrementLeadingContiguousPriorities(CustomLoadOrder loadOrder, int startingPriority)
        {
            var nextPriority    = startingPriority + 1;
            var modsToIncrement = loadOrder.Mods.Where(mod => mod.Priority == startingPriority).ToArray();
            var displacedMods   = loadOrder.Mods.Where(mod => mod.Priority == nextPriority).ToArray();

            if (!modsToIncrement.Any())
            {
                return;
            }

            if (displacedMods.Any() &&
                nextPriority < CustomLoadOrder.BottomPriority)
            {
                IncrementLeadingContiguousPriorities(loadOrder, nextPriority);
            }

            foreach (var mod in modsToIncrement)
            {
                ++mod.Priority;
            }
        }
Пример #3
0
        static void PrioritizeMergedMod(CustomLoadOrder loadOrder, ModLoadSetting mergedModSetting)
        {
            // Priority of min - 1 will be incremented to min
            var priority = CustomLoadOrder.TopPriority - 1;

            if (mergedModSetting != null)
            {
                mergedModSetting.IsEnabled = true;
                mergedModSetting.Priority  = priority;
            }
            else
            {
                loadOrder.Mods.Insert(0, new ModLoadSetting
                {
                    ModName   = Paths.RetrieveMergedModName(),
                    IsEnabled = true,
                    Priority  = priority
                });
            }

            IncrementLeadingContiguousPriorities(loadOrder, priority);

            loadOrder.Save();
        }