Ejemplo n.º 1
0
        private bool UpdateRegistry(ConsoleTheme theme, bool showNewModsPrompt = true)
        {
            ProgressScreen ps = new ProgressScreen("Updating Registry", "Checking for updates");

            LaunchSubScreen(theme, ps, (ConsoleTheme th) => {
                HashSet <string> availBefore = new HashSet <string>(
                    Array.ConvertAll <CkanModule, string>(
                        registry.CompatibleModules(
                            manager.CurrentInstance.VersionCriteria()
                            ).ToArray(),
                        (l => l.identifier)
                        )
                    );
                recent.Clear();
                try {
                    Repo.UpdateAllRepositories(
                        RegistryManager.Instance(manager.CurrentInstance),
                        manager.CurrentInstance,
                        manager.Cache,
                        ps
                        );
                } catch (ReinstallModuleKraken rmk) {
                    ChangePlan reinstPlan = new ChangePlan();
                    foreach (CkanModule m in rmk.Modules)
                    {
                        reinstPlan.ToggleUpgrade(m);
                    }
                    LaunchSubScreen(theme, new InstallScreen(manager, reinstPlan, debug));
                } catch (Exception ex) {
                    // There can be errors while you re-install mods with changed metadata
                    ps.RaiseError(ex.Message + ex.StackTrace);
                }
                // Update recent with mods that were updated in this pass
                foreach (CkanModule mod in registry.CompatibleModules(
                             manager.CurrentInstance.VersionCriteria()
                             ))
                {
                    if (!availBefore.Contains(mod.identifier))
                    {
                        recent.Add(mod.identifier);
                    }
                }
            });
            if (showNewModsPrompt && recent.Count > 0 && RaiseYesNoDialog(newModPrompt(recent.Count)))
            {
                searchBox.Clear();
                moduleList.FilterString = searchBox.Value = "~n";
            }
            RefreshList(theme);
            return(true);
        }