Skip to content

Commit

Permalink
Skip modpack compat prompt if no modpacks
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Mar 18, 2024
1 parent 4694463 commit a50c334
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a50c334

Please sign in to comment.