Exemple #1
0
        private static void ActivateMods(CommandLine commandLine)
        {
            var mods     = new ModCollection();
            var modpacks = new ModpackCollection();

            ModManager.BeginUpdateTemplates();
            Mod.LoadMods(mods, modpacks);
            ModpackTemplateList.Instance.PopulateModpackList(mods, modpacks, null);

            mods.ForEach(mod => mod.Active = false);

            string modpackName;

            if (commandLine.TryGetArgument('p', "modpack", out modpackName))
            {
                Modpack modpack = modpacks.Find(modpackName);
                if (modpack != null)
                {
                    modpack.Active = true;
                }
                else
                {
                    MessageBox.Show(
                        $"No modpack named '{modpackName}' found.\nThe game will be launched without any mods enabled.",
                        "Error loading modpack!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            ModManager.EndUpdateTemplates(true);
            ModManager.SaveTemplates();
        }
Exemple #2
0
        private Mod GetMod(ModCollection modList, ModpackTemplateMod modTemplate)
        {
            Mod result = null;

            if (!(modTemplate.UsesExactVersion && modList.TryGetMod(modTemplate.Name, modTemplate.Version, out result)))
            {
                var candidates = modList.Find(modTemplate.Name, modTemplate.FactorioVersion);
                if (!candidates.Any())
                {
                    candidates = modList.Find(modTemplate.Name);
                }

                result = candidates.MaxBy(mod => mod.Version, new VersionComparer());
            }

            return(result);
        }
Exemple #3
0
        public void PopulateModpackList(ModCollection modList, ModpackCollection modpackList, IEditableCollectionView modpackView)
        {
            foreach (var template in Modpacks)
            {
                var modpack = new Modpack(template.Name, template.IsLocked, modpackList);
                if (modpackView != null)
                {
                    modpack.ParentView = modpackView;
                }

                foreach (ModpackTemplateMod modTemplate in template.Mods)
                {
                    Mod mod = GetMod(modList, modTemplate);
                    if (mod != null)
                    {
                        modpack.Mods.Add(new ModReference(mod, modpack));
                    }
                }

                modpackList.Add(modpack);
            }

            foreach (var modpack in modpackList)
            {
                ModpackTemplate template = GetTemplate(modpack.Name);

                foreach (string modpackName in template.Modpacks)
                {
                    Modpack subModpack = GetModpack(modpackList, modpackName);
                    var     reference  = new ModpackReference(subModpack, modpack);
                    reference.ParentView = modpack.ModsView;
                    if (subModpack != null)
                    {
                        modpack.Mods.Add(reference);
                    }
                }
            }
        }