private void _UpdateModsList() { Registry registry = RegistryManager.Instance(CurrentInstance).registry; var ckanModules = registry.Available(CurrentInstance.Version()).Concat( registry.Incompatible(CurrentInstance.Version())).ToList(); var gui_mods = ckanModules.Select(m => new GUIMod(m, registry, CurrentInstance.Version())).ToList(); mainModList.Modules = new ReadOnlyCollection <GUIMod>(gui_mods); var rows = MainModList.ConstructModList(mainModList.Modules); ModList.Rows.Clear(); ModList.Rows.AddRange(rows.ToArray()); ModList.Sort(ModList.Columns[2], ListSortDirection.Ascending); //TODO Consider using smart enum patten so stuff like this is easier FilterToolButton.DropDownItems[0].Text = String.Format("All ({0})", mainModList.CountModsByFilter(GUIModFilter.All)); FilterToolButton.DropDownItems[1].Text = String.Format("Installed ({0})", mainModList.CountModsByFilter(GUIModFilter.Installed)); FilterToolButton.DropDownItems[2].Text = String.Format("Updated ({0})", mainModList.CountModsByFilter(GUIModFilter.InstalledUpdateAvailable)); FilterToolButton.DropDownItems[3].Text = String.Format("New in repository ({0})", mainModList.CountModsByFilter(GUIModFilter.NewInRepository)); FilterToolButton.DropDownItems[4].Text = String.Format("Not installed ({0})", mainModList.CountModsByFilter(GUIModFilter.NotInstalled)); FilterToolButton.DropDownItems[5].Text = String.Format("Incompatible ({0})", mainModList.CountModsByFilter(GUIModFilter.Incompatible)); var has_any_updates = gui_mods.Any(mod => mod.HasUpdate); UpdateAllToolButton.Enabled = has_any_updates; UpdateFilters(this); }
public void CurrentInstanceUpdated() { Util.Invoke(this, () => { Text = String.Format("CKAN {0} - KSP {1} -- {2}", Meta.Version(), CurrentInstance.Version(), CurrentInstance.GameDir()); KSPVersionLabel.Text = String.Format("Kerbal Space Program {0}", CurrentInstance.Version()); }); // Update the settings dialog to reflect the changes made. Util.Invoke(m_SettingsDialog, () => { m_SettingsDialog.UpdateDialog(); }); m_Configuration = Configuration.LoadOrCreateConfiguration ( Path.Combine(CurrentInstance.GameDir(), "CKAN/GUIConfig.xml"), Repo.default_ckan_repo.ToString() ); UpdateModsList(); ChangeSet = null; Conflicts = null; Filter((GUIModFilter)m_Configuration.ActiveFilter); }
private void AddMod(IEnumerable <RelationshipDescriptor> relations, Dictionary <string, List <string> > chooseAble, string identifier, IRegistryQuerier registry) { if (relations == null) { return; } foreach (RelationshipDescriptor mod in relations) { try { // if the mod is available for the current KSP version _and_ // the mod is not installed _and_ // the mod is not already in the install list if ( registry.LatestAvailable(mod.name, CurrentInstance.Version()) != null && !registry.IsInstalled(mod.name) && !toInstall.Contains(mod.name)) { // add it to the list of chooseAble mods we display to the user if (!chooseAble.ContainsKey(mod.name)) { chooseAble.Add(mod.name, new List <string>()); } chooseAble[mod.name].Add(identifier); } } // XXX - Don't ignore all krakens! Those things are important! catch (Kraken) { } } }
private void CurrentInstanceUpdated() { Util.Invoke(this, () => { Text = $"CKAN {Meta.GetVersion()} - KSP {CurrentInstance.Version()} -- {CurrentInstance.GameDir()}"; }); configuration = Configuration.LoadOrCreateConfiguration ( Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml"), Repo.default_ckan_repo.ToString() ); if (CurrentInstance.CompatibleVersionsAreFromDifferentKsp) { CompatibleKspVersionsDialog dialog = new CompatibleKspVersionsDialog(CurrentInstance); dialog.ShowDialog(); } UpdateModsList(); ChangeSet = null; Conflicts = null; Filter((GUIModFilter)configuration.ActiveFilter); }
/// <summary> /// React to switching to a new game instance /// </summary> /// <param name="onStartup">true if this is the initial load and should trigger auto repo updates, false otherwise</param> private void CurrentInstanceUpdated(bool onStartup) { Util.Invoke(this, () => { Text = $"CKAN {Meta.GetVersion()} - KSP {CurrentInstance.Version()} -- {CurrentInstance.GameDir()}"; }); configuration = Configuration.LoadOrCreateConfiguration( Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml") ); if (CurrentInstance.CompatibleVersionsAreFromDifferentKsp) { new CompatibleKspVersionsDialog(CurrentInstance, !actuallyVisible) .ShowDialog(); } bool repoUpdateNeeded = configuration.RefreshOnStartup || !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable(); if (onStartup && repoUpdateNeeded) { UpdateRepo(); } else { UpdateModsList(); } ChangeSet = null; Conflicts = null; Filter((GUIModFilter)configuration.ActiveFilter); }
public void LaunchGame() { var split = configuration.CommandLineArguments.Split(' '); if (split.Length == 0) { return; } var registry = RegistryManager.Instance(CurrentInstance).registry; var suppressedIdentifiers = CurrentInstance.GetSuppressedCompatWarningIdentifiers; var incomp = registry.IncompatibleInstalled(CurrentInstance.VersionCriteria()) .Where(m => !m.Module.IsDLC && !suppressedIdentifiers.Contains(m.identifier)) .ToList(); if (incomp.Any()) { // Warn that it might not be safe to run Game with incompatible modules installed string incompatDescrip = incomp .Select(m => $"{m.Module} ({registry.CompatibleGameVersions(CurrentInstance.game, m.Module)})") .Aggregate((a, b) => $"{a}{Environment.NewLine}{b}"); var ver = CurrentInstance.Version(); var result = SuppressableYesNoDialog( string.Format(Properties.Resources.MainLaunchWithIncompatible, incompatDescrip), string.Format(Properties.Resources.MainLaunchDontShow, CurrentInstance.game.ShortName, new GameVersion(ver.Major, ver.Minor, ver.Patch)), Properties.Resources.MainLaunch, Properties.Resources.MainGoBack ); if (result.Item1 != DialogResult.Yes) { return; } else if (result.Item2) { CurrentInstance.AddSuppressedCompatWarningIdentifiers( incomp.Select(m => m.identifier).ToHashSet() ); } } split = CurrentInstance.game.AdjustCommandLine(split, Main.Instance.CurrentInstance.Version()); var binary = split[0]; var args = string.Join(" ", split.Skip(1)); try { Directory.SetCurrentDirectory(CurrentInstance.GameDir()); Process.Start(binary, args); } catch (Exception exception) { currentUser.RaiseError(Properties.Resources.MainLaunchFailed, exception.Message); } }
private void _UpdateModsList(bool repo_updated) { log.Debug("Updating the mod list"); Registry registry = RegistryManager.Instance(CurrentInstance).registry; var ckanModules = registry.Available(CurrentInstance.Version()).Concat( registry.Incompatible(CurrentInstance.Version())).ToList(); var gui_mods = new HashSet <GUIMod>(ckanModules.Select(m => new GUIMod(m, registry, CurrentInstance.Version()))); var old_modules = new HashSet <GUIMod>(mainModList.Modules); if (repo_updated) { foreach (var gui_mod in gui_mods.Where(m => !old_modules.Contains(m))) { gui_mod.IsNew = true; } } else { //Copy the new mod flag from the old list. var old_new_mods = new HashSet <GUIMod>(old_modules.Where(m => m.IsNew)); foreach (var gui_mod in gui_mods.Where(m => old_new_mods.Contains(m))) { gui_mod.IsNew = true; } } mainModList.Modules = new ReadOnlyCollection <GUIMod>(gui_mods.ToList()); var rows = mainModList.ConstructModList(mainModList.Modules); ModList.Rows.Clear(); ModList.Rows.AddRange(rows.ToArray()); ModList.Sort(ModList.Columns[2], ListSortDirection.Ascending); //TODO Consider using smart enum patten so stuff like this is easier FilterToolButton.DropDownItems[0].Text = String.Format("Compatible ({0})", mainModList.CountModsByFilter(GUIModFilter.Compatible)); FilterToolButton.DropDownItems[1].Text = String.Format("Installed ({0})", mainModList.CountModsByFilter(GUIModFilter.Installed)); FilterToolButton.DropDownItems[2].Text = String.Format("Upgradeable ({0})", mainModList.CountModsByFilter(GUIModFilter.InstalledUpdateAvailable)); FilterToolButton.DropDownItems[3].Text = String.Format("New in repository ({0})", mainModList.CountModsByFilter(GUIModFilter.NewInRepository)); FilterToolButton.DropDownItems[4].Text = String.Format("Not installed ({0})", mainModList.CountModsByFilter(GUIModFilter.NotInstalled)); FilterToolButton.DropDownItems[5].Text = String.Format("Incompatible ({0})", mainModList.CountModsByFilter(GUIModFilter.Incompatible)); FilterToolButton.DropDownItems[6].Text = String.Format("All ({0})", mainModList.CountModsByFilter(GUIModFilter.All)); var has_any_updates = gui_mods.Any(mod => mod.HasUpdate); UpdateAllToolButton.Enabled = has_any_updates; UpdateFilters(this); }
private void UpdateStatusBar() { StatusInstanceLabel.Text = string.Format( CurrentInstance.playTime.Time > TimeSpan.Zero ? Properties.Resources.StatusInstanceLabelTextWithPlayTime : Properties.Resources.StatusInstanceLabelText, CurrentInstance.Name, CurrentInstance.game.ShortName, CurrentInstance.Version()?.ToString(), CurrentInstance.playTime.ToString()); }
private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open_file_dialog = new OpenFileDialog { Filter = Resources.CKANFileFilter }; if (open_file_dialog.ShowDialog() == DialogResult.OK) { var path = open_file_dialog.FileName; CkanModule module; try { module = CkanModule.FromFile(path); } catch (Kraken kraken) { m_User.RaiseError(kraken.Message + ": " + kraken.InnerException.Message); return; } catch (Exception ex) { m_User.RaiseError(ex.Message); return; } // We'll need to make some registry changes to do this. RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance); // Remove this version of the module in the registry, if it exists. registry_manager.registry.RemoveAvailable(module); // Sneakily add our version in... registry_manager.registry.AddAvailable(module); var changeset = new List <ModChange>(); changeset.Add(new ModChange( new GUIMod(module, registry_manager.registry, CurrentInstance.Version()), GUIModChangeType.Install, null)); menuStrip1.Enabled = false; RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts(); install_ops.with_recommends = false; m_InstallWorker.RunWorkerAsync( new KeyValuePair <List <ModChange>, RelationshipResolverOptions>( changeset, install_ops)); m_Changeset = null; UpdateChangesDialog(null, m_InstallWorker); ShowWaitDialog(); } }
/// <summary> /// Tries to get every mod in the Dictionary, which can be installed /// It also transforms the Recommender list to a string /// </summary> /// <param name="mods"></param> /// <returns></returns> private Dictionary <CkanModule, string> GetShowableMods(Dictionary <string, List <string> > mods) { Dictionary <CkanModule, string> modules = new Dictionary <CkanModule, string>(); var opts = new RelationshipResolverOptions { with_all_suggests = false, with_recommends = false, with_suggests = false, without_enforce_consistency = false, without_toomanyprovides_kraken = true }; foreach (var pair in mods) { CkanModule module; try { var resolver = new RelationshipResolver(new List <string> { pair.Key }, opts, RegistryManager.Instance(manager.CurrentInstance).registry, CurrentInstance.Version()); if (!resolver.ModList().Any()) { continue; } module = RegistryManager.Instance(manager.CurrentInstance) .registry.LatestAvailable(pair.Key, CurrentInstance.Version()); } catch { continue; } if (module == null) { continue; } modules.Add(module, String.Join(",", pair.Value.ToArray())); } return(modules); }
public void CurrentInstanceUpdated() { Util.Invoke(this, () => { Text = String.Format("CFAN {0} - Factorio {1} -- {2}", Meta.Version(), CurrentInstance.Version(), CurrentInstance.GameDir()); KSPVersionLabel.Text = String.Format("Factorio {0}", CurrentInstance.Version()); }); m_Configuration = Configuration.LoadOrCreateConfiguration ( CurrentInstance.findFactorioBinaryPath(), Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml"), Repo.default_ckan_repo.ToString() ); UpdateModsList(); ChangeSet = null; Conflicts = null; Filter((GUIModFilter)m_Configuration.ActiveFilter); }
private async Task UpdateChangeSetAndConflicts(IRegistryQuerier registry) { IEnumerable <ModChange> full_change_set = null; Dictionary <GUIMod, string> new_conflicts = null; bool too_many_provides_thrown = false; var user_change_set = mainModList.ComputeUserChangeSet(); try { var module_installer = ModuleInstaller.GetInstance(CurrentInstance, GUI.user); full_change_set = await mainModList.ComputeChangeSetFromModList(registry, user_change_set, module_installer, CurrentInstance.Version()); } catch (InconsistentKraken) { //Need to be recomputed due to ComputeChangeSetFromModList possibly changing it with too many provides handling. user_change_set = mainModList.ComputeUserChangeSet(); new_conflicts = MainModList.ComputeConflictsFromModList(registry, user_change_set, CurrentInstance.Version()); full_change_set = null; } catch (TooManyModsProvideKraken) { //Can be thrown by ComputeChangeSetFromModList if the user cancels out of it. //We can just rerun it as the ModInfoTabControl has been removed. too_many_provides_thrown = true; } if (too_many_provides_thrown) { await UpdateChangeSetAndConflicts(registry); new_conflicts = Conflicts; full_change_set = ChangeSet; } last_mod_to_have_install_toggled.Clear(); Conflicts = new_conflicts; ChangeSet = full_change_set; }
private void Main_Load(object sender, EventArgs e) { m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; m_InstallWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_InstallWorker.RunWorkerCompleted += PostInstallMods; m_InstallWorker.DoWork += InstallMods; UpdateModsList(); ApplyToolButton.Enabled = false; ModList.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); Text = String.Format("CKAN {0} - KSP {1}", Meta.Version(), CurrentInstance.Version()); KSPVersionLabel.Text = String.Format("Kerbal Space Program {0}", CurrentInstance.Version()); }
private void UpdateChangeSetAndConflicts(Registry registry) { IEnumerable <KeyValuePair <CkanModule, GUIModChangeType> > full_change_set; Dictionary <Module, string> conflicts; var user_change_set = mainModList.ComputeUserChangeSet(); try { var module_installer = ModuleInstaller.GetInstance(CurrentInstance, GUI.user); full_change_set = MainModList.ComputeChangeSetFromModList(registry, user_change_set, module_installer, CurrentInstance.Version()); conflicts = null; } catch (InconsistentKraken) { conflicts = MainModList.ComputeConflictsFromModList(registry, user_change_set, CurrentInstance.Version()); full_change_set = null; } Conflicts = conflicts; ChangeSet = full_change_set; }
protected override void OnLoad(EventArgs e) { enableTls2IfPossible(); Location = m_Configuration.WindowLoc; Size = m_Configuration.WindowSize; if (CurrentInstance.lacksFactorioAuthData()) { m_User.RaiseError( "Your config file located in {0} does not contain Factorio authorization data. Mods from official factorio.com mod portal will not be shown.\n\rYou can fix it by launching Factorio, entering in-game mod manager (mods -> install mods), quitting the game and restarting CFAN.", new object[] { CurrentInstance.getFactorioAuthDataPath() } ); } if (!m_Configuration.CheckForUpdatesOnLaunchNoNag) { log.Debug("Asking user if they wish for autoupdates"); if (new AskUserForAutoUpdatesDialog().ShowDialog() == DialogResult.OK) { m_Configuration.CheckForUpdatesOnLaunch = true; } m_Configuration.CheckForUpdatesOnLaunchNoNag = true; m_Configuration.Save(); } if (m_Configuration.CheckForUpdatesOnLaunch) { try { log.Info("Making autoupdate call"); AutoUpdate.Instance.FetchLatestReleaseInfo(); var latest_version = AutoUpdate.Instance.LatestVersion; var current_version = new CFANVersion(Meta.Version(), ""); if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version)) { log.Debug("Found higher cfan version"); var release_notes = AutoUpdate.Instance.ReleaseNotes; var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes); if (dialog.ShowDialog() == DialogResult.OK) { log.Info("Start cfan update"); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (sender, args) => AutoUpdate.Instance.StartUpdateProcess(true, PleaseWait.User); bw.RunWorkerAsync(); new PleaseWait().ShowDialog(this); } } } catch (Exception exception) { m_User.RaiseError("Error in autoupdate: \n\t" + exception.Message + ""); log.Error("Error in autoupdate", exception); } } m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; m_InstallWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_InstallWorker.RunWorkerCompleted += PostInstallMods; m_InstallWorker.DoWork += InstallMods; m_CacheWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_CacheWorker.RunWorkerCompleted += PostModCaching; m_CacheWorker.DoWork += CacheMod; var old_YesNoDialog = m_User.displayYesNo; m_User.displayYesNo = YesNoDialog; //URLHandlers.RegisterURLHandler(m_Configuration, m_User); m_User.displayYesNo = old_YesNoDialog; ApplyToolButton.Enabled = false; CurrentInstanceUpdated(); CheckForConsistency(); if (m_Configuration.RefreshOnStartup) { UpdateRepo(); } Text = String.Format("CFAN {0} - Factorio {1} -- {2}", Meta.Version(), CurrentInstance.Version(), CurrentInstance.GameDir()); KSPVersionLabel.Text = String.Format("Factorio {0}", CurrentInstance.Version()); if (m_CommandLineArgs.Length >= 2) { var identifier = m_CommandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("cfan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } log.Debug("Attempting to select mod from startup parameters"); FocusMod(identifier, true, true); ModList.Refresh(); log.Debug("Failed to select mod from startup parameters"); } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } m_PluginController = new PluginController(pluginsPath, true); CurrentInstance.RebuildKSPSubDir(); log.Info("GUI started"); base.OnLoad(e); }
/// <summary> /// React to switching to a new game instance /// </summary> /// <param name="allowRepoUpdate">true if a repo update is allowed if needed (e.g. on initial load), false otherwise</param> private void CurrentInstanceUpdated(bool allowRepoUpdate) { CurrentInstance.Scan(); Util.Invoke(this, () => { Text = $"CKAN {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {CurrentInstance.GameDir().Replace('/', Path.DirectorySeparatorChar)}"; StatusInstanceLabel.Text = string.Format( Properties.Resources.StatusInstanceLabelText, CurrentInstance.Name, CurrentInstance.game.ShortName, CurrentInstance.Version()?.ToString() ); }); configuration = GUIConfiguration.LoadOrCreateConfiguration( Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml") ); if (CurrentInstance.CompatibleVersionsAreFromDifferentGameVersion) { new CompatibleGameVersionsDialog(CurrentInstance, !actuallyVisible) .ShowDialog(); } (RegistryManager.Instance(CurrentInstance).registry as Registry) ?.BuildTagIndex(ManageMods.mainModList.ModuleTags); bool repoUpdateNeeded = configuration.RefreshOnStartup || !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable(); if (allowRepoUpdate) { // If not allowing, don't do anything if (repoUpdateNeeded) { // Update the filters after UpdateRepo() completed. // Since this happens with a backgroundworker, Filter() is added as callback for RunWorkerCompleted. // Remove it again after it ran, else it stays there and is added again and again. void filterUpdate(object sender, RunWorkerCompletedEventArgs e) { ManageMods.Filter( (GUIModFilter)configuration.ActiveFilter, ManageMods.mainModList.ModuleTags.Tags.GetOrDefault(configuration.TagFilter), ManageMods.mainModList.ModuleLabels.LabelsFor(CurrentInstance.Name) .FirstOrDefault(l => l.Name == configuration.CustomLabelFilter) ); m_UpdateRepoWorker.RunWorkerCompleted -= filterUpdate; } m_UpdateRepoWorker.RunWorkerCompleted += filterUpdate; ManageMods.ModGrid.Rows.Clear(); UpdateRepo(); } else { ManageMods.UpdateModsList(); ManageMods.Filter( (GUIModFilter)configuration.ActiveFilter, ManageMods.mainModList.ModuleTags.Tags.GetOrDefault(configuration.TagFilter), ManageMods.mainModList.ModuleLabels.LabelsFor(CurrentInstance.Name) .FirstOrDefault(l => l.Name == configuration.CustomLabelFilter) ); } } ManageMods.InstanceUpdated(CurrentInstance); }
private void UpdateRecommendedDialog(Dictionary <string, List <string> > mods, bool suggested = false) { if (!suggested) { RecommendedDialogLabel.Text = "The following modules have been recommended by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Recommended by:"; } else { RecommendedDialogLabel.Text = "The following modules have been suggested by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Suggested by:"; } RecommendedModsListView.Items.Clear(); foreach (var pair in mods) { CkanModule module; try { module = RegistryManager.Instance(manager.CurrentInstance).registry.LatestAvailable(pair.Key, CurrentInstance.Version()); } catch { continue; } if (module == null) { continue; } ListViewItem item = new ListViewItem { Tag = module, Checked = !suggested, Text = pair.Key }; ListViewItem.ListViewSubItem recommendedBy = new ListViewItem.ListViewSubItem(); string recommendedByString = ""; bool first = true; foreach (string mod in pair.Value) { if (!first) { recommendedByString += ", "; } else { first = false; } recommendedByString += mod; } recommendedBy.Text = recommendedByString; item.SubItems.Add(recommendedBy); ListViewItem.ListViewSubItem description = new ListViewItem.ListViewSubItem { Text = module.@abstract }; item.SubItems.Add(description); RecommendedModsListView.Items.Add(item); } }
protected override void OnLoad(EventArgs e) { Location = m_Configuration.WindowLoc; Size = m_Configuration.WindowSize; if (!m_Configuration.CheckForUpdatesOnLaunchNoNag) { log.Debug("Asking user if they wish for autoupdates"); if (new AskUserForAutoUpdatesDialog().ShowDialog() == DialogResult.OK) { m_Configuration.CheckForUpdatesOnLaunch = true; } m_Configuration.CheckForUpdatesOnLaunchNoNag = true; m_Configuration.Save(); } if (m_Configuration.CheckForUpdatesOnLaunch) { try { log.Info("Making autoupdate call"); AutoUpdate.Instance.FetchLatestReleaseInfo(); var latest_version = AutoUpdate.Instance.LatestVersion; var current_version = new Version(Meta.Version()); if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version)) { log.Debug("Found higher ckan version"); var release_notes = AutoUpdate.Instance.ReleaseNotes; var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes); if (dialog.ShowDialog() == DialogResult.OK) { log.Info("Start ckan update"); AutoUpdate.Instance.StartUpdateProcess(true); } } } catch (Exception exception) { m_User.RaiseError("Error in autoupdate: \n\t" + exception.Message + ""); log.Error("Error in autoupdate", exception); } } m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; m_InstallWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_InstallWorker.RunWorkerCompleted += PostInstallMods; m_InstallWorker.DoWork += InstallMods; m_CacheWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_CacheWorker.RunWorkerCompleted += PostModCaching; m_CacheWorker.DoWork += CacheMod; var old_YesNoDialog = m_User.displayYesNo; m_User.displayYesNo = YesNoDialog; URLHandlers.RegisterURLHandler(m_Configuration, m_User); m_User.displayYesNo = old_YesNoDialog; ApplyToolButton.Enabled = false; CurrentInstanceUpdated(); if (m_Configuration.RefreshOnStartup) { UpdateRepo(); } Text = String.Format("CKAN {0} - KSP {1} -- {2}", Meta.Version(), CurrentInstance.Version(), CurrentInstance.GameDir()); KSPVersionLabel.Text = String.Format("Kerbal Space Program {0}", CurrentInstance.Version()); if (m_CommandLineArgs.Length >= 2) { var identifier = m_CommandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("ckan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } log.Debug("Attempting to select mod from startup parameters"); FocusMod(identifier, true, true); ModList.Refresh(); log.Debug("Failed to select mod from startup parameters"); } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } m_PluginController = new PluginController(pluginsPath, true); CurrentInstance.RebuildKSPSubDir(); log.Info("GUI started"); base.OnLoad(e); }
protected override void OnLoad(EventArgs e) { if (configuration.WindowLoc.X == -1 && configuration.WindowLoc.Y == -1) { // Center on screen for first launch StartPosition = FormStartPosition.CenterScreen; } else if (Platform.IsMac) { // Make sure there's room at the top for the MacOSX menu bar Location = Util.ClampedLocationWithMargins( configuration.WindowLoc, configuration.WindowSize, new Size(0, 30), new Size(0, 0) ); } else { // Just make sure it's fully on screen Location = Util.ClampedLocation(configuration.WindowLoc, configuration.WindowSize); } Size = configuration.WindowSize; WindowState = configuration.IsWindowMaximised ? FormWindowState.Maximized : FormWindowState.Normal; #if (!ONI) if (!configuration.CheckForUpdatesOnLaunchNoNag && AutoUpdate.CanUpdate) { log.Debug("Asking user if they wish for auto-updates"); if (new AskUserForAutoUpdatesDialog().ShowDialog() == DialogResult.OK) { configuration.CheckForUpdatesOnLaunch = true; } configuration.CheckForUpdatesOnLaunchNoNag = true; configuration.Save(); } #else configuration.CheckForUpdatesOnLaunch = false; configuration.CheckForUpdatesOnLaunchNoNag = false; configuration.Save(); #endif bool autoUpdating = false; if (configuration.CheckForUpdatesOnLaunch && AutoUpdate.CanUpdate) { try { log.Info("Making auto-update call"); AutoUpdate.Instance.FetchLatestReleaseInfo(); var latest_version = AutoUpdate.Instance.latestUpdate.Version; var current_version = new ModuleVersion(Meta.GetVersion()); if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version)) { log.Debug("Found higher ckan version"); var release_notes = AutoUpdate.Instance.latestUpdate.ReleaseNotes; var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes); if (dialog.ShowDialog() == DialogResult.OK) { UpdateCKAN(); autoUpdating = true; } } } catch (Exception exception) { currentUser.RaiseError($"Error in auto-update:\n\t{exception.Message}"); log.Error("Error in auto-update", exception); } } CheckTrayState(); InitRefreshTimer(); m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; installWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; installWorker.RunWorkerCompleted += PostInstallMods; installWorker.DoWork += InstallMods; #if (!ONI) URLHandlers.RegisterURLHandler(configuration, currentUser); #endif ApplyToolButton.Enabled = false; CurrentInstanceUpdated(); // We would like to refresh if we're configured to refresh on startup, // or if we have no currently available modules. bool repoUpdateNeeded = configuration.RefreshOnStartup || !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable(); // If we're auto-updating the client then we shouldn't interfere with the progress tab if (!autoUpdating && repoUpdateNeeded) { UpdateRepo(); } Text = $"CKAN {Meta.GetVersion()} - {GameConfig.Constants.GameNameShort} {CurrentInstance.Version()} -- {CurrentInstance.GameDir()}"; if (commandLineArgs.Length >= 2) { var identifier = commandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("ckan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } log.Debug("Attempting to select mod from startup parameters"); FocusMod(identifier, true, true); ModList.Refresh(); log.Debug("Failed to select mod from startup parameters"); } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } pluginController = new PluginController(pluginsPath); CurrentInstance.RebuildKSPSubDir(); // Initialize navigation. This should be called as late as // possible, once the UI is "settled" from its initial load. NavInit(); log.Info("GUI started"); base.OnLoad(e); }
/// <summary> /// React to switching to a new game instance /// </summary> /// <param name="allowRepoUpdate">true if a repo update is allowed if needed (e.g. on initial load), false otherwise</param> private void CurrentInstanceUpdated(bool allowRepoUpdate) { log.Debug("Current instance updated, scanning"); CurrentInstance.Scan(); Util.Invoke(this, () => { Text = $"CKAN {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {CurrentInstance.GameDir().Replace('/', Path.DirectorySeparatorChar)}"; StatusInstanceLabel.Text = string.Format( Properties.Resources.StatusInstanceLabelText, CurrentInstance.Name, CurrentInstance.game.ShortName, CurrentInstance.Version()?.ToString() ); }); if (CurrentInstance.CompatibleVersionsAreFromDifferentGameVersion) { new CompatibleGameVersionsDialog(CurrentInstance, !actuallyVisible) .ShowDialog(); } // This will throw RegistryInUseKraken if locked by another process var regMgr = RegistryManager.Instance(CurrentInstance); var registry = regMgr.registry; if (!string.IsNullOrEmpty(regMgr.previousCorruptedMessage) && !string.IsNullOrEmpty(regMgr.previousCorruptedPath)) { errorDialog.ShowErrorDialog(Properties.Resources.MainCorruptedRegistry, regMgr.previousCorruptedPath, regMgr.previousCorruptedMessage, Path.Combine(Path.GetDirectoryName(regMgr.previousCorruptedPath) ?? "", regMgr.LatestInstalledExportFilename())); regMgr.previousCorruptedMessage = null; regMgr.previousCorruptedPath = null; } registry.BuildTagIndex(ManageMods.mainModList.ModuleTags); configuration = GUIConfiguration.LoadOrCreateConfiguration( Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml")); bool repoUpdateNeeded = configuration.RefreshOnStartup || !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable(); if (allowRepoUpdate) { // If not allowing, don't do anything if (repoUpdateNeeded) { // Update the filters after UpdateRepo() completed. // Since this happens with a backgroundworker, Filter() is added as callback for RunWorkerCompleted. // Remove it again after it ran, else it stays there and is added again and again. void filterUpdate(object sender, RunWorkerCompletedEventArgs e) { SetupDefaultSearch(); m_UpdateRepoWorker.RunWorkerCompleted -= filterUpdate; } m_UpdateRepoWorker.RunWorkerCompleted += filterUpdate; ManageMods.ModGrid.Rows.Clear(); UpdateRepo(); } else { SetupDefaultSearch(); ManageMods.UpdateModsList(); } } ManageMods.InstanceUpdated(CurrentInstance); }
private void UpdateRecommendedDialog(Dictionary <string, List <string> > mods, bool suggested = false) { if (!suggested) { RecommendedDialogLabel.Text = "The following modules have been recommended by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Recommended by:"; RecommendedModsToggleCheckbox.Text = "(De-)select all recommended mods."; RecommendedModsToggleCheckbox.Checked = true; m_TabController.RenameTab("ChooseRecommendedModsTabPage", "Choose recommended mods"); } else { RecommendedDialogLabel.Text = "The following modules have been suggested by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Suggested by:"; RecommendedModsToggleCheckbox.Text = "(De-)select all suggested mods."; RecommendedModsToggleCheckbox.Checked = false; m_TabController.RenameTab("ChooseRecommendedModsTabPage", "Choose suggested mods"); } RecommendedModsListView.Items.Clear(); foreach (KeyValuePair <string, List <string> > pair in mods) { CfanModule module; try { var opts = new RelationshipResolverOptions { with_all_suggests = false, with_recommends = false, with_suggests = false, without_enforce_consistency = false, without_toomanyprovides_kraken = true }; CfanModuleIdAndVersion[] arrayWithOneModName = new[] { new CfanModuleIdAndVersion(pair.Key) }; RelationshipResolver resolver = new RelationshipResolver(arrayWithOneModName, opts, RegistryManager.Instance(manager.CurrentInstance).registry, CurrentInstance.Version()); if (!resolver.ModList().Any()) { continue; } module = RegistryManager.Instance(manager.CurrentInstance) .registry.LatestAvailable(pair.Key, CurrentInstance.Version()); } catch { continue; } if (module == null) { continue; } ListViewItem item = new ListViewItem { Tag = module, Checked = !suggested, Text = pair.Key }; ListViewItem.ListViewSubItem recommendedBy = new ListViewItem.ListViewSubItem(); string recommendedByString = ""; bool first = true; foreach (string mod in pair.Value) { if (!first) { recommendedByString += ", "; } else { first = false; } recommendedByString += mod; } recommendedBy.Text = recommendedByString; item.SubItems.Add(recommendedBy); ListViewItem.ListViewSubItem description = new ListViewItem.ListViewSubItem { Text = module.@abstract }; item.SubItems.Add(description); RecommendedModsListView.Items.Add(item); } }
private void UpdateRecommendedDialog(Dictionary <string, List <string> > mods, bool suggested = false) { if (!suggested) { RecommendedDialogLabel.Text = "The following modules have been recommended by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Recommended by:"; } else { RecommendedDialogLabel.Text = "The following modules have been suggested by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Suggested by:"; } RecommendedModsListView.Items.Clear(); foreach (var pair in mods) { CkanModule module; try { var opts = new RelationshipResolverOptions() { with_all_suggests = false, with_recommends = false, with_suggests = false, without_enforce_consistency = false, without_toomanyprovides_kraken = true }; var resolver = new RelationshipResolver(new List <string>() { pair.Key }, opts, RegistryManager.Instance(manager.CurrentInstance).registry, CurrentInstance.Version()); if (!resolver.ModList().Any()) { continue; } module = RegistryManager.Instance(manager.CurrentInstance).registry.LatestAvailable(pair.Key, CurrentInstance.Version()); } catch { continue; } if (module == null) { continue; } ListViewItem item = new ListViewItem { Tag = module, Checked = !suggested, Text = pair.Key }; ListViewItem.ListViewSubItem recommendedBy = new ListViewItem.ListViewSubItem(); string recommendedByString = ""; bool first = true; foreach (string mod in pair.Value) { if (!first) { recommendedByString += ", "; } else { first = false; } recommendedByString += mod; } recommendedBy.Text = recommendedByString; item.SubItems.Add(recommendedBy); ListViewItem.ListViewSubItem description = new ListViewItem.ListViewSubItem { Text = module.@abstract }; item.SubItems.Add(description); RecommendedModsListView.Items.Add(item); } }
private void _UpdateModsList(bool repo_updated) { log.Debug("Updating the mod list"); FactorioVersion version = CurrentInstance.Version(); IRegistryQuerier registry = RegistryManager.Instance(CurrentInstance).registry; var gui_mods = new HashSet <GUIMod>(registry.Available(version) .Select(m => new GUIMod(m, registry, version))); gui_mods.UnionWith(registry.Incompatible(version) .Select(m => new GUIMod(m, registry, version))); var installed = registry.InstalledModules .Select(m => new GUIMod(m.Module, registry, version)); //Hashset does not define if add/unionwith replaces existing elements. //In this case that could cause a CkanModule to be replaced by a Module. //Hence the explicit checking foreach (var mod in installed.Where(mod => !gui_mods.Contains(mod))) { gui_mods.Add(mod); } var old_modules = new HashSet <GUIMod>(mainModList.Modules); if (repo_updated) { foreach (var gui_mod in gui_mods.Where(m => !old_modules.Contains(m))) { gui_mod.IsNew = true; } } else { //Copy the new mod flag from the old list. var old_new_mods = new HashSet <GUIMod>(old_modules.Where(m => m.IsNew)); foreach (var gui_mod in gui_mods.Where(m => old_new_mods.Contains(m))) { gui_mod.IsNew = true; } } // Update our mod listing. If we're doing a repo update, then we don't refresh // all (in case the user has selected changes they wish to apply). mainModList.ConstructModList(gui_mods.ToList(), refreshAll: !repo_updated); mainModList.Modules = new ReadOnlyCollection <GUIMod>( mainModList.full_list_of_mod_rows.Values.Select(row => row.Tag as GUIMod).ToList()); //TODO Consider using smart enum patten so stuff like this is easier FilterToolButton.DropDownItems[0].Text = String.Format("Compatible ({0})", mainModList.CountModsByFilter(GUIModFilter.Compatible)); FilterToolButton.DropDownItems[1].Text = String.Format("Installed ({0})", mainModList.CountModsByFilter(GUIModFilter.Installed)); FilterToolButton.DropDownItems[2].Text = String.Format("Upgradeable ({0})", mainModList.CountModsByFilter(GUIModFilter.InstalledUpdateAvailable)); FilterToolButton.DropDownItems[3].Text = String.Format("Cached ({0})", mainModList.CountModsByFilter(GUIModFilter.Cached)); FilterToolButton.DropDownItems[4].Text = String.Format("New in repository ({0})", mainModList.CountModsByFilter(GUIModFilter.NewInRepository)); FilterToolButton.DropDownItems[5].Text = String.Format("Not installed ({0})", mainModList.CountModsByFilter(GUIModFilter.NotInstalled)); FilterToolButton.DropDownItems[6].Text = String.Format("Incompatible ({0})", mainModList.CountModsByFilter(GUIModFilter.Incompatible)); FilterToolButton.DropDownItems[7].Text = String.Format("All ({0})", mainModList.CountModsByFilter(GUIModFilter.All)); var has_any_updates = gui_mods.Any(mod => mod.HasUpdate); UpdateAllToolButton.Enabled = has_any_updates; UpdateFilters(this); }
protected override void OnLoad(EventArgs e) { Location = configuration.WindowLoc; Size = configuration.WindowSize; WindowState = configuration.IsWindowMaximised ? FormWindowState.Maximized : FormWindowState.Normal; splitContainer1.SplitterDistance = configuration.PanelPosition; ModInfoTabControl.ModMetaSplitPosition = configuration.ModInfoPosition; if (!configuration.CheckForUpdatesOnLaunchNoNag && AutoUpdate.CanUpdate) { log.Debug("Asking user if they wish for auto-updates"); if (new AskUserForAutoUpdatesDialog().ShowDialog() == DialogResult.OK) { configuration.CheckForUpdatesOnLaunch = true; } configuration.CheckForUpdatesOnLaunchNoNag = true; configuration.Save(); } bool autoUpdating = false; if (configuration.CheckForUpdatesOnLaunch && AutoUpdate.CanUpdate) { try { log.Info("Making auto-update call"); AutoUpdate.Instance.FetchLatestReleaseInfo(); var latest_version = AutoUpdate.Instance.LatestVersion; var current_version = new Version(Meta.GetVersion()); if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version)) { log.Debug("Found higher ckan version"); var release_notes = AutoUpdate.Instance.ReleaseNotes; var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes); if (dialog.ShowDialog() == DialogResult.OK) { UpdateCKAN(); autoUpdating = true; } } } catch (Exception exception) { currentUser.RaiseError($"Error in auto-update:\n\t{exception.Message}"); log.Error("Error in auto-update", exception); } } m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; installWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; installWorker.RunWorkerCompleted += PostInstallMods; installWorker.DoWork += InstallMods; var old_YesNoDialog = currentUser.displayYesNo; currentUser.displayYesNo = YesNoDialog; URLHandlers.RegisterURLHandler(configuration, currentUser); currentUser.displayYesNo = old_YesNoDialog; ApplyToolButton.Enabled = false; CurrentInstanceUpdated(); // We would like to refresh if we're configured to refresh on startup, // or if we have no currently available modules. bool repoUpdateNeeded = configuration.RefreshOnStartup || !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable(); // If we're auto-updating the client then we shouldn't interfere with the progress tab if (!autoUpdating && repoUpdateNeeded) { UpdateRepo(); } Text = $"CKAN {Meta.GetVersion()} - KSP {CurrentInstance.Version()} -- {CurrentInstance.GameDir()}"; if (commandLineArgs.Length >= 2) { var identifier = commandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("ckan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } log.Debug("Attempting to select mod from startup parameters"); FocusMod(identifier, true, true); ModList.Refresh(); log.Debug("Failed to select mod from startup parameters"); } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } pluginController = new PluginController(pluginsPath); CurrentInstance.RebuildKSPSubDir(); // Initialize navigation. This should be called as late as // possible, once the UI is "settled" from its initial load. NavInit(); log.Info("GUI started"); base.OnLoad(e); }
private void Main_Load(object sender, EventArgs e) { m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; m_InstallWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; m_InstallWorker.RunWorkerCompleted += PostInstallMods; m_InstallWorker.DoWork += InstallMods; UpdateModsList(); m_User.displayYesNo = YesNoDialog; URLHandlers.RegisterURLHandler(m_Configuration, m_User); m_User.displayYesNo = null; ApplyToolButton.Enabled = false; ModList.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); Text = String.Format("CKAN {0} - KSP {1}", Meta.Version(), CurrentInstance.Version()); KSPVersionLabel.Text = String.Format("Kerbal Space Program {0}", CurrentInstance.Version()); if (m_CommandLineArgs.Length >= 2) { var identifier = m_CommandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("ckan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } int i = 0; foreach (DataGridViewRow row in ModList.Rows) { var module = ((GUIMod)row.Tag).ToCkanModule(); if (identifier == module.identifier) { ModList.FirstDisplayedScrollingRowIndex = i; row.Selected = true; break; } i++; } } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } m_PluginController = new PluginController(pluginsPath, true); }
protected override void OnLoad(EventArgs e) { Location = configuration.WindowLoc; Size = configuration.WindowSize; if (!configuration.CheckForUpdatesOnLaunchNoNag) { log.Debug("Asking user if they wish for autoupdates"); if (new AskUserForAutoUpdatesDialog().ShowDialog() == DialogResult.OK) { configuration.CheckForUpdatesOnLaunch = true; } configuration.CheckForUpdatesOnLaunchNoNag = true; configuration.Save(); } bool autoUpdating = false; if (configuration.CheckForUpdatesOnLaunch) { try { log.Info("Making autoupdate call"); AutoUpdate.Instance.FetchLatestReleaseInfo(); var latest_version = AutoUpdate.Instance.LatestVersion; var current_version = new Version(Meta.GetVersion()); if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version)) { log.Debug("Found higher ckan version"); var release_notes = AutoUpdate.Instance.ReleaseNotes; var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes); if (dialog.ShowDialog() == DialogResult.OK) { UpdateCKAN(); autoUpdating = true; } } } catch (Exception exception) { currentUser.RaiseError("Error in autoupdate: \n\t" + exception.Message + ""); log.Error("Error in autoupdate", exception); } } m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true }; m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo; m_UpdateRepoWorker.DoWork += UpdateRepo; installWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; installWorker.RunWorkerCompleted += PostInstallMods; installWorker.DoWork += InstallMods; var old_YesNoDialog = currentUser.displayYesNo; currentUser.displayYesNo = YesNoDialog; URLHandlers.RegisterURLHandler(configuration, currentUser); currentUser.displayYesNo = old_YesNoDialog; ApplyToolButton.Enabled = false; CurrentInstanceUpdated(); // if we're autoUpdating then we shouldn't interfere progress tab if (configuration.RefreshOnStartup && !autoUpdating) { UpdateRepo(); } Text = String.Format("CKAN {0} - KSP {1} -- {2}", Meta.GetVersion(), CurrentInstance.Version(), CurrentInstance.GameDir()); if (commandLineArgs.Length >= 2) { var identifier = commandLineArgs[1]; if (identifier.StartsWith("//")) { identifier = identifier.Substring(2); } else if (identifier.StartsWith("ckan://")) { identifier = identifier.Substring(7); } if (identifier.EndsWith("/")) { identifier = identifier.Substring(0, identifier.Length - 1); } log.Debug("Attempting to select mod from startup parameters"); FocusMod(identifier, true, true); ModList.Refresh(); log.Debug("Failed to select mod from startup parameters"); } var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins"); if (!Directory.Exists(pluginsPath)) { Directory.CreateDirectory(pluginsPath); } pluginController = new PluginController(pluginsPath, true); CurrentInstance.RebuildKSPSubDir(); NavInit(); // initialize navigation. this should be called as late // as possible, once the UI is "settled" from its initial // load. log.Info("GUI started"); base.OnLoad(e); }
public void CurrentInstanceUpdated() { Util.Invoke(this, () => { Text = String.Format("CKAN {0} - KSP {1} -- {2}", Meta.Version(), CurrentInstance.Version(), CurrentInstance.GameDir()); }); configuration = Configuration.LoadOrCreateConfiguration ( Path.Combine(CurrentInstance.GameDir(), "CKAN/GUIConfig.xml"), Repo.default_ckan_repo.ToString() ); UpdateModsList(); ChangeSet = null; Conflicts = null; Filter((GUIModFilter)configuration.ActiveFilter); }