Show recommendations of installed modules in GUI #2577
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When installing a mod, CKAN shows the user other mods that are recommended or suggested by that mod, and the user can choose whether to install them as well.
If the user chooses not to install these mods, but then later has second thoughts, there's no easy way to try again. They would have to remember what the mods were and choose to install them, check the Relationships tab in mod info, or uninstall and re-install the dependent mods.
Changes
Now there's a new File ⇒ Audit recommendations menu option:
If you click this and none of your installed mods have recommendations or suggestions, it'll tell you that:
Otherwise, it takes you to the Choose recommended mods tab, listing the mods that are recommended by currently installed mods.
Clicking Continue jumps to Choose suggested mods:
If you click Cancel at any point, or if you don't select anything to install, then it just stops. Otherwise it takes you to the installer flow. (One possibly confusing point here is that the recommendations / suggestion lists might appear again if any of the mods you chose to install have recommendations or suggestions.) The chosen mods are downloaded and installed:
Code details
The private member variable
Main.toInstall
is removed and replaced with a local variable, to improve encapsulation and because that's how it's already used. To share this object effectively, it's now a parameter to the other functions that use it. WhereRecommendedModsContinueButton_Click
previously manipulatedtoInstall
directly, nowShowSelection
does that work instead.A lot of the code in
MainInstall.cs
was specifically for handling recommendations and suggestions. This is now split out intoMainRecommendations.cs
, along with a function or two from another file, to make it easier to find and reduce the clutter ofMainInstall.cs
.MainRecommendations.cs
then has a bit of new code at the end to gather installed mods' recommendations and suggestions and feed them into the selection prompts, then launch the installer.ShowSelection
usesMonitor.Wait
to wait for the cancel or continue buttons to be clicked and callMonitor.Pulse
, which requires the foreground GUI thread to be unoccupied, so the menu item click handler has to start a new thread. I usedTask.Factory.StartNew
for this, but I'm not sure that's the best way, please advise.Fixes #1764.
Side fixes
Recommendation conflicts with mods we're installing
If you select several mods to install and some have recommendations or suggestions, recommendations and suggestions that conflict with installed mods will be hidden, but ones that conflict with mods that are planned to install in this change set will be shown.
Now recommendations and suggestions will only be shown if they don't conflict with installed mods or mods planned to be installed in the current change set.
Fixes KSP-CKAN/NetKAN#6709.
Recommendations with virtual dependencies
If you select a mod to install that has a recommendation with a virtual dependency, that recommendation won't appear in the list, even if it can be satisfied by installing some combination of allowable mods. For example,
ExtrasolarPlanetsBeyondKerbol-stock
recommendsScatterer
, which depends onScatterer-sunflare
andScatterer-config
, each of which are provided by several possible mods (assuming you have KSP 1.3; some haven't been updated past that point yet). InstallingExtrasolarPlanetsBeyondKerbol-stock
won't ask if you want to installScatterer
.Now such recommendations show up as available in GUI.
This requires two main pieces:
TooManyModsProvideKraken
in the recommendation logic, which we now do in a newCanInstall
function.TooManyModsProvideKraken
inMain.InstallMods
. This may have existed at some point, but if it did it went missing at some point. Now it's definitely present, so you can be asked to choose a mod to satisfy a virtual dependency after you choose a recommendation.Fixes #2268.