mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Implemented basic sorting logic
This commit is contained in:
@ -184,6 +184,44 @@ namespace osu.Game.Screens.Select
|
|||||||
ScrollTo(selectedY, animated);
|
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)
|
private static float offsetX(float dist, float halfHeight)
|
||||||
{
|
{
|
||||||
// The radius of the circle the carousel moves on.
|
// The radius of the circle the carousel moves on.
|
||||||
|
@ -250,9 +250,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public enum SortMode
|
public enum SortMode
|
||||||
{
|
{
|
||||||
Arist,
|
Artist,
|
||||||
BPM,
|
BPM,
|
||||||
Creator,
|
Author,
|
||||||
DateAdded,
|
DateAdded,
|
||||||
Difficulty,
|
Difficulty,
|
||||||
Length,
|
Length,
|
||||||
@ -263,9 +263,9 @@ namespace osu.Game.Screens.Select
|
|||||||
public enum GroupMode
|
public enum GroupMode
|
||||||
{
|
{
|
||||||
NoGrouping,
|
NoGrouping,
|
||||||
Arist,
|
Artist,
|
||||||
BPM,
|
BPM,
|
||||||
Creator,
|
Author,
|
||||||
DateAdded,
|
DateAdded,
|
||||||
Difficulty,
|
Difficulty,
|
||||||
Length,
|
Length,
|
||||||
|
@ -174,6 +174,7 @@ namespace osu.Game.Screens.Select
|
|||||||
filterTask = null;
|
filterTask = null;
|
||||||
var search = filter.Search;
|
var search = filter.Search;
|
||||||
BeatmapGroup newSelection = null;
|
BeatmapGroup newSelection = null;
|
||||||
|
carousel.Sort(filter.Sort);
|
||||||
foreach (var beatmapGroup in carousel)
|
foreach (var beatmapGroup in carousel)
|
||||||
{
|
{
|
||||||
var set = beatmapGroup.BeatmapSet;
|
var set = beatmapGroup.BeatmapSet;
|
||||||
@ -373,6 +374,7 @@ namespace osu.Game.Screens.Select
|
|||||||
if (token.IsCancellationRequested) return;
|
if (token.IsCancellationRequested) return;
|
||||||
addBeatmapSet(beatmapSet, game);
|
addBeatmapSet(beatmapSet, game);
|
||||||
}
|
}
|
||||||
|
filterChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
Reference in New Issue
Block a user