mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Add SortID
to RulesetInfo
to allow stable ordering of rulesets for display
This commit is contained in:
@ -24,6 +24,11 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public string InstantiationInfo { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// A best effort sort ID which provides stable ordering and puts online rulesets before non-online rulesets.
|
||||
/// </summary>
|
||||
public int SortID => OnlineID >= 0 ? OnlineID : Math.Abs(ShortName.GetHashCode());
|
||||
|
||||
public RulesetInfo(string shortName, string name, string instantiationInfo, int onlineID)
|
||||
{
|
||||
ShortName = shortName;
|
||||
|
@ -163,10 +163,7 @@ namespace osu.Game.Rulesets
|
||||
}
|
||||
}
|
||||
|
||||
// add known official rulesets first..
|
||||
availableRulesets.AddRange(detachedRulesets.Where(r => r.OnlineID >= 0).OrderBy(r => r.OnlineID));
|
||||
// .. then add any customs
|
||||
availableRulesets.AddRange(detachedRulesets.Where(r => r.OnlineID < 0).OrderBy(r => r.ShortName));
|
||||
availableRulesets.AddRange(detachedRulesets.OrderBy(r => r.SortID));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
default:
|
||||
case SortMode.Difficulty:
|
||||
int ruleset = BeatmapInfo.RulesetID.CompareTo(otherBeatmap.BeatmapInfo.RulesetID);
|
||||
int ruleset = BeatmapInfo.Ruleset.SortID.CompareTo(otherBeatmap.BeatmapInfo.Ruleset.SortID);
|
||||
if (ruleset != 0) return ruleset;
|
||||
|
||||
return BeatmapInfo.StarRating.CompareTo(otherBeatmap.BeatmapInfo.StarRating);
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
beatmapSet.Beatmaps
|
||||
.Where(b => !b.Hidden)
|
||||
.OrderBy(b => b.RulesetID)
|
||||
.OrderBy(b => b.Ruleset.SortID)
|
||||
.ThenBy(b => b.StarRating)
|
||||
.Select(b => new CarouselBeatmap(b))
|
||||
.ForEach(AddChild);
|
||||
|
Reference in New Issue
Block a user