From 5a12e063076faa2bae106185b453613751e36565 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 1 Dec 2023 12:57:38 -0600 Subject: [PATCH 1/6] Ensure installed mods aren't displayed as uninstalled --- GUI/Controls/ManageMods.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GUI/Controls/ManageMods.cs b/GUI/Controls/ManageMods.cs index 40b59303a1..a9e57ae0ae 100644 --- a/GUI/Controls/ManageMods.cs +++ b/GUI/Controls/ManageMods.cs @@ -1193,6 +1193,9 @@ private bool _UpdateModsList(Dictionary old_modules = null) Main.Instance.Wait.AddLogMessage(Properties.Resources.MainModListLoadingInstalled); var versionCriteria = Main.Instance.CurrentInstance.VersionCriteria(); + var installed = registry.InstalledModules + .Select(im => im.Module) + .ToHashSet(); var gui_mods = registry.InstalledModules .AsParallel() .Where(instMod => !instMod.Module.IsDLC) @@ -1201,6 +1204,7 @@ private bool _UpdateModsList(Dictionary old_modules = null) Main.Instance.configuration.HideEpochs, Main.Instance.configuration.HideV)) .Concat(registry.CompatibleModules(versionCriteria) + .Except(installed) .AsParallel() .Where(m => !m.IsDLC) .Select(m => new GUIMod( @@ -1208,6 +1212,7 @@ private bool _UpdateModsList(Dictionary old_modules = null) Main.Instance.configuration.HideEpochs, Main.Instance.configuration.HideV))) .Concat(registry.IncompatibleModules(versionCriteria) + .Except(installed) .AsParallel() .Where(m => !m.IsDLC) .Select(m => new GUIMod( From 74f5ee78223b143b404163cbd96e499fee6307dd Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 1 Dec 2023 11:40:19 -0600 Subject: [PATCH 2/6] Don't show recommendations of unchosen providing mods --- Core/Relationships/RelationshipResolver.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Core/Relationships/RelationshipResolver.cs b/Core/Relationships/RelationshipResolver.cs index 4c7bf749bf..22507a3974 100644 --- a/Core/Relationships/RelationshipResolver.cs +++ b/Core/Relationships/RelationshipResolver.cs @@ -326,14 +326,13 @@ private void ResolveStanza(List stanza, // Oh no, too many to pick from! if (options.without_toomanyprovides_kraken) { - if (options.get_recommenders) + if (options.get_recommenders && !(reason is SelectionReason.Depends)) { for (int i = 0; i < candidates.Count; ++i) { - var cand = candidates[i]; - Add(cand, reason is SelectionReason.Recommended rec - ? rec.WithIndex(i) - : reason); + Add(candidates[i], reason is SelectionReason.Recommended rec + ? rec.WithIndex(i) + : reason); } } continue; From 40ae4b0331f5e0ade201475298b46401fd7d4b35 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 1 Dec 2023 11:41:33 -0600 Subject: [PATCH 3/6] Improve debug messages for rejecting mods --- Core/Repositories/AvailableModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Repositories/AvailableModule.cs b/Core/Repositories/AvailableModule.cs index 94b9f5bd1e..f11f6dec27 100644 --- a/Core/Repositories/AvailableModule.cs +++ b/Core/Repositories/AvailableModule.cs @@ -137,7 +137,7 @@ private static bool DependsAndConflictsOK(CkanModule module, ICollection m.identifier)) && !rel.MatchesAny(others, null, null)) { - log.DebugFormat("Unsatisfied dependency {0}, rejecting", rel); + log.DebugFormat("Unsatisfied dependency {0}, rejecting {1}", rel, module); return false; } } @@ -151,7 +151,7 @@ private static bool DependsAndConflictsOK(CkanModule module, ICollection Date: Fri, 1 Dec 2023 11:39:36 -0600 Subject: [PATCH 4/6] Hide status bar progress bar during provides prompt --- GUI/Main/MainInstall.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GUI/Main/MainInstall.cs b/GUI/Main/MainInstall.cs index f7a1fbb073..2f4ee06fe3 100644 --- a/GUI/Main/MainInstall.cs +++ b/GUI/Main/MainInstall.cs @@ -271,6 +271,7 @@ private void InstallMods(object sender, DoWorkEventArgs e) { // Prompt user to choose which mod to use tabController.ShowTab("ChooseProvidedModsTabPage", 3); + Util.Invoke(this, () => StatusProgress.Visible = false); ChooseProvidedMods.LoadProviders(k.Message, k.modules, Manager.Cache); tabController.SetTabLock(true); CkanModule chosen = ChooseProvidedMods.Wait(); @@ -283,6 +284,7 @@ private void InstallMods(object sender, DoWorkEventArgs e) toInstall.Add(chosen); // DON'T return so we can loop around and try the above InstallList call again tabController.ShowTab("WaitTabPage"); + Util.Invoke(this, () => StatusProgress.Visible = true); } else { From 1b7ec8694b11dbe6dbe4a5a43ed2483fe1a6ac85 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 1 Dec 2023 11:43:50 -0600 Subject: [PATCH 5/6] Autosize provider message and simplify with depending mod --- Core/Properties/Resources.resx | 4 +++- Core/Relationships/RelationshipResolver.cs | 10 ++++++---- Core/Types/Kraken.cs | 7 +++++-- GUI/Controls/ChooseProvidedMods.Designer.cs | 1 + GUI/Controls/ChooseProvidedMods.cs | 8 ++++++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Core/Properties/Resources.resx b/Core/Properties/Resources.resx index 69990be6ef..93b113f85f 100644 --- a/Core/Properties/Resources.resx +++ b/Core/Properties/Resources.resx @@ -259,7 +259,9 @@ Please remove manually before trying to install it. Module not found: {0} {1} {0} dependency on {1} version {2} not satisfied (any) - Module {0} is provided by more than one available module. Please choose one of the following: + {1} requires {0}, which can be provided by multiple mods. + +Which {0} provider would you like to install? Inconsistencies were found: {0} missing dependency {1} {0} conflicts with {1} diff --git a/Core/Relationships/RelationshipResolver.cs b/Core/Relationships/RelationshipResolver.cs index 22507a3974..d431871bab 100644 --- a/Core/Relationships/RelationshipResolver.cs +++ b/Core/Relationships/RelationshipResolver.cs @@ -347,15 +347,17 @@ private void ResolveStanza(List stanza, .ToList(); if (provide.Count != 1) { - //We still have either nothing, or too many to pick from - //Just throw the TMP now - throw new TooManyModsProvideKraken(descriptor.ToString(), candidates, descriptor.choice_help_text); + // We still have either nothing, or too many to pick from + // Just throw the TMP now + throw new TooManyModsProvideKraken(reason.Parent, descriptor.ToString(), + candidates, descriptor.choice_help_text); } candidates[0] = provide.First(); } else { - throw new TooManyModsProvideKraken(descriptor.ToString(), candidates, descriptor.choice_help_text); + throw new TooManyModsProvideKraken(reason.Parent, descriptor.ToString(), + candidates, descriptor.choice_help_text); } } diff --git a/Core/Types/Kraken.cs b/Core/Types/Kraken.cs index 4ec8f869ed..d4f6d20b09 100644 --- a/Core/Types/Kraken.cs +++ b/Core/Types/Kraken.cs @@ -176,18 +176,21 @@ public RegistryVersionNotSupportedKraken(int v, string reason = null, Exception public class TooManyModsProvideKraken : Kraken { + public readonly CkanModule requester; public readonly List modules; public readonly string requested; public readonly string choice_help_text; - public TooManyModsProvideKraken(string requested, + public TooManyModsProvideKraken(CkanModule requester, + string requested, List modules, string choice_help_text = null, Exception innerException = null) : base(choice_help_text ?? string.Format(Properties.Resources.KrakenProvidedByMoreThanOne, - requested), + requested, requester.name), innerException) { + this.requester = requester; this.requested = requested; this.modules = modules; this.choice_help_text = choice_help_text; diff --git a/GUI/Controls/ChooseProvidedMods.Designer.cs b/GUI/Controls/ChooseProvidedMods.Designer.cs index 02a0e209ae..7f4a268df6 100644 --- a/GUI/Controls/ChooseProvidedMods.Designer.cs +++ b/GUI/Controls/ChooseProvidedMods.Designer.cs @@ -45,6 +45,7 @@ private void InitializeComponent() this.ChooseProvidedModsLabel.Dock = System.Windows.Forms.DockStyle.Top; this.ChooseProvidedModsLabel.Location = new System.Drawing.Point(9, 18); this.ChooseProvidedModsLabel.Margin = new System.Windows.Forms.Padding(5,5,5,5); + this.ChooseProvidedModsLabel.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10); this.ChooseProvidedModsLabel.Name = "ChooseProvidedModsLabel"; this.ChooseProvidedModsLabel.Size = new System.Drawing.Size(490, 40); this.ChooseProvidedModsLabel.TabIndex = 0; diff --git a/GUI/Controls/ChooseProvidedMods.cs b/GUI/Controls/ChooseProvidedMods.cs index 521c0b5181..bde9f667e8 100644 --- a/GUI/Controls/ChooseProvidedMods.cs +++ b/GUI/Controls/ChooseProvidedMods.cs @@ -27,6 +27,8 @@ public void LoadProviders(string message, List modules, NetModuleCac Util.Invoke(this, () => { ChooseProvidedModsLabel.Text = message; + ChooseProvidedModsLabel.Height = + Util.LabelStringHeight(CreateGraphics(), ChooseProvidedModsLabel); ChooseProvidedModsListView.Items.Clear(); ChooseProvidedModsListView.Items.AddRange(modules @@ -45,6 +47,12 @@ public void LoadProviders(string message, List modules, NetModuleCac }); } + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + ChooseProvidedModsLabel.Height = Util.LabelStringHeight(CreateGraphics(), ChooseProvidedModsLabel); + } + [ForbidGUICalls] public CkanModule Wait() { From 919a59638592d360136387ad672ff476a523fdcf Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 1 Dec 2023 11:44:23 -0600 Subject: [PATCH 6/6] Sort providing mods by download count, auto-check top --- GUI/Controls/ChooseProvidedMods.cs | 7 ++++--- GUI/Main/MainInstall.cs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/GUI/Controls/ChooseProvidedMods.cs b/GUI/Controls/ChooseProvidedMods.cs index bde9f667e8..8355f8c2c2 100644 --- a/GUI/Controls/ChooseProvidedMods.cs +++ b/GUI/Controls/ChooseProvidedMods.cs @@ -32,18 +32,19 @@ public void LoadProviders(string message, List modules, NetModuleCac ChooseProvidedModsListView.Items.Clear(); ChooseProvidedModsListView.Items.AddRange(modules - .Select(module => new ListViewItem(new string[] + .Select((module, index) => new ListViewItem(new string[] { cache.DescribeAvailability(module), module.@abstract }) { Tag = module, - Checked = false + Checked = index == 0, }) .ToArray()); ChooseProvidedModsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); - ChooseProvidedModsContinueButton.Enabled = false; + ChooseProvidedModsContinueButton.Enabled = + (ChooseProvidedModsListView.CheckedItems.Count > 0); }); } diff --git a/GUI/Main/MainInstall.cs b/GUI/Main/MainInstall.cs index 2f4ee06fe3..3dcebe071c 100644 --- a/GUI/Main/MainInstall.cs +++ b/GUI/Main/MainInstall.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Transactions; +using Autofac; + using CKAN.Extensions; using CKAN.GUI.Attributes; #if NET5_0_OR_GREATER @@ -272,7 +274,16 @@ private void InstallMods(object sender, DoWorkEventArgs e) // Prompt user to choose which mod to use tabController.ShowTab("ChooseProvidedModsTabPage", 3); Util.Invoke(this, () => StatusProgress.Visible = false); - ChooseProvidedMods.LoadProviders(k.Message, k.modules, Manager.Cache); + var repoData = ServiceLocator.Container.Resolve(); + ChooseProvidedMods.LoadProviders( + k.Message, + k.modules.OrderByDescending(m => repoData.GetDownloadCount(registry.Repositories.Values, + m.identifier) + ?? 0) + .ThenByDescending(m => m.identifier == k.requested) + .ThenBy(m => m.name) + .ToList(), + Manager.Cache); tabController.SetTabLock(true); CkanModule chosen = ChooseProvidedMods.Wait(); // Close the selection prompt