From a50c334e5b9213db7a291e14845b101b1f8f3238 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sun, 17 Mar 2024 21:57:36 -0500 Subject: [PATCH] Skip modpack compat prompt if no modpacks --- GUI/Main/Main.cs | 53 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/GUI/Main/Main.cs b/GUI/Main/Main.cs index cc440a82a..54b7f2ca4 100644 --- a/GUI/Main/Main.cs +++ b/GUI/Main/Main.cs @@ -739,31 +739,36 @@ private void InstallFromCkanFiles(string[] files) } } - CkanModule.GetMinMaxVersions(toInstall.Where(m => m.IsMetapackage), - out _, out _, - out GameVersion minGame, out GameVersion maxGame); - var filesRange = new GameVersionRange(minGame, maxGame); - var instRanges = crit.Versions.Select(gv => gv.ToVersionRange()) - .ToList(); - var missing = CurrentInstance.game - .KnownVersions - .Where(gv => filesRange.Contains(gv) - && !instRanges.Any(ir => ir.Contains(gv))) - // Use broad Major.Minor group for each specific version - .Select(gv => new GameVersion(gv.Major, gv.Minor)) - .Distinct() - .ToList(); - if (missing.Any() - && YesNoDialog(string.Format(Properties.Resources.MetapackageAddCompatibilityPrompt, - filesRange.ToSummaryString(CurrentInstance.game), - crit.ToSummaryString(CurrentInstance.game)), - Properties.Resources.MetapackageAddCompatibilityYes, - Properties.Resources.MetapackageAddCompatibilityNo)) + var modpacks = toInstall.Where(m => m.IsMetapackage) + .ToArray(); + if (modpacks.Any()) { - CurrentInstance.SetCompatibleVersions(crit.Versions - .Concat(missing) - .ToList()); - crit = CurrentInstance.VersionCriteria(); + CkanModule.GetMinMaxVersions(modpacks, + out _, out _, + out GameVersion minGame, out GameVersion maxGame); + var filesRange = new GameVersionRange(minGame, maxGame); + var instRanges = crit.Versions.Select(gv => gv.ToVersionRange()) + .ToList(); + var missing = CurrentInstance.game + .KnownVersions + .Where(gv => filesRange.Contains(gv) + && !instRanges.Any(ir => ir.Contains(gv))) + // Use broad Major.Minor group for each specific version + .Select(gv => new GameVersion(gv.Major, gv.Minor)) + .Distinct() + .ToList(); + if (missing.Any() + && YesNoDialog(string.Format(Properties.Resources.MetapackageAddCompatibilityPrompt, + filesRange.ToSummaryString(CurrentInstance.game), + crit.ToSummaryString(CurrentInstance.game)), + Properties.Resources.MetapackageAddCompatibilityYes, + Properties.Resources.MetapackageAddCompatibilityNo)) + { + CurrentInstance.SetCompatibleVersions(crit.Versions + .Concat(missing) + .ToList()); + crit = CurrentInstance.VersionCriteria(); + } } // Get all recursively incompatible module identifiers (quickly)