Add sorting support

This commit is contained in:
Dean Herbert
2017-12-14 20:40:58 +09:00
parent b4b2f12116
commit 67f05977ea
7 changed files with 204 additions and 153 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Screens.Select.Carousel
{
@ -32,5 +33,21 @@ namespace osu.Game.Screens.Select.Carousel
Filtered.Value = !match;
}
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
{
if (!(other is CarouselBeatmap otherBeatmap))
return base.CompareTo(criteria, other);
switch (criteria.Sort)
{
default:
case SortMode.Difficulty:
var ruleset = Beatmap.RulesetID.CompareTo(otherBeatmap.Beatmap.RulesetID);
if (ruleset != 0) return ruleset;
return Beatmap.StarDifficulty.CompareTo(otherBeatmap.Beatmap.StarDifficulty);
}
}
}
}