Ejemplo n.º 1
0
        public void Install(ModList onlineMods, bool installProfileVersions)
        {
            foreach (ProfileEntry entry in entries)
            {
                Mod mod = onlineMods.Find(entry.fullName);

                if (mod != null)
                {
                    ModManager.ActivateMod(mod, installProfileVersions ? entry.version : null);
                }
                else
                {
                    MessageBox.Show($"Could not find mod \"{entry.fullName}\"!", "Profile Load Error", MessageBoxButton.OK);
                }
            }
        }
Ejemplo n.º 2
0
        public static void InstallMod(Mod mod, string version = null)
        {
            ModInstallStarted(mod);

            if (_priorityInstalls.Count > 0 && !_priorityInstalls.Contains(mod.fullName))
            {
                _installQueue.Enqueue(mod);
                return;
            }

            foreach (string dependency in mod.dependencies)
            {
                string[] tokens             = dependency.Split('-');
                string   dependencyFullName = tokens[0] + '-' + tokens[1];

                if (onlineModList != null)
                {
                    Mod dependencyMod = onlineModList.Find(dependencyFullName);

                    if (dependencyMod == null)
                    {
                        MessageBox.Show($"Error: Somehow, the dependency \"{dependency}\" could not be found in the online mod list.\nHmm... maybe you could try refreshing the online mod list?", "Uh oh", MessageBoxButton.OK);
                    }
                    else if (!dependencyMod.CheckIfInstalled())
                    {
                        MessageBoxResult result = MessageBoxResult.Yes;

                        _priorityInstalls.Add(dependencyFullName);

                        if (!silent)
                        {
                            result = MessageBox.Show(
                                $"This mod depends on \"{dependency}\".\nDo you want to install this first?",
                                "You must install additional mods", MessageBoxButton.YesNo);
                        }

                        if (result == MessageBoxResult.Yes)
                        {
                            ActivateMod(dependencyMod);
                            _installQueue.Enqueue(mod);
                            return;
                        }
                        else
                        {
                            _priorityInstalls.Remove(dependencyFullName);
                        }
                    }
                }
            }

            mod.Install();

            ModInstallFinished(mod);

            _priorityInstalls.Remove(mod.fullName);

            if (_installQueue.Count > 0)
            {
                InstallMod(_installQueue.Dequeue());
            }

            UpdateInstalledStatuses();
        }