mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Move main menu (song select) presentation logic to a local implementation
Reduces cross-dependencies between OsuGame and MainMenu.
This commit is contained in:
parent
36e1fb6da8
commit
fcea900a53
@ -361,10 +361,6 @@ namespace osu.Game
|
||||
|
||||
PerformFromScreen(screen =>
|
||||
{
|
||||
// we might already be at song select, so a check is required before performing the load to solo.
|
||||
if (screen is MainMenu)
|
||||
menuScreen.LoadToSolo();
|
||||
|
||||
// we might even already be at the song
|
||||
if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash && (difficultyCriteria?.Invoke(Beatmap.Value.BeatmapInfo) ?? true))
|
||||
return;
|
||||
|
@ -9,12 +9,14 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
@ -23,7 +25,7 @@ using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public class MainMenu : OsuScreen
|
||||
public class MainMenu : OsuScreen, IHandlePresentBeatmap
|
||||
{
|
||||
public const float FADE_IN_DURATION = 300;
|
||||
|
||||
@ -104,7 +106,7 @@ namespace osu.Game.Screens.Menu
|
||||
Beatmap.SetDefault();
|
||||
this.Push(new Editor());
|
||||
},
|
||||
OnSolo = onSolo,
|
||||
OnSolo = loadSoloSongSelect,
|
||||
OnMultiplayer = () => this.Push(new Multiplayer()),
|
||||
OnPlaylists = () => this.Push(new Playlists()),
|
||||
OnExit = confirmAndExit,
|
||||
@ -160,9 +162,7 @@ namespace osu.Game.Screens.Menu
|
||||
LoadComponentAsync(songSelect = new PlaySongSelect());
|
||||
}
|
||||
|
||||
public void LoadToSolo() => Schedule(onSolo);
|
||||
|
||||
private void onSolo() => this.Push(consumeSongSelect());
|
||||
private void loadSoloSongSelect() => this.Push(consumeSongSelect());
|
||||
|
||||
private Screen consumeSongSelect()
|
||||
{
|
||||
@ -289,5 +289,13 @@ namespace osu.Game.Screens.Menu
|
||||
this.FadeOut(3000);
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
public void PresentBeatmap(WorkingBeatmap beatmap, RulesetInfo ruleset)
|
||||
{
|
||||
Beatmap.Value = beatmap;
|
||||
Ruleset.Value = ruleset;
|
||||
|
||||
Schedule(loadSoloSongSelect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user