Merge pull request #17196 from frenzibyte/skinnable-welcome-intro

Add skinning support for "Welcome" intro sequence
This commit is contained in:
Dean Herbert 2022-03-14 22:54:19 +09:00 committed by GitHub
commit e047413329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 17 deletions

View File

@ -13,14 +13,17 @@ using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Skinning;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using Realms; using Realms;
@ -55,7 +58,8 @@ namespace osu.Game.Screens.Menu
private const int exit_delay = 3000; private const int exit_delay = 3000;
private Sample seeya; private SkinnableSound skinnableSeeya;
private ISample seeya;
protected virtual string SeeyaSampleName => "Intro/seeya"; protected virtual string SeeyaSampleName => "Intro/seeya";
@ -90,14 +94,18 @@ namespace osu.Game.Screens.Menu
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, Framework.Game game, RealmAccess realm) private void load(OsuConfigManager config, Framework.Game game, RealmAccess realm, IAPIProvider api)
{ {
// prevent user from changing beatmap while the intro is still running. // prevent user from changing beatmap while the intro is still running.
beatmap = Beatmap.BeginLease(false); beatmap = Beatmap.BeginLease(false);
MenuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice); MenuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
MenuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic); MenuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
seeya = audio.Samples.Get(SeeyaSampleName);
if (api.LocalUser.Value.IsSupporter)
AddInternal(skinnableSeeya = new SkinnableSound(new SampleInfo(SeeyaSampleName)));
else
seeya = audio.Samples.Get(SeeyaSampleName);
// if the user has requested not to play theme music, we should attempt to find a random beatmap from their collection. // if the user has requested not to play theme music, we should attempt to find a random beatmap from their collection.
if (!MenuMusic.Value) if (!MenuMusic.Value)
@ -201,7 +209,15 @@ namespace osu.Game.Screens.Menu
// we also handle the exit transition. // we also handle the exit transition.
if (MenuVoice.Value) if (MenuVoice.Value)
{ {
seeya.Play(); if (skinnableSeeya != null)
{
// resuming a screen (i.e. calling OnResume) happens before the screen itself becomes alive,
// therefore skinnable samples may not be updated yet with the recently selected skin.
// schedule after children to ensure skinnable samples have processed skin changes before playing.
ScheduleAfterChildren(() => skinnableSeeya.Play());
}
else
seeya.Play();
// if playing the outro voice, we have more time to have fun with the background track. // if playing the outro voice, we have more time to have fun with the background track.
// initially fade to almost silent then ramp out over the remaining time. // initially fade to almost silent then ramp out over the remaining time.

View File

@ -13,7 +13,10 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Online.API;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Skinning;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Menu namespace osu.Game.Screens.Menu
@ -23,8 +26,11 @@ namespace osu.Game.Screens.Menu
protected override string BeatmapHash => "64e00d7022195959bfa3109d09c2e2276c8f12f486b91fcf6175583e973b48f2"; protected override string BeatmapHash => "64e00d7022195959bfa3109d09c2e2276c8f12f486b91fcf6175583e973b48f2";
protected override string BeatmapFile => "welcome.osz"; protected override string BeatmapFile => "welcome.osz";
private const double delay_step_two = 2142; private const double delay_step_two = 2142;
private Sample welcome;
private Sample pianoReverb; private SkinnableSound skinnableWelcome;
private ISample welcome;
private ISample pianoReverb;
protected override string SeeyaSampleName => "Intro/Welcome/seeya"; protected override string SeeyaSampleName => "Intro/Welcome/seeya";
protected override BackgroundScreen CreateBackground() => background = new BackgroundScreenDefault(false) protected override BackgroundScreen CreateBackground() => background = new BackgroundScreenDefault(false)
@ -40,10 +46,15 @@ namespace osu.Game.Screens.Menu
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio, IAPIProvider api)
{ {
if (MenuVoice.Value) if (MenuVoice.Value)
welcome = audio.Samples.Get(@"Intro/Welcome/welcome"); {
if (api.LocalUser.Value.IsSupporter)
AddInternal(skinnableWelcome = new SkinnableSound(new SampleInfo(@"Intro/Welcome/welcome")));
else
welcome = audio.Samples.Get(@"Intro/Welcome/welcome");
}
pianoReverb = audio.Samples.Get(@"Intro/Welcome/welcome_piano"); pianoReverb = audio.Samples.Get(@"Intro/Welcome/welcome_piano");
} }
@ -65,7 +76,10 @@ namespace osu.Game.Screens.Menu
AddInternal(intro); AddInternal(intro);
welcome?.Play(); if (skinnableWelcome != null)
skinnableWelcome.Play();
else
welcome?.Play();
var reverbChannel = pianoReverb?.Play(); var reverbChannel = pianoReverb?.Play();
if (reverbChannel != null) if (reverbChannel != null)
@ -100,13 +114,13 @@ namespace osu.Game.Screens.Menu
private class WelcomeIntroSequence : Container private class WelcomeIntroSequence : Container
{ {
private Sprite welcomeText; private Drawable welcomeText;
private Container scaleContainer; private Container scaleContainer;
public LogoVisualisation LogoVisualisation { get; private set; } public LogoVisualisation LogoVisualisation { get; private set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures, IAPIProvider api)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
@ -135,15 +149,17 @@ namespace osu.Game.Screens.Menu
Size = new Vector2(480), Size = new Vector2(480),
Colour = Color4.Black Colour = Color4.Black
}, },
welcomeText = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = textures.Get(@"Intro/Welcome/welcome_text")
},
} }
}, },
}; };
if (api.LocalUser.Value.IsSupporter)
scaleContainer.Add(welcomeText = new SkinnableSprite(@"Intro/Welcome/welcome_text"));
else
scaleContainer.Add(welcomeText = new Sprite { Texture = textures.Get(@"Intro/Welcome/welcome_text") });
welcomeText.Anchor = Anchor.Centre;
welcomeText.Origin = Anchor.Centre;
} }
protected override void LoadComplete() protected override void LoadComplete()