mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Abstract intro screen logic to base class
This commit is contained in:
@ -71,7 +71,7 @@ namespace osu.Desktop
|
|||||||
|
|
||||||
switch (newScreen)
|
switch (newScreen)
|
||||||
{
|
{
|
||||||
case Intro _:
|
case IntroScreen _:
|
||||||
case MainMenu _:
|
case MainMenu _:
|
||||||
versionManager?.Show();
|
versionManager?.Show();
|
||||||
break;
|
break;
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Menus
|
namespace osu.Game.Tests.Visual.Menus
|
||||||
@ -45,13 +46,15 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
},
|
},
|
||||||
new OsuScreenStack(new Intro())
|
new OsuScreenStack(new IntroCircles())
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
logo = new OsuLogo
|
logo = new OsuLogo
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Alpha = 0,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Position = new Vector2(0.5f),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -86,7 +86,8 @@ namespace osu.Game
|
|||||||
private BackButton backButton;
|
private BackButton backButton;
|
||||||
|
|
||||||
private MainMenu menuScreen;
|
private MainMenu menuScreen;
|
||||||
private Intro introScreen;
|
|
||||||
|
private IntroScreen introScreen;
|
||||||
|
|
||||||
private Bindable<int> configRuleset;
|
private Bindable<int> configRuleset;
|
||||||
|
|
||||||
@ -760,7 +761,7 @@ namespace osu.Game
|
|||||||
if (introScreen == null)
|
if (introScreen == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!introScreen.DidLoadMenu || !(screenStack.CurrentScreen is Intro))
|
if (!introScreen.DidLoadMenu || !(screenStack.CurrentScreen is IntroScreen))
|
||||||
{
|
{
|
||||||
Scheduler.Add(introScreen.MakeCurrent);
|
Scheduler.Add(introScreen.MakeCurrent);
|
||||||
return true;
|
return true;
|
||||||
@ -795,7 +796,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
switch (newScreen)
|
switch (newScreen)
|
||||||
{
|
{
|
||||||
case Intro intro:
|
case IntroScreen intro:
|
||||||
introScreen = intro;
|
introScreen = intro;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
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;
|
||||||
@ -12,41 +11,24 @@ using osu.Framework.MathUtils;
|
|||||||
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;
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
public class Intro : StartupScreen
|
public class IntroCircles : IntroScreen
|
||||||
{
|
{
|
||||||
private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83";
|
private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we have loaded the menu previously.
|
|
||||||
/// </summary>
|
|
||||||
public bool DidLoadMenu;
|
|
||||||
|
|
||||||
private MainMenu mainMenu;
|
|
||||||
private SampleChannel welcome;
|
private SampleChannel welcome;
|
||||||
private SampleChannel seeya;
|
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
|
|
||||||
|
|
||||||
private readonly BindableDouble exitingVolumeFade = new BindableDouble(1);
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private AudioManager audio { get; set; }
|
|
||||||
|
|
||||||
private Bindable<bool> menuVoice;
|
|
||||||
private Bindable<bool> menuMusic;
|
private Bindable<bool> menuMusic;
|
||||||
|
|
||||||
private Track track;
|
private Track track;
|
||||||
|
|
||||||
private WorkingBeatmap introBeatmap;
|
private WorkingBeatmap introBeatmap;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
|
private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, ISampleStore samples)
|
||||||
{
|
{
|
||||||
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
|
||||||
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
||||||
|
|
||||||
BeatmapSetInfo setInfo = null;
|
BeatmapSetInfo setInfo = null;
|
||||||
@ -75,15 +57,13 @@ namespace osu.Game.Screens.Menu
|
|||||||
introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
||||||
track = introBeatmap.Track;
|
track = introBeatmap.Track;
|
||||||
|
|
||||||
welcome = audio.Samples.Get(@"welcome");
|
if (config.Get<bool>(OsuSetting.MenuVoice))
|
||||||
seeya = audio.Samples.Get(@"seeya");
|
welcome = samples.Get(@"welcome");
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double delay_step_one = 2300;
|
private const double delay_step_one = 2300;
|
||||||
private const double delay_step_two = 600;
|
private const double delay_step_two = 600;
|
||||||
|
|
||||||
public const int EXIT_DELAY = 3000;
|
|
||||||
|
|
||||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||||
{
|
{
|
||||||
base.LogoArriving(logo, resuming);
|
base.LogoArriving(logo, resuming);
|
||||||
@ -93,8 +73,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
Beatmap.Value = introBeatmap;
|
Beatmap.Value = introBeatmap;
|
||||||
introBeatmap = null;
|
introBeatmap = null;
|
||||||
|
|
||||||
if (menuVoice.Value)
|
welcome?.Play();
|
||||||
welcome.Play();
|
|
||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
@ -105,74 +84,23 @@ namespace osu.Game.Screens.Menu
|
|||||||
track = null;
|
track = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(mainMenu = new MainMenu());
|
PrepareMenuLoad();
|
||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(LoadMenu, delay_step_one);
|
||||||
{
|
|
||||||
DidLoadMenu = true;
|
|
||||||
this.Push(mainMenu);
|
|
||||||
}, delay_step_one);
|
|
||||||
}, delay_step_two);
|
}, delay_step_two);
|
||||||
}
|
|
||||||
|
|
||||||
logo.Colour = Color4.White;
|
|
||||||
logo.Ripple = false;
|
|
||||||
|
|
||||||
const int quick_appear = 350;
|
|
||||||
|
|
||||||
int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0;
|
|
||||||
|
|
||||||
logo.MoveTo(new Vector2(0.5f), initialMovementTime, Easing.OutQuint);
|
|
||||||
|
|
||||||
if (!resuming)
|
|
||||||
{
|
|
||||||
logo.ScaleTo(1);
|
logo.ScaleTo(1);
|
||||||
logo.FadeIn();
|
logo.FadeIn();
|
||||||
logo.PlayIntro();
|
logo.PlayIntro();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
logo.Triangles = false;
|
|
||||||
|
|
||||||
logo
|
|
||||||
.ScaleTo(1, initialMovementTime, Easing.OutQuint)
|
|
||||||
.FadeIn(quick_appear, Easing.OutQuint)
|
|
||||||
.Then()
|
|
||||||
.RotateTo(20, EXIT_DELAY * 1.5f)
|
|
||||||
.FadeOut(EXIT_DELAY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public override void OnSuspending(IScreen next)
|
||||||
{
|
{
|
||||||
|
track = null;
|
||||||
|
|
||||||
this.FadeOut(300);
|
this.FadeOut(300);
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
|
||||||
{
|
|
||||||
//cancel exiting if we haven't loaded the menu yet.
|
|
||||||
return !DidLoadMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
|
||||||
{
|
|
||||||
this.FadeIn(300);
|
|
||||||
|
|
||||||
double fadeOutTime = EXIT_DELAY;
|
|
||||||
//we also handle the exit transition.
|
|
||||||
if (menuVoice.Value)
|
|
||||||
seeya.Play();
|
|
||||||
else
|
|
||||||
fadeOutTime = 500;
|
|
||||||
|
|
||||||
audio.AddAdjustment(AdjustableProperty.Volume, exitingVolumeFade);
|
|
||||||
this.TransformBindableTo(exitingVolumeFade, 0, fadeOutTime).OnComplete(_ => this.Exit());
|
|
||||||
|
|
||||||
//don't want to fade out completely else we will stop running updates.
|
|
||||||
Game.FadeTo(0.01f, fadeOutTime);
|
|
||||||
|
|
||||||
base.OnResuming(last);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
114
osu.Game/Screens/Menu/IntroScreen.cs
Normal file
114
osu.Game/Screens/Menu/IntroScreen.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Backgrounds;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Menu
|
||||||
|
{
|
||||||
|
public abstract class IntroScreen : StartupScreen
|
||||||
|
{
|
||||||
|
private readonly BindableDouble exitingVolumeFade = new BindableDouble(1);
|
||||||
|
|
||||||
|
public const int EXIT_DELAY = 3000;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
|
private SampleChannel seeya;
|
||||||
|
|
||||||
|
private Bindable<bool> menuVoice;
|
||||||
|
|
||||||
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
|
||||||
|
{
|
||||||
|
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
||||||
|
seeya = audio.Samples.Get(@"seeya");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we have loaded the menu previously.
|
||||||
|
/// </summary>
|
||||||
|
public bool DidLoadMenu { get; private set; }
|
||||||
|
|
||||||
|
public override bool OnExiting(IScreen next)
|
||||||
|
{
|
||||||
|
//cancel exiting if we haven't loaded the menu yet.
|
||||||
|
return !DidLoadMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnResuming(IScreen last)
|
||||||
|
{
|
||||||
|
this.FadeIn(300);
|
||||||
|
|
||||||
|
double fadeOutTime = EXIT_DELAY;
|
||||||
|
//we also handle the exit transition.
|
||||||
|
if (menuVoice.Value)
|
||||||
|
seeya.Play();
|
||||||
|
else
|
||||||
|
fadeOutTime = 500;
|
||||||
|
|
||||||
|
audio.AddAdjustment(AdjustableProperty.Volume, exitingVolumeFade);
|
||||||
|
this.TransformBindableTo(exitingVolumeFade, 0, fadeOutTime).OnComplete(_ => this.Exit());
|
||||||
|
|
||||||
|
//don't want to fade out completely else we will stop running updates.
|
||||||
|
Game.FadeTo(0.01f, fadeOutTime);
|
||||||
|
|
||||||
|
base.OnResuming(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||||
|
{
|
||||||
|
base.LogoArriving(logo, resuming);
|
||||||
|
|
||||||
|
logo.Colour = Color4.White;
|
||||||
|
logo.Triangles = false;
|
||||||
|
logo.Ripple = false;
|
||||||
|
|
||||||
|
if (!resuming)
|
||||||
|
{
|
||||||
|
logo.MoveTo(new Vector2(0.5f));
|
||||||
|
logo.ScaleTo(Vector2.One);
|
||||||
|
logo.Hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int quick_appear = 350;
|
||||||
|
int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0;
|
||||||
|
|
||||||
|
logo.MoveTo(new Vector2(0.5f), initialMovementTime, Easing.OutQuint);
|
||||||
|
|
||||||
|
logo
|
||||||
|
.ScaleTo(1, initialMovementTime, Easing.OutQuint)
|
||||||
|
.FadeIn(quick_appear, Easing.OutQuint)
|
||||||
|
.Then()
|
||||||
|
.RotateTo(20, EXIT_DELAY * 1.5f)
|
||||||
|
.FadeOut(EXIT_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private MainMenu mainMenu;
|
||||||
|
|
||||||
|
protected void PrepareMenuLoad()
|
||||||
|
{
|
||||||
|
LoadComponentAsync(mainMenu = new MainMenu());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void LoadMenu()
|
||||||
|
{
|
||||||
|
DidLoadMenu = true;
|
||||||
|
this.Push(mainMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -120,7 +120,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
var track = Beatmap.Value.Track;
|
var track = Beatmap.Value.Track;
|
||||||
var metadata = Beatmap.Value.Metadata;
|
var metadata = Beatmap.Value.Metadata;
|
||||||
|
|
||||||
if (last is Intro && track != null)
|
if (last is IntroScreen && track != null)
|
||||||
{
|
{
|
||||||
if (!track.IsRunning)
|
if (!track.IsRunning)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user