mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:35:05 +08:00
Implemented basic sorting logic
This commit is contained in:
parent
ecb840e26f
commit
7dcbefd50f
@ -184,6 +184,44 @@ namespace osu.Game.Screens.Select
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
|
||||
public void Sort(FilterControl.SortMode mode) {
|
||||
switch (mode) {
|
||||
case FilterControl.SortMode.Artist:
|
||||
groups.Sort((x, y) =>
|
||||
{
|
||||
return string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist);
|
||||
});
|
||||
break;
|
||||
case FilterControl.SortMode.Title:
|
||||
groups.Sort((x, y) =>
|
||||
{
|
||||
return string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title);
|
||||
});
|
||||
break;
|
||||
case FilterControl.SortMode.Author:
|
||||
groups.Sort((x, y) =>
|
||||
{
|
||||
return string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author);
|
||||
});
|
||||
break;
|
||||
case FilterControl.SortMode.Difficulty:
|
||||
groups.Sort((x, y) =>
|
||||
{
|
||||
if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty >
|
||||
y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty)
|
||||
return 1;
|
||||
else if (Equals(x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty,
|
||||
y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static float offsetX(float dist, float halfHeight)
|
||||
{
|
||||
// The radius of the circle the carousel moves on.
|
||||
|
@ -250,9 +250,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public enum SortMode
|
||||
{
|
||||
Arist,
|
||||
Artist,
|
||||
BPM,
|
||||
Creator,
|
||||
Author,
|
||||
DateAdded,
|
||||
Difficulty,
|
||||
Length,
|
||||
@ -263,9 +263,9 @@ namespace osu.Game.Screens.Select
|
||||
public enum GroupMode
|
||||
{
|
||||
NoGrouping,
|
||||
Arist,
|
||||
Artist,
|
||||
BPM,
|
||||
Creator,
|
||||
Author,
|
||||
DateAdded,
|
||||
Difficulty,
|
||||
Length,
|
||||
|
@ -174,6 +174,7 @@ namespace osu.Game.Screens.Select
|
||||
filterTask = null;
|
||||
var search = filter.Search;
|
||||
BeatmapGroup newSelection = null;
|
||||
carousel.Sort(filter.Sort);
|
||||
foreach (var beatmapGroup in carousel)
|
||||
{
|
||||
var set = beatmapGroup.BeatmapSet;
|
||||
@ -373,6 +374,7 @@ namespace osu.Game.Screens.Select
|
||||
if (token.IsCancellationRequested) return;
|
||||
addBeatmapSet(beatmapSet, game);
|
||||
}
|
||||
filterChanged();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
|
Loading…
Reference in New Issue
Block a user