mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Get MenuMusic and MenuVoice woking
This commit is contained in:
@ -1,12 +1,18 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using OpenTK.Graphics;
|
||||
@ -56,30 +62,60 @@ namespace osu.Game.Screens.Menu
|
||||
};
|
||||
}
|
||||
|
||||
private Bindable<bool> menuVoice;
|
||||
private Bindable<bool> osuBGM;
|
||||
private BeatmapDatabase beatmaps;
|
||||
private TrackManager trackManager;
|
||||
private BeatmapInfo beatmap;
|
||||
private WorkingBeatmap song;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
private void load(OsuGameBase game, AudioManager audio, OsuConfigManager config, BeatmapDatabase beatmaps)
|
||||
{
|
||||
menuVoice = config.GetBindable<bool>(OsuConfig.MenuVoice);
|
||||
osuBGM = config.GetBindable<bool>(OsuConfig.MenuMusic);
|
||||
|
||||
if (osuBGM)
|
||||
{
|
||||
bgm = audio.Track.Get(@"circles");
|
||||
bgm.Looping = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.beatmaps = beatmaps;
|
||||
trackManager = game.Audio.Track;
|
||||
beatmap = beatmaps.GetWithChildren<BeatmapSetInfo>(RNG.Next(0, beatmaps.Query<BeatmapSetInfo>().Count() - 1)).Beatmaps[0];
|
||||
song = beatmaps.GetWorkingBeatmap(beatmap, null);
|
||||
}
|
||||
|
||||
welcome = audio.Sample.Get(@"welcome");
|
||||
|
||||
seeya = audio.Sample.Get(@"seeya");
|
||||
|
||||
bgm = audio.Track.Get(@"circles");
|
||||
bgm.Looping = true;
|
||||
}
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
welcome.Play();
|
||||
|
||||
if(menuVoice)
|
||||
welcome.Play();
|
||||
Scheduler.AddDelayed(delegate
|
||||
{
|
||||
bgm.Start();
|
||||
if(osuBGM)
|
||||
bgm.Start();
|
||||
|
||||
LoadComponentAsync(mainMenu = new MainMenu());
|
||||
|
||||
Scheduler.AddDelayed(delegate
|
||||
{
|
||||
if (!osuBGM)
|
||||
Task.Run(() =>
|
||||
{
|
||||
trackManager.SetExclusive(song.Track);
|
||||
song.Track.Seek(beatmap.Metadata.PreviewTime);
|
||||
song.Track.Start();
|
||||
});
|
||||
DidLoadMenu = true;
|
||||
Push(mainMenu);
|
||||
}, 2300);
|
||||
@ -109,15 +145,17 @@ namespace osu.Game.Screens.Menu
|
||||
if (!(last is MainMenu))
|
||||
Content.FadeIn(300);
|
||||
|
||||
double fadeOutTime = 2000;
|
||||
//we also handle the exit transition.
|
||||
seeya.Play();
|
||||
if (menuVoice)
|
||||
seeya.Play();
|
||||
else
|
||||
fadeOutTime = 500;
|
||||
|
||||
const double fade_out_time = 2000;
|
||||
|
||||
Scheduler.AddDelayed(Exit, fade_out_time);
|
||||
Scheduler.AddDelayed(Exit, fadeOutTime);
|
||||
|
||||
//don't want to fade out completely else we will stop running updates and shit will hit the fan.
|
||||
Game.FadeTo(0.01f, fade_out_time);
|
||||
Game.FadeTo(0.01f, fadeOutTime);
|
||||
|
||||
base.OnResuming(last);
|
||||
}
|
||||
|
Reference in New Issue
Block a user