mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move MenuMusic logic to MainMenu
This commit is contained in:
@ -74,17 +74,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
menuVoice = config.GetBindable<bool>(OsuConfig.MenuVoice);
|
menuVoice = config.GetBindable<bool>(OsuConfig.MenuVoice);
|
||||||
menuMusic = config.GetBindable<bool>(OsuConfig.MenuMusic);
|
menuMusic = config.GetBindable<bool>(OsuConfig.MenuMusic);
|
||||||
if (!menuMusic)
|
|
||||||
{
|
|
||||||
trackManager = game.Audio.Track;
|
|
||||||
choosableBeatmapsetAmmout = beatmaps.Query<BeatmapSetInfo>().Count();
|
|
||||||
if (choosableBeatmapsetAmmout > 0)
|
|
||||||
{
|
|
||||||
beatmap = beatmaps.GetWithChildren<BeatmapSetInfo>(RNG.Next(1, choosableBeatmapsetAmmout)).Beatmaps[0];
|
|
||||||
song = beatmaps.GetWorkingBeatmap(beatmap);
|
|
||||||
Beatmap = song;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bgm = audio.Track.Get(@"circles");
|
bgm = audio.Track.Get(@"circles");
|
||||||
bgm.Looping = true;
|
bgm.Looping = true;
|
||||||
@ -105,23 +94,11 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
if(menuMusic)
|
if(menuMusic)
|
||||||
bgm.Start();
|
bgm.Start();
|
||||||
else if (song != null)
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
trackManager.SetExclusive(song.Track);
|
|
||||||
song.Track.Seek(beatmap.Metadata.PreviewTime);
|
|
||||||
if (beatmap.Metadata.PreviewTime == -1)
|
|
||||||
song.Track.Seek(song.Track.Length * .4f);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadComponentAsync(mainMenu = new MainMenu());
|
LoadComponentAsync(mainMenu = new MainMenu());
|
||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
if (!menuMusic && song != null)
|
|
||||||
Task.Run(() => song.Track.Start());
|
|
||||||
DidLoadMenu = true;
|
DidLoadMenu = true;
|
||||||
Push(mainMenu);
|
Push(mainMenu);
|
||||||
}, 2300);
|
}, 2300);
|
||||||
|
@ -2,8 +2,14 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
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 osu.Game.Screens.Charts;
|
using osu.Game.Screens.Charts;
|
||||||
@ -15,6 +21,7 @@ using osu.Game.Screens.Select;
|
|||||||
using osu.Game.Screens.Tournament;
|
using osu.Game.Screens.Tournament;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
@ -54,11 +61,30 @@ namespace osu.Game.Screens.Menu
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bindable<bool> menuMusic;
|
||||||
|
private TrackManager trackManager;
|
||||||
|
private BeatmapInfo beatmap;
|
||||||
|
private WorkingBeatmap song;
|
||||||
|
private int choosableBeatmapsetAmmout;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGame game)
|
private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps)
|
||||||
{
|
{
|
||||||
|
menuMusic = config.GetBindable<bool>(OsuConfig.MenuMusic);
|
||||||
LoadComponentAsync(background);
|
LoadComponentAsync(background);
|
||||||
|
|
||||||
|
if (!menuMusic)
|
||||||
|
{
|
||||||
|
trackManager = game.Audio.Track;
|
||||||
|
choosableBeatmapsetAmmout = beatmaps.Query<BeatmapSetInfo>().Count();
|
||||||
|
if (choosableBeatmapsetAmmout > 0)
|
||||||
|
{
|
||||||
|
beatmap = beatmaps.GetWithChildren<BeatmapSetInfo>(RNG.Next(1, choosableBeatmapsetAmmout)).Beatmaps[0];
|
||||||
|
song = beatmaps.GetWorkingBeatmap(beatmap);
|
||||||
|
Beatmap = song;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buttons.OnSettings = game.ToggleOptions;
|
buttons.OnSettings = game.ToggleOptions;
|
||||||
|
|
||||||
preloadSongSelect();
|
preloadSongSelect();
|
||||||
@ -81,6 +107,15 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
buttons.FadeInFromZero(500);
|
buttons.FadeInFromZero(500);
|
||||||
|
if(last is Intro && song != null)
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
trackManager.SetExclusive(song.Track);
|
||||||
|
song.Track.Seek(beatmap.Metadata.PreviewTime);
|
||||||
|
if (beatmap.Metadata.PreviewTime == -1)
|
||||||
|
song.Track.Seek(song.Track.Length * .4f);
|
||||||
|
song.Track.Start();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSuspending(Screen next)
|
protected override void OnSuspending(Screen next)
|
||||||
|
Reference in New Issue
Block a user