Skip to content

Show recommendations of chosen recommendations in GUI, readable foreground colors for labels#4381

Merged
HebaruSan merged 8 commits into
KSP-CKAN:masterfrom
HebaruSan:feature/gui-recs-of-recs
May 28, 2025
Merged

Show recommendations of chosen recommendations in GUI, readable foreground colors for labels#4381
HebaruSan merged 8 commits into
KSP-CKAN:masterfrom
HebaruSan:feature/gui-recs-of-recs

Conversation

@HebaruSan
Copy link
Copy Markdown
Member

@HebaruSan HebaruSan commented May 28, 2025

Motivation

  • Currently GUI only prompts to choose among recommendations, suggestions, and supporters once per install, for the initial changeset. However, if you choose to install any of them, those mods might also have recommendations, suggestions, or supporters that you'd like to install, so it would be nice to show them as well. For comparison:
    • CmdLine installs all recommendations-of-recommendations by default and has a --no-recommends option to turn that behavior off and a --with-all-suggests option to enable it for suggestions.
    • ConsoleUI shows the recommendations screen multiple times until the whole relationship tree is exhausted.
  • Currently we only set the background color for labels, and the foreground color remains the default of the mod list or menu where the label is being shown. If you choose a color that's too similar to those default foreground colors, the text may not be readable.

Changes

  • Now after you choose to install recommendations, suggestions, or supporters in GUI, the mods you chose are then checked for further recommendations, suggestions, or supporters, and if there are any, the recommendations list is shown again, just like in ConsoleUI. Note that each mod will only be shown once across all such passes; once you decide you don't want a particular mod, it won't appear again.
    Fixes [Feature]: Install Recommended Dependencies Recursively #4031.
  • Now the foreground color of labels is set to white when the background color's brightness is less than 0.5 and black otherwise. Tests are added to ensure that several light and dark colors use a sensible foreground color (see https://learn.microsoft.com/en-us/dotnet/media/art-color-table.png).
    Fixes [Feature]: Change label text color #4379.
  • Now when you add or remove a mod from a label, the mod info header refreshes to reflect the change.
  • Now the configured label color is shown in the mod info header, hidden label list, and the edit labels dialog. The foreground will be set according to the above brightness-based logic.
  • Now if you right-click a label link, a context menu appears with an option to toggle whether the currently selected mod is included in that label.
  • Now if you right-click a tag link, a context menu appears with an option to toggle whether mods with that tag are hidden in the mod list.

image
image
image
image image

Known limitations

That "Label with a space" label's background color is #8000FF, sometimes called "Electric Indigo". Its brightness happens to be 0.5 or slightly greater, so it is shown with black text, but it looks dark enough to my eye that white text would be better. I investigated this for a while and was not able to determine a way to programmatically distinguish such colors. (Increasing the threshold above 0.5 isn't feasible because there are several other 0.5-brightness colors that definitely should have black text.) I'm leaving it with black text for now because medium-brightness colors are still readable either way, just not optimally so.

@HebaruSan HebaruSan added Enhancement New features or functionality GUI Issues affecting the interactive GUI Relationships Issues affecting depends, recommends, etc. labels May 28, 2025
@HebaruSan HebaruSan merged commit 17b4240 into KSP-CKAN:master May 28, 2025
2 checks passed
@HebaruSan HebaruSan deleted the feature/gui-recs-of-recs branch May 28, 2025 18:18
@SofieBrink
Copy link
Copy Markdown

I investigated this for a while and was not able to determine a way to programmatically distinguish such colors.

Did you try the WCAG Relative Luminance scale by any chance?
I recently ran into a similiar problem to this at work and this turned out to be a good solution for my particular problem.

I had ChatGPT write up a simple javascript/html page that displays a colour picker and some sample text in a coloured block. and it does infact class #8000FF as a colour that benefits from white text. Infact it does so all the way up to around #9E3DFF which according to the HSL scale has a lightness of 62% compared to the 50% for electric indigo.

@HebaruSan
Copy link
Copy Markdown
Member Author

I did find a function to calculate that while I was looking into this:

https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.platformui.colorutilities.getluminance

... but unfortunately it's in Microsoft.VisualStudio.PlatformUI instead of in the regular .NET runtime or something on Nuget we could redistribute. I don't love the idea of embedding more specialized algorithms and magic numbers into CKAN, but I suppose it's an option...

@SofieBrink
Copy link
Copy Markdown

Hmm yeah that’s a bummer, i can’t find a real alternative to it either, at least not quickly

@HebaruSan
Copy link
Copy Markdown
Member Author

OK, that does look better.

image

It flipped on the #408080 of "Inveztigating," but that's probably an improvement as well. And all of my hard-coded test cases still pass.

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

Development

Successfully merging this pull request may close these issues.

[Feature]: Change label text color [Feature]: Install Recommended Dependencies Recursively

2 participants