mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:47:20 +08:00
Present recommended beatmaps
This commit is contained in:
parent
bbef94b4df
commit
872551733f
@ -322,7 +322,7 @@ namespace osu.Game
|
||||
/// </param>
|
||||
public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate<BeatmapInfo> difficultyCriteria = null)
|
||||
{
|
||||
difficultyCriteria ??= b => b.Ruleset.Equals(Ruleset.Value);
|
||||
difficultyCriteria ??= _ => true;
|
||||
|
||||
var databasedSet = beatmap.OnlineBeatmapSetID != null
|
||||
? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID)
|
||||
@ -346,11 +346,15 @@ namespace osu.Game
|
||||
return;
|
||||
}
|
||||
|
||||
// Find first beatmap that matches our predicate.
|
||||
var first = databasedSet.Beatmaps.Find(difficultyCriteria) ?? databasedSet.Beatmaps.First();
|
||||
// Find beatmaps that match our predicate.
|
||||
var beatmaps = databasedSet.Beatmaps.Where(b => difficultyCriteria(b));
|
||||
if (!beatmaps.Any())
|
||||
beatmaps = databasedSet.Beatmaps;
|
||||
|
||||
Ruleset.Value = first.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first);
|
||||
var selection = DifficultyRecommender.GetRecommendedBeatmap(beatmaps);
|
||||
|
||||
Ruleset.Value = selection.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||
}, validScreens: new[] { typeof(PlaySongSelect) });
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,9 @@ namespace osu.Game
|
||||
|
||||
public bool IsDeployedBuild => AssemblyVersion.Major > 0;
|
||||
|
||||
[Cached]
|
||||
protected readonly DifficultyRecommender DifficultyRecommender = new DifficultyRecommender();
|
||||
|
||||
public virtual string Version
|
||||
{
|
||||
get
|
||||
@ -241,9 +244,7 @@ namespace osu.Game
|
||||
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
||||
Add(previewTrackManager);
|
||||
|
||||
DifficultyRecommender difficultyRecommender;
|
||||
dependencies.Cache(difficultyRecommender = new DifficultyRecommender());
|
||||
Add(difficultyRecommender);
|
||||
Add(DifficultyRecommender);
|
||||
|
||||
Ruleset.BindValueChanged(onRulesetChanged);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user