mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Merge pull request #2127 from peppy/fix-song-select-iteration
Fix song select iteration when all panels are filtered
This commit is contained in:
commit
1936498392
@ -207,6 +207,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
checkVisibleItemCount(true, 0);
|
checkVisibleItemCount(true, 0);
|
||||||
AddAssert("Selection is null", () => currentSelection == null);
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
|
advanceSelection(true);
|
||||||
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
|
advanceSelection(false);
|
||||||
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||||
|
|
||||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||||
|
@ -192,7 +192,9 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
|
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
|
||||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||||
{
|
{
|
||||||
if (!Items.Any())
|
var visibleItems = Items.Where(s => !s.Item.Filtered).ToList();
|
||||||
|
|
||||||
|
if (!visibleItems.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DrawableCarouselItem drawable = null;
|
DrawableCarouselItem drawable = null;
|
||||||
@ -202,15 +204,15 @@ namespace osu.Game.Screens.Select
|
|||||||
// we can fix this by changing this method to not reference drawables / Items in the first place.
|
// we can fix this by changing this method to not reference drawables / Items in the first place.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int originalIndex = Items.IndexOf(drawable);
|
int originalIndex = visibleItems.IndexOf(drawable);
|
||||||
int currentIndex = originalIndex;
|
int currentIndex = originalIndex;
|
||||||
|
|
||||||
// local function to increment the index in the required direction, wrapping over extremities.
|
// local function to increment the index in the required direction, wrapping over extremities.
|
||||||
int incrementIndex() => currentIndex = (currentIndex + direction + Items.Count) % Items.Count;
|
int incrementIndex() => currentIndex = (currentIndex + direction + visibleItems.Count) % visibleItems.Count;
|
||||||
|
|
||||||
while (incrementIndex() != originalIndex)
|
while (incrementIndex() != originalIndex)
|
||||||
{
|
{
|
||||||
var item = Items[currentIndex].Item;
|
var item = visibleItems[currentIndex].Item;
|
||||||
|
|
||||||
if (item.Filtered || item.State == CarouselItemState.Selected) continue;
|
if (item.Filtered || item.State == CarouselItemState.Selected) continue;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user