1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 15:12:57 +08:00

Get MenuMusic and MenuVoice woking

This commit is contained in:
ColdVolcano 2017-04-14 12:42:42 -05:00
parent d2fd3f1e0c
commit 2a9f4e6950
2 changed files with 52 additions and 13 deletions

View File

@ -35,6 +35,9 @@ namespace osu.Game.Configuration
Set(OsuConfig.MenuParallax, true); Set(OsuConfig.MenuParallax, true);
Set(OsuConfig.MenuVoice, true);
Set(OsuConfig.MenuMusic, true);
Set(OsuConfig.ShowInterface, true); Set(OsuConfig.ShowInterface, true);
Set(OsuConfig.KeyOverlay, false); Set(OsuConfig.KeyOverlay, false);
//todo: implement all settings below this line (remove the Disabled set when doing so). //todo: implement all settings below this line (remove the Disabled set when doing so).
@ -145,8 +148,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.YahooIntegration, false).Disabled = true; Set(OsuConfig.YahooIntegration, false).Disabled = true;
Set(OsuConfig.ForceFrameFlush, false).Disabled = true; Set(OsuConfig.ForceFrameFlush, false).Disabled = true;
Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true; Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true;
Set(OsuConfig.MenuMusic, true).Disabled = true;
Set(OsuConfig.MenuVoice, true).Disabled = true;
Set(OsuConfig.RawInput, false).Disabled = true; Set(OsuConfig.RawInput, false).Disabled = true;
Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true; Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true;
Set(OsuConfig.ShowMenuTips, true).Disabled = true; Set(OsuConfig.ShowMenuTips, true).Disabled = true;

View File

@ -1,12 +1,18 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Threading.Tasks;
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.Configuration;
using osu.Framework.MathUtils;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -56,30 +62,60 @@ namespace osu.Game.Screens.Menu
}; };
} }
[BackgroundDependencyLoader] private Bindable<bool> menuVoice;
private void load(AudioManager audio) private Bindable<bool> osuBGM;
{ private BeatmapDatabase beatmaps;
welcome = audio.Sample.Get(@"welcome"); private TrackManager trackManager;
seeya = audio.Sample.Get(@"seeya"); private BeatmapInfo beatmap;
private WorkingBeatmap song;
[BackgroundDependencyLoader]
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 = audio.Track.Get(@"circles");
bgm.Looping = true; 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");
}
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)
{ {
base.OnEntering(last); base.OnEntering(last);
if(menuVoice)
welcome.Play(); welcome.Play();
Scheduler.AddDelayed(delegate Scheduler.AddDelayed(delegate
{ {
if(osuBGM)
bgm.Start(); bgm.Start();
LoadComponentAsync(mainMenu = new MainMenu()); LoadComponentAsync(mainMenu = new MainMenu());
Scheduler.AddDelayed(delegate Scheduler.AddDelayed(delegate
{ {
if (!osuBGM)
Task.Run(() =>
{
trackManager.SetExclusive(song.Track);
song.Track.Seek(beatmap.Metadata.PreviewTime);
song.Track.Start();
});
DidLoadMenu = true; DidLoadMenu = true;
Push(mainMenu); Push(mainMenu);
}, 2300); }, 2300);
@ -109,15 +145,17 @@ namespace osu.Game.Screens.Menu
if (!(last is MainMenu)) if (!(last is MainMenu))
Content.FadeIn(300); Content.FadeIn(300);
double fadeOutTime = 2000;
//we also handle the exit transition. //we also handle the exit transition.
if (menuVoice)
seeya.Play(); seeya.Play();
else
fadeOutTime = 500;
const double fade_out_time = 2000; Scheduler.AddDelayed(Exit, fadeOutTime);
Scheduler.AddDelayed(Exit, fade_out_time);
//don't want to fade out completely else we will stop running updates and shit will hit the fan. //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); base.OnResuming(last);
} }