Allow intro screens to be created without loading a MainMenu

This commit is contained in:
Dean Herbert
2021-10-07 16:38:22 +09:00
parent acaef26af7
commit f88d898960
5 changed files with 46 additions and 7 deletions

View File

@ -49,14 +49,16 @@ namespace osu.Game.Screens
switch (introSequence) switch (introSequence)
{ {
case IntroSequence.Circles: case IntroSequence.Circles:
return new IntroCircles(); return new IntroCircles(createMainMenu);
case IntroSequence.Welcome: case IntroSequence.Welcome:
return new IntroWelcome(); return new IntroWelcome(createMainMenu);
default: default:
return new IntroTriangles(); return new IntroTriangles(createMainMenu);
} }
MainMenu createMainMenu() => new MainMenu();
} }
protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler(); protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler();

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -20,6 +22,11 @@ namespace osu.Game.Screens.Menu
private Sample welcome; private Sample welcome;
public IntroCircles([CanBeNull] Func<MainMenu> createNextScreen = null)
: base(createNextScreen)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {

View File

@ -1,15 +1,17 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
@ -55,7 +57,7 @@ namespace osu.Game.Screens.Menu
private LeasedBindable<WorkingBeatmap> beatmap; private LeasedBindable<WorkingBeatmap> beatmap;
private MainMenu mainMenu; private OsuScreen nextScreen;
[Resolved] [Resolved]
private AudioManager audio { get; set; } private AudioManager audio { get; set; }
@ -63,12 +65,20 @@ namespace osu.Game.Screens.Menu
[Resolved] [Resolved]
private MusicController musicController { get; set; } private MusicController musicController { get; set; }
[CanBeNull]
private readonly Func<OsuScreen> createNextScreen;
/// <summary> /// <summary>
/// Whether the <see cref="Track"/> is provided by osu! resources, rather than a user beatmap. /// Whether the <see cref="Track"/> is provided by osu! resources, rather than a user beatmap.
/// Only valid during or after <see cref="LogoArriving"/>. /// Only valid during or after <see cref="LogoArriving"/>.
/// </summary> /// </summary>
protected bool UsingThemedIntro { get; private set; } protected bool UsingThemedIntro { get; private set; }
protected IntroScreen([CanBeNull] Func<MainMenu> createNextScreen = null)
{
this.createNextScreen = createNextScreen;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game)
{ {
@ -214,14 +224,21 @@ namespace osu.Game.Screens.Menu
} }
} }
protected void PrepareMenuLoad() => LoadComponentAsync(mainMenu = new MainMenu()); protected void PrepareMenuLoad()
{
nextScreen = createNextScreen?.Invoke();
if (nextScreen != null)
LoadComponentAsync(nextScreen);
}
protected void LoadMenu() protected void LoadMenu()
{ {
beatmap.Return(); beatmap.Return();
DidLoadMenu = true; DidLoadMenu = true;
this.Push(mainMenu); if (nextScreen != null)
this.Push(nextScreen);
} }
} }
} }

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -44,6 +45,11 @@ namespace osu.Game.Screens.Menu
private DecoupleableInterpolatingFramedClock decoupledClock; private DecoupleableInterpolatingFramedClock decoupledClock;
private TrianglesIntroSequence intro; private TrianglesIntroSequence intro;
public IntroTriangles([CanBeNull] Func<MainMenu> createNextScreen = null)
: base(createNextScreen)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osuTK; using osuTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -32,6 +34,11 @@ namespace osu.Game.Screens.Menu
private BackgroundScreenDefault background; private BackgroundScreenDefault background;
public IntroWelcome([CanBeNull] Func<MainMenu> createNextScreen = null)
: base(createNextScreen)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {