mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Move MenuMusic logic to MainMenu
This commit is contained in:
@ -2,8 +2,14 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Charts;
|
||||
@ -15,6 +21,7 @@ using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Tournament;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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]
|
||||
private void load(OsuGame game)
|
||||
private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps)
|
||||
{
|
||||
menuMusic = config.GetBindable<bool>(OsuConfig.MenuMusic);
|
||||
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;
|
||||
|
||||
preloadSongSelect();
|
||||
@ -81,6 +107,15 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
base.OnEntering(last);
|
||||
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)
|
||||
|
Reference in New Issue
Block a user