Skip to content

Commit

Permalink
Merge pull request ppy#29786 from bdach/fix-difficulty-sort-selection…
Browse files Browse the repository at this point in the history
…-change

Fix selection being dropped when changing carousel sort mode from difficulty sort
  • Loading branch information
peppy authored Sep 8, 2024
2 parents 4a6266e + cefbc76 commit e836062
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ public void TestAddRemove()
waitForSelection(set_count);
}

[Solo]
[Test]
public void TestDifficultiesSplitOutOnLoad()
{
Expand Down Expand Up @@ -1132,6 +1131,32 @@ public void TestCarouselRemembersSelectionDifficultySort()
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()
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Select/BeatmapCarousel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void loadNewRoot()
// 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;
Expand Down

0 comments on commit e836062

Please sign in to comment.