Add skinning support for "seeya" sample

This commit is contained in:
Salman Ahmed 2022-03-10 05:52:20 +03:00
parent b8ee786d77
commit 2c1589e068

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,14 @@ 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(); // ensure samples have been updated after resume before playing.
ScheduleAfterChildren(() =>
{
if (skinnableSeeya != null)
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.