private void Download() { ProgressScreen ps = new ProgressScreen($"Downloading {mod.identifier}"); NetAsyncModulesDownloader dl = new NetAsyncModulesDownloader(ps); ModuleInstaller inst = ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, ps); LaunchSubScreen( ps, () => { try { dl.DownloadModules(manager.Cache, new List <CkanModule> { mod }); if (!manager.Cache.IsMaybeCachedZip(mod)) { ps.RaiseError("Download failed, file is corrupted"); } } catch (Exception ex) { ps.RaiseError($"Download failed: {ex}"); } } ); // Don't let the installer re-use old screen references inst.User = null; }
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); }
/// <summary> /// Let the user choose some zip files, then import them to the mod cache. /// </summary> /// <param name="gameInst">Game instance to import into</param> /// <param name="cp">Change plan object for marking things to be installed</param> public static void ImportDownloads(KSP gameInst, ChangePlan cp) { ConsoleFileMultiSelectDialog cfmsd = new ConsoleFileMultiSelectDialog( "Import Downloads", FindDownloadsPath(gameInst), "*.zip", "Import" ); HashSet<FileInfo> files = cfmsd.Run(); if (files.Count > 0) { ProgressScreen ps = new ProgressScreen("Importing Downloads", "Calculating..."); ModuleInstaller inst = ModuleInstaller.GetInstance(gameInst, ps); ps.Run(() => inst.ImportFiles(files, ps, (CkanModule mod) => cp.Install.Add(mod))); // Don't let the installer re-use old screen references inst.User = null; } }
/// <summary> /// Let the user choose some zip files, then import them to the mod cache. /// </summary> /// <param name="theme">The visual theme to use to draw the dialog</param> /// <param name="gameInst">Game instance to import into</param> /// <param name="cache">Cache object to import into</param> /// <param name="cp">Change plan object for marking things to be installed</param> public static void ImportDownloads(ConsoleTheme theme, GameInstance gameInst, NetModuleCache cache, ChangePlan cp) { ConsoleFileMultiSelectDialog cfmsd = new ConsoleFileMultiSelectDialog( "Import Downloads", FindDownloadsPath(gameInst), "*.zip", "Import" ); HashSet <FileInfo> files = cfmsd.Run(theme); if (files.Count > 0) { ProgressScreen ps = new ProgressScreen("Importing Downloads", "Calculating..."); ModuleInstaller inst = new ModuleInstaller(gameInst, cache, ps); ps.Run(theme, (ConsoleTheme th) => inst.ImportFiles(files, ps, (CkanModule mod) => cp.Install.Add(mod), RegistryManager.Instance(gameInst).registry)); // Don't let the installer re-use old screen references inst.User = null; } }