mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
Merge pull request #23312 from Renzo904/fix-rewind-bug
Fix song select rewind logic not handling deleted beatmaps
This commit is contained in:
commit
d563de0e54
@ -453,6 +453,25 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRewindToDeletedBeatmap()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
var firstAdded = TestResources.CreateTestBeatmapSetInfo();
|
||||||
|
|
||||||
|
AddStep("add new set", () => carousel.UpdateBeatmapSet(firstAdded));
|
||||||
|
AddStep("select set", () => carousel.SelectBeatmap(firstAdded.Beatmaps.First()));
|
||||||
|
|
||||||
|
nextRandom();
|
||||||
|
|
||||||
|
AddStep("delete set", () => carousel.RemoveBeatmapSet(firstAdded));
|
||||||
|
|
||||||
|
prevRandom();
|
||||||
|
|
||||||
|
AddAssert("deleted set not selected", () => carousel.SelectedBeatmapSet?.Equals(firstAdded) == false);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test adding and removing beatmap sets
|
/// Test adding and removing beatmap sets
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -155,7 +155,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public Bindable<RandomSelectAlgorithm> RandomAlgorithm = new Bindable<RandomSelectAlgorithm>();
|
public Bindable<RandomSelectAlgorithm> RandomAlgorithm = new Bindable<RandomSelectAlgorithm>();
|
||||||
private readonly List<CarouselBeatmapSet> previouslyVisitedRandomSets = new List<CarouselBeatmapSet>();
|
private readonly List<CarouselBeatmapSet> previouslyVisitedRandomSets = new List<CarouselBeatmapSet>();
|
||||||
private readonly Stack<CarouselBeatmap> randomSelectedBeatmaps = new Stack<CarouselBeatmap>();
|
private readonly List<CarouselBeatmap> randomSelectedBeatmaps = new List<CarouselBeatmap>();
|
||||||
|
|
||||||
private CarouselRoot root;
|
private CarouselRoot root;
|
||||||
|
|
||||||
@ -348,6 +348,11 @@ namespace osu.Game.Screens.Select
|
|||||||
if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSet))
|
if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
foreach (var beatmap in existingSet.Beatmaps)
|
||||||
|
randomSelectedBeatmaps.Remove(beatmap);
|
||||||
|
|
||||||
|
previouslyVisitedRandomSets.Remove(existingSet);
|
||||||
|
|
||||||
root.RemoveItem(existingSet);
|
root.RemoveItem(existingSet);
|
||||||
itemsCache.Invalidate();
|
itemsCache.Invalidate();
|
||||||
|
|
||||||
@ -501,7 +506,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
if (selectedBeatmap != null && selectedBeatmapSet != null)
|
if (selectedBeatmap != null && selectedBeatmapSet != null)
|
||||||
{
|
{
|
||||||
randomSelectedBeatmaps.Push(selectedBeatmap);
|
randomSelectedBeatmaps.Add(selectedBeatmap);
|
||||||
|
|
||||||
// when performing a random, we want to add the current set to the previously visited list
|
// when performing a random, we want to add the current set to the previously visited list
|
||||||
// else the user may be "randomised" to the existing selection.
|
// else the user may be "randomised" to the existing selection.
|
||||||
@ -538,9 +543,10 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
while (randomSelectedBeatmaps.Any())
|
while (randomSelectedBeatmaps.Any())
|
||||||
{
|
{
|
||||||
var beatmap = randomSelectedBeatmaps.Pop();
|
var beatmap = randomSelectedBeatmaps[^1];
|
||||||
|
randomSelectedBeatmaps.Remove(beatmap);
|
||||||
|
|
||||||
if (!beatmap.Filtered.Value)
|
if (!beatmap.Filtered.Value && beatmap.BeatmapInfo.BeatmapSet?.DeletePending != true)
|
||||||
{
|
{
|
||||||
if (selectedBeatmapSet != null)
|
if (selectedBeatmapSet != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user