mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Avoid applying filter in UpdateBeatmapSet
flow
This commit is contained in:
@ -300,16 +300,18 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
root.AddChild(newSet);
|
root.AddChild(newSet);
|
||||||
|
|
||||||
// only reset scroll position if already near the scroll target.
|
|
||||||
// without this, during a large beatmap import it is impossible to navigate the carousel.
|
|
||||||
applyActiveCriteria(false, alwaysResetScrollPosition: false);
|
|
||||||
|
|
||||||
// check if we can/need to maintain our current selection.
|
// check if we can/need to maintain our current selection.
|
||||||
if (previouslySelectedID != null)
|
if (previouslySelectedID != null)
|
||||||
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet);
|
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet);
|
||||||
|
|
||||||
itemsCache.Invalidate();
|
itemsCache.Invalidate();
|
||||||
Schedule(() => BeatmapSetsChanged?.Invoke());
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (!Scroll.UserScrolling)
|
||||||
|
ScrollToSelected(true);
|
||||||
|
|
||||||
|
BeatmapSetsChanged?.Invoke();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Carousel
|
namespace osu.Game.Screens.Select.Carousel
|
||||||
{
|
{
|
||||||
@ -36,7 +37,21 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
|
i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
|
||||||
i.ChildID = ++currentChildID;
|
i.ChildID = ++currentChildID;
|
||||||
InternalChildren.Add(i);
|
|
||||||
|
if (lastCriteria != null)
|
||||||
|
{
|
||||||
|
i.Filter(lastCriteria);
|
||||||
|
|
||||||
|
int index = InternalChildren.BinarySearch(i, criteriaComparer);
|
||||||
|
if (index < 0) index = ~index; // BinarySearch hacks multiple return values with 2's complement.
|
||||||
|
|
||||||
|
InternalChildren.Insert(index, i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// criteria may be null for initial population. the filtering will be applied post-add.
|
||||||
|
InternalChildren.Add(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CarouselGroup(List<CarouselItem> items = null)
|
public CarouselGroup(List<CarouselItem> items = null)
|
||||||
@ -62,14 +77,22 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Comparer<CarouselItem> criteriaComparer;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private FilterCriteria lastCriteria;
|
||||||
|
|
||||||
public override void Filter(FilterCriteria criteria)
|
public override void Filter(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
base.Filter(criteria);
|
base.Filter(criteria);
|
||||||
|
|
||||||
InternalChildren.ForEach(c => c.Filter(criteria));
|
InternalChildren.ForEach(c => c.Filter(criteria));
|
||||||
|
|
||||||
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
|
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
|
||||||
var criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
|
criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
|
||||||
InternalChildren = InternalChildren.OrderBy(c => c, criteriaComparer).ToList();
|
InternalChildren = InternalChildren.OrderBy(c => c, criteriaComparer).ToList();
|
||||||
|
|
||||||
|
lastCriteria = criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
|
protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
|
||||||
|
Reference in New Issue
Block a user