mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 22:42:57 +08:00
Change difficulty sort to be based on MaxStarDifficulty.
This commit is contained in:
parent
360340c61d
commit
4d84bf7350
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SQLite.Net.Attributes;
|
||||
using SQLiteNetExtensions.Attributes;
|
||||
|
||||
@ -23,6 +24,8 @@ namespace osu.Game.Database
|
||||
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||
|
||||
public float MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
|
||||
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
@ -173,28 +173,7 @@ namespace osu.Game.Screens.Select
|
||||
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Difficulty:
|
||||
sortedGroups.Sort((x, y) =>
|
||||
{
|
||||
float xAverage = 0, yAverage = 0;
|
||||
int counter = 0;
|
||||
foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps)
|
||||
{
|
||||
xAverage += set.StarDifficulty;
|
||||
counter++;
|
||||
}
|
||||
xAverage /= counter;
|
||||
counter = 0;
|
||||
foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps)
|
||||
{
|
||||
yAverage += set.StarDifficulty;
|
||||
counter++;
|
||||
}
|
||||
yAverage /= counter;
|
||||
if (xAverage > yAverage)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
});
|
||||
sortedGroups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty));
|
||||
break;
|
||||
default:
|
||||
Sort(SortMode.Artist); // Temporary
|
||||
|
Loading…
Reference in New Issue
Block a user