Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show recommendations of installed modules in GUI #2577

Merged
merged 3 commits into from
Nov 21, 2018

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Nov 16, 2018

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:

image

If you click this and none of your installed mods have recommendations or suggestions, it'll tell you that:

image

Otherwise, it takes you to the Choose recommended mods tab, listing the mods that are recommended by currently installed mods.

image

Clicking Continue jumps to Choose suggested mods:

image

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:

image

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. Where RecommendedModsContinueButton_Click previously manipulated toInstall directly, now ShowSelection does that work instead.

A lot of the code in MainInstall.cs was specifically for handling recommendations and suggestions. This is now split out into MainRecommendations.cs, along with a function or two from another file, to make it easier to find and reduce the clutter of MainInstall.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 uses Monitor.Wait to wait for the cancel or continue buttons to be clicked and call Monitor.Pulse, which requires the foreground GUI thread to be unoccupied, so the menu item click handler has to start a new thread. I used Task.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 recommends Scatterer, which depends on Scatterer-sunflare and Scatterer-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). Installing ExtrasolarPlanetsBeyondKerbol-stock won't ask if you want to install Scatterer.

Now such recommendations show up as available in GUI.

This requires two main pieces:

  1. Allowing the recommendation to appear. This requires us to handle TooManyModsProvideKraken in the recommendation logic, which we now do in a new CanInstall function.
  2. Prompting the user to resolve the virtual dependency when installing. This requires handling TooManyModsProvideKraken in Main.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.

@HebaruSan HebaruSan added Enhancement New features or functionality GUI Issues affecting the interactive GUI Pull request Relationships Issues affecting depends, recommends, etc. labels Nov 16, 2018
@politas
Copy link
Member

politas commented Nov 21, 2018

I like this. I always like smaller chunks of code per file where it makes sense.

@politas
Copy link
Member

politas commented Nov 21, 2018

We've had a bunch of new features added so far for this version. Any chance we could get some tests addressing these features, to make sure nothing gets broken in the future?

@politas politas merged commit 07ad596 into KSP-CKAN:master Nov 21, 2018
@HebaruSan HebaruSan deleted the feature/installed-recommendations branch November 21, 2018 07:42
@HebaruSan
Copy link
Member Author

I will put together a PR with a bunch of tests in the next couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New features or functionality GUI Issues affecting the interactive GUI Relationships Issues affecting depends, recommends, etc.
Projects
None yet
2 participants