1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 23:02:56 +08:00
osu-lazer/osu.Game/Screens/Menu/IntroCircles.cs

107 lines
3.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.IO.Archives;
namespace osu.Game.Screens.Menu
{
public class IntroCircles : IntroScreen
2018-04-13 17:19:50 +08:00
{
private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83";
private SampleChannel welcome;
2018-04-13 17:19:50 +08:00
private Bindable<bool> menuMusic;
2018-04-13 17:19:50 +08:00
private Track track;
private WorkingBeatmap introBeatmap;
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, ISampleStore samples)
2018-04-13 17:19:50 +08:00
{
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
BeatmapSetInfo setInfo = null;
2019-02-21 17:56:34 +08:00
if (!menuMusic.Value)
2018-04-13 17:19:50 +08:00
{
var sets = beatmaps.GetAllUsableBeatmapSets();
if (sets.Count > 0)
setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID);
}
if (setInfo == null)
{
setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash);
if (setInfo == null)
{
// we need to import the default menu background beatmap
setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz")).Result;
2018-04-13 17:19:50 +08:00
setInfo.Protected = true;
beatmaps.Update(setInfo);
}
}
introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
track = introBeatmap.Track;
2018-04-13 17:19:50 +08:00
if (config.Get<bool>(OsuSetting.MenuVoice))
welcome = samples.Get(@"welcome");
2018-04-13 17:19:50 +08:00
}
private const double delay_step_one = 2300;
private const double delay_step_two = 600;
protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
if (!resuming)
{
2019-02-01 14:42:15 +08:00
Beatmap.Value = introBeatmap;
introBeatmap = null;
welcome?.Play();
Scheduler.AddDelayed(delegate
{
2019-08-23 10:37:01 +08:00
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
2019-02-21 17:56:34 +08:00
if (menuMusic.Value)
{
2019-07-06 18:05:42 +08:00
track.Restart();
track = null;
}
PrepareMenuLoad();
Scheduler.AddDelayed(LoadMenu, delay_step_one);
}, delay_step_two);
2018-04-13 17:19:50 +08:00
logo.ScaleTo(1);
logo.FadeIn();
logo.PlayIntro();
}
}
2019-01-23 19:52:00 +08:00
public override void OnSuspending(IScreen next)
2018-04-13 17:19:50 +08:00
{
track = null;
2019-01-23 19:52:00 +08:00
this.FadeOut(300);
2018-04-13 17:19:50 +08:00
base.OnSuspending(next);
}
}
}