diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index ff3dee55af..3d6b93c87d 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -311,22 +311,12 @@ namespace osu.Game
public void ShowBeatmap(int beatmapId) => waitForReady(() => beatmapSetOverlay, _ => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId));
///
- /// Present a beatmap at song select immediately.
+ /// Present a specific beatmap difficulty at song select immediately.
/// The user should have already requested this interactively.
///
/// The beatmap to select.
- public void PresentBeatmap(BeatmapSetInfo beatmap)
+ public void PresentBeatmap(BeatmapInfo beatmap)
{
- var databasedSet = beatmap.OnlineBeatmapSetID != null
- ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID)
- : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash);
-
- if (databasedSet == null)
- {
- Logger.Log("The requested beatmap could not be loaded.", LoggingTarget.Information);
- return;
- }
-
PerformFromScreen(screen =>
{
// we might already be at song select, so a check is required before performing the load to solo.
@@ -334,19 +324,36 @@ namespace osu.Game
menuScreen.LoadToSolo();
// we might even already be at the song
- if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash)
- {
+ if (Beatmap.Value.BeatmapInfo.Hash == beatmap.Hash)
return;
- }
- // Use first beatmap available for current ruleset, else switch ruleset.
- var first = databasedSet.Beatmaps.Find(b => b.Ruleset.Equals(Ruleset.Value)) ?? databasedSet.Beatmaps.First();
-
- Ruleset.Value = first.Ruleset;
- Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first);
+ Ruleset.Value = beatmap.Ruleset;
+ Beatmap.Value = BeatmapManager.GetWorkingBeatmap(beatmap);
}, validScreens: new[] { typeof(PlaySongSelect) });
}
+ ///
+ ///
+ /// Instead of selecting a specific difficulty, this will select the first difficulty of the current ruleset in a beatmapset,
+ /// or the first difficulty of the set if there is none.
+ ///
+ /// The beatmapset to select.
+ public void PresentBeatmap(BeatmapSetInfo beatmapSet)
+ {
+ var databasedSet = beatmapSet.OnlineBeatmapSetID != null
+ ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmapSet.OnlineBeatmapSetID)
+ : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmapSet.Hash);
+
+ if (databasedSet == null)
+ {
+ Logger.Log("The requested beatmap could not be loaded.", LoggingTarget.Information);
+ return;
+ }
+
+ var first = databasedSet.Beatmaps.Find(b => b.Ruleset.Equals(Ruleset.Value)) ?? databasedSet.Beatmaps.First();
+ PresentBeatmap(first);
+ }
+
///
/// Present a score's replay immediately.
/// The user should have already requested this interactively.
diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
index 80dae575ff..9e4f31b15b 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
@@ -34,8 +34,6 @@ namespace osu.Game.Screens.Select.Carousel
private DialogOverlay dialogOverlay;
private readonly BeatmapSetInfo beatmapSet;
- private SongSelect songSelect;
-
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
: base(set)
{
@@ -43,11 +41,8 @@ namespace osu.Game.Screens.Select.Carousel
}
[BackgroundDependencyLoader(true)]
- private void load(SongSelect songSelect, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay)
+ private void load(BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay)
{
- if (songSelect != null)
- this.songSelect = songSelect;
-
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
dialogOverlay = overlay;
if (beatmapOverlay != null)
@@ -123,7 +118,7 @@ namespace osu.Game.Screens.Select.Carousel
return beatmaps.Count > maximum_difficulty_icons
? (IEnumerable)beatmaps.GroupBy(b => b.Beatmap.Ruleset).Select(group => new FilterableGroupedDifficultyIcon(group.ToList(), group.Key))
- : beatmaps.Select(b => new FilterableDifficultyIcon(b, songSelect));
+ : beatmaps.Select(b => new FilterableDifficultyIcon(b));
}
public MenuItem[] ContextMenuItems
@@ -216,17 +211,17 @@ namespace osu.Game.Screens.Select.Carousel
{
private readonly BindableBool filtered = new BindableBool();
- private readonly SongSelect songSelect;
+ private OsuGame game;
+ private SongSelect songSelect;
private readonly BeatmapInfo info;
- public FilterableDifficultyIcon(CarouselBeatmap item, SongSelect songSelect)
+ public FilterableDifficultyIcon(CarouselBeatmap item)
: base(item.Beatmap)
{
filtered.BindTo(item.Filtered);
filtered.ValueChanged += isFiltered => Schedule(() => this.FadeTo(isFiltered.NewValue ? 0.1f : 1, 100));
filtered.TriggerChange();
- this.songSelect = songSelect;
info = item.Beatmap;
}
@@ -234,7 +229,7 @@ namespace osu.Game.Screens.Select.Carousel
{
if (!filtered.Value)
{
- songSelect?.Carousel.SelectBeatmap(info);
+ game.PresentBeatmap(info);
if (e.AltPressed)
songSelect?.FinaliseSelection();
@@ -242,6 +237,15 @@ namespace osu.Game.Screens.Select.Carousel
return base.OnClick(e);
}
+
+ [BackgroundDependencyLoader]
+ private void load(OsuGame game, SongSelect songSelect)
+ {
+ this.game = game;
+
+ if (songSelect != null)
+ this.songSelect = songSelect;
+ }
}
public class FilterableGroupedDifficultyIcon : GroupedDifficultyIcon
diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs
index 463a17989a..5037081b5e 100644
--- a/osu.Game/Screens/Select/SongSelect.cs
+++ b/osu.Game/Screens/Select/SongSelect.cs
@@ -80,7 +80,7 @@ namespace osu.Game.Screens.Select
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
- public BeatmapCarousel Carousel { get; private set; }
+ protected BeatmapCarousel Carousel { get; private set; }
private BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;