mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:52:55 +08:00
Fix carousel including filtered difficulties in sort comparisons
This commit is contained in:
parent
46d6c5ec3b
commit
f15953d65c
@ -49,16 +49,33 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);
|
||||
|
||||
case SortMode.BPM:
|
||||
return BeatmapSet.MaxBPM.CompareTo(otherSet.BeatmapSet.MaxBPM);
|
||||
return compareUsingAggregateMax(otherSet, b => b.BPM);
|
||||
|
||||
case SortMode.Length:
|
||||
return BeatmapSet.MaxLength.CompareTo(otherSet.BeatmapSet.MaxLength);
|
||||
return compareUsingAggregateMax(otherSet, b => b.Length);
|
||||
|
||||
case SortMode.Difficulty:
|
||||
return BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty);
|
||||
return compareUsingAggregateMax(otherSet, b => b.StarDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All beatmaps which are not filtered and valid for display.
|
||||
/// </summary>
|
||||
protected IEnumerable<BeatmapInfo> ValidBeatmaps => Beatmaps.Where(b => !b.Filtered.Value).Select(b => b.Beatmap);
|
||||
|
||||
private int compareUsingAggregateMax(CarouselBeatmapSet other, Func<BeatmapInfo, double> func)
|
||||
{
|
||||
var ourBeatmaps = ValidBeatmaps.Any();
|
||||
var otherBeatmaps = other.ValidBeatmaps.Any();
|
||||
|
||||
if (!ourBeatmaps && !otherBeatmaps) return 0;
|
||||
if (!ourBeatmaps) return -1;
|
||||
if (!otherBeatmaps) return 1;
|
||||
|
||||
return ValidBeatmaps.Max(func).CompareTo(other.ValidBeatmaps.Max(func));
|
||||
}
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
|
@ -83,8 +83,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
var children = new List<CarouselItem>(InternalChildren);
|
||||
|
||||
children.Sort((x, y) => x.CompareTo(criteria, y));
|
||||
children.ForEach(c => c.Filter(criteria));
|
||||
children.Sort((x, y) => x.CompareTo(criteria, y));
|
||||
|
||||
InternalChildren = children;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user