Fix panel selection after deleting or hiding beatmaps
Closes #33536 (including my comment)
Adds a test for deleting a set and hiding a difficult, making sure it selects the new panel that replaces it.
The cleanest solution I found this was to implement it in two layers.
- Carousel will, when an entry is deleted, select the new entry that occupies the slot the old one was in. (I don't know if this is okay to place in the general Carousel container rather than BeatmapCarousel).
- SongSelect will, when an entry is invalidated, look for the next best difficulty in the same set, if there are valid difficulties in the set. Otherwise it will randomize the beatmap, although this shouldn't happen if the Carousel implementation works correctly.
The findNextValidBeatmap is a bit complicated, there might be a simpler way to express it, but basically it gets the next valid difficulty located after the newly hidden one. And one isn't found, it will find the previous valid difficulty before the newly one. Basically, finds the the difficulty closest to the newly hidden one.
Dealing with indexes directly is kinda ugly but it's the only thing I could come up with.
The CodeFactor failure wasn't from my changes, I'm not sure what the right carouselItems?.Any() != true equivalent is, carouselItems == null || carouselItems.Count == 0?
Thanks for your contribution.
That said, I would highly recommend asking before submitting relatively complex fixes for features recently released by core team members. On principle, if this is not reviewable within 10 minutes I will be closing it and implement myself as this is already on my task list.
The CodeFactor failure wasn't from my changes, I'm not sure what the right
carouselItems?.Any() != trueequivalent is,carouselItems == null || carouselItems.Count == 0?
codefactor can generally be ignored, yeah.
I'm going to review this. I've started by (hopefully) rebasing the changes on top of latest master.
Added this as closing https://github.com/ppy/osu/issues/33512 as well, as it looks like it should. Will ensure test coverage is added for rulesets.
Closing this as the implementation was wrong in too many ways. New PR will arrive soon.