1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 08:27:49 +08:00

Merge pull request #29786 from bdach/fix-difficulty-sort-selection-change

Fix selection being dropped when changing carousel sort mode from difficulty sort
This commit is contained in:
Dean Herbert 2024-09-09 00:45:33 +09:00 committed by GitHub
commit e836062b21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -520,7 +520,6 @@ namespace osu.Game.Tests.Visual.SongSelect
waitForSelection(set_count);
}
[Solo]
[Test]
public void TestDifficultiesSplitOutOnLoad()
{
@ -1132,6 +1131,32 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1);
}
[Test]
public void TestCarouselRetainsSelectionFromDifficultySort()
{
List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
AddStep("Populate beatmap sets", () =>
{
manySets.Clear();
for (int i = 1; i <= 50; i++)
manySets.Add(TestResources.CreateTestBeatmapSetInfo(diff_count));
});
loadBeatmaps(manySets);
BeatmapInfo chosenBeatmap = null!;
AddStep("select given beatmap", () => carousel.SelectBeatmap(chosenBeatmap = manySets[20].Beatmaps[0]));
AddUntilStep("selection changed", () => carousel.SelectedBeatmapInfo, () => Is.EqualTo(chosenBeatmap));
AddStep("sort by difficulty", () => carousel.FilterImmediately(new FilterCriteria { Sort = SortMode.Difficulty }));
AddAssert("selection retained", () => carousel.SelectedBeatmapInfo, () => Is.EqualTo(chosenBeatmap));
AddStep("sort by title", () => carousel.FilterImmediately(new FilterCriteria { Sort = SortMode.Title }));
AddAssert("selection retained", () => carousel.SelectedBeatmapInfo, () => Is.EqualTo(chosenBeatmap));
}
[Test]
public void TestFilteringByUserStarDifficulty()
{

View File

@ -143,7 +143,7 @@ namespace osu.Game.Screens.Select
// We'll catch up on changes via subscriptions anyway.
BeatmapSetInfo[] loadableSets = detachedBeatmapSets!.ToArray();
if (selectedBeatmapSet != null && !loadableSets.Contains(selectedBeatmapSet.BeatmapSet))
if (selectedBeatmapSet != null && !loadableSets.Contains(selectedBeatmapSet.BeatmapSet, EqualityComparer<BeatmapSetInfo>.Default))
selectedBeatmapSet = null;
var selectedBeatmapBefore = selectedBeatmap?.BeatmapInfo;