mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Use selectNextRandom instead
This commit is contained in:
parent
3f65e3a7e3
commit
7e30375443
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Select
|
|||||||
get { return beatmapSets.Select(g => g.BeatmapSet); }
|
get { return beatmapSets.Select(g => g.BeatmapSet); }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
CarouselGroup newRoot = new CarouselGroupEagerSelect(true);
|
CarouselGroup newRoot = new CarouselGroupEagerSelect(this);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -102,10 +102,11 @@ namespace osu.Game.Screens.Select
|
|||||||
private readonly Stack<CarouselBeatmap> randomSelectedBeatmaps = new Stack<CarouselBeatmap>();
|
private readonly Stack<CarouselBeatmap> randomSelectedBeatmaps = new Stack<CarouselBeatmap>();
|
||||||
|
|
||||||
protected List<DrawableCarouselItem> Items = new List<DrawableCarouselItem>();
|
protected List<DrawableCarouselItem> Items = new List<DrawableCarouselItem>();
|
||||||
private CarouselGroup root = new CarouselGroupEagerSelect(true);
|
private CarouselGroup root;
|
||||||
|
|
||||||
public BeatmapCarousel()
|
public BeatmapCarousel()
|
||||||
{
|
{
|
||||||
|
root = new CarouselGroupEagerSelect(this);
|
||||||
Child = new OsuContextMenuContainer
|
Child = new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@ -12,11 +11,11 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CarouselGroupEagerSelect : CarouselGroup
|
public class CarouselGroupEagerSelect : CarouselGroup
|
||||||
{
|
{
|
||||||
private readonly bool isRootSelector;
|
private readonly BeatmapCarousel parent;
|
||||||
|
|
||||||
public CarouselGroupEagerSelect(bool isRootSelector = false)
|
public CarouselGroupEagerSelect(BeatmapCarousel parent = null)
|
||||||
{
|
{
|
||||||
this.isRootSelector = isRootSelector;
|
this.parent = parent;
|
||||||
State.ValueChanged += v =>
|
State.ValueChanged += v =>
|
||||||
{
|
{
|
||||||
if (v == CarouselItemState.Selected)
|
if (v == CarouselItemState.Selected)
|
||||||
@ -87,20 +86,15 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
// we only perform eager selection if none of our children are in a selected state already.
|
// we only perform eager selection if none of our children are in a selected state already.
|
||||||
if (Children.Any(i => i.State == CarouselItemState.Selected)) return;
|
if (Children.Any(i => i.State == CarouselItemState.Selected)) return;
|
||||||
|
|
||||||
CarouselItem nextToSelect = null;
|
if (parent != null && lastSelected == null)
|
||||||
if (isRootSelector && lastSelected == null)
|
|
||||||
{
|
{
|
||||||
var selectables = Children.Where(i => !i.Filtered).ToList();
|
parent.SelectNextRandom();
|
||||||
if (selectables.Any())
|
return;
|
||||||
nextToSelect = selectables[RNG.Next(selectables.Count)];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nextToSelect =
|
|
||||||
Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ??
|
|
||||||
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CarouselItem nextToSelect =
|
||||||
|
Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ??
|
||||||
|
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered);
|
||||||
|
|
||||||
if (nextToSelect != null)
|
if (nextToSelect != null)
|
||||||
nextToSelect.State.Value = CarouselItemState.Selected;
|
nextToSelect.State.Value = CarouselItemState.Selected;
|
||||||
|
Loading…
Reference in New Issue
Block a user