2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-06 20:10:01 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
2016-10-06 20:10:01 +08:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
|
using osu.Framework.Audio.Track;
|
2017-04-15 01:42:42 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-02-17 17:59:30 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-05-23 15:26:51 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2017-07-26 12:22:46 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 15:26:51 +08:00
|
|
|
|
using osu.Game.Beatmaps.IO;
|
2017-04-15 01:42:42 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2017-11-01 19:54:58 +08:00
|
|
|
|
using OpenTK;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2016-10-06 20:10:01 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
namespace osu.Game.Screens.Menu
|
2016-10-06 20:10:01 +08:00
|
|
|
|
{
|
2017-02-18 13:16:46 +08:00
|
|
|
|
public class Intro : OsuScreen
|
2016-10-06 20:10:01 +08:00
|
|
|
|
{
|
2017-10-09 05:30:52 +08:00
|
|
|
|
private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83";
|
2017-05-23 15:26:51 +08:00
|
|
|
|
|
2016-10-07 18:12:36 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether we have loaded the menu previously.
|
|
|
|
|
/// </summary>
|
2017-11-21 10:49:42 +08:00
|
|
|
|
public bool DidLoadMenu;
|
2016-10-07 17:58:20 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private MainMenu mainMenu;
|
2017-02-18 16:35:04 +08:00
|
|
|
|
private SampleChannel welcome;
|
|
|
|
|
private SampleChannel seeya;
|
2016-11-01 22:24:14 +08:00
|
|
|
|
|
2017-11-01 15:57:59 +08:00
|
|
|
|
public override bool HasLocalCursorDisplayed => true;
|
2017-03-16 22:58:36 +08:00
|
|
|
|
|
2017-12-25 17:52:09 +08:00
|
|
|
|
public override bool ShowOverlaysOnEnter => false;
|
2016-11-09 14:22:54 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
2016-10-06 22:32:35 +08:00
|
|
|
|
|
2017-04-15 01:42:42 +08:00
|
|
|
|
private Bindable<bool> menuVoice;
|
2017-04-15 02:10:59 +08:00
|
|
|
|
private Bindable<bool> menuMusic;
|
2017-05-23 15:26:51 +08:00
|
|
|
|
private Track track;
|
2017-04-15 01:42:42 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-07-27 15:56:41 +08:00
|
|
|
|
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
|
2016-11-01 22:24:14 +08:00
|
|
|
|
{
|
2017-05-15 09:56:27 +08:00
|
|
|
|
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
|
|
|
|
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
2017-04-15 01:42:42 +08:00
|
|
|
|
|
2017-05-23 15:26:51 +08:00
|
|
|
|
BeatmapSetInfo setInfo = null;
|
|
|
|
|
|
|
|
|
|
if (!menuMusic)
|
|
|
|
|
{
|
2017-10-11 03:29:16 +08:00
|
|
|
|
var sets = beatmaps.GetAllUsableBeatmapSets();
|
2017-07-27 14:34:13 +08:00
|
|
|
|
if (sets.Count > 0)
|
|
|
|
|
setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID);
|
2017-05-23 15:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (setInfo == null)
|
|
|
|
|
{
|
2017-07-26 19:22:02 +08:00
|
|
|
|
setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash);
|
2017-05-23 15:26:51 +08:00
|
|
|
|
|
|
|
|
|
if (setInfo == null)
|
|
|
|
|
{
|
|
|
|
|
// we need to import the default menu background beatmap
|
2017-07-26 19:22:02 +08:00
|
|
|
|
setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz")));
|
|
|
|
|
setInfo.Protected = true;
|
2017-05-23 15:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
2017-05-23 15:26:51 +08:00
|
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
|
track = Beatmap.Value.Track;
|
2017-04-15 01:42:42 +08:00
|
|
|
|
|
2017-04-15 02:10:59 +08:00
|
|
|
|
welcome = audio.Sample.Get(@"welcome");
|
2016-12-05 18:34:52 +08:00
|
|
|
|
seeya = audio.Sample.Get(@"seeya");
|
2017-11-05 00:42:28 +08:00
|
|
|
|
|
|
|
|
|
if (setInfo.Protected)
|
|
|
|
|
beatmaps.Delete(setInfo);
|
2016-11-01 22:24:14 +08:00
|
|
|
|
}
|
2016-10-06 20:10:01 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnEntering(Screen last)
|
2016-11-01 22:24:14 +08:00
|
|
|
|
{
|
2017-01-20 16:28:03 +08:00
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
2017-04-25 11:48:25 +08:00
|
|
|
|
if (menuVoice)
|
2017-04-15 01:42:42 +08:00
|
|
|
|
welcome.Play();
|
2017-04-15 06:17:51 +08:00
|
|
|
|
|
2017-02-26 20:15:33 +08:00
|
|
|
|
Scheduler.AddDelayed(delegate
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2017-07-20 07:57:46 +08:00
|
|
|
|
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu.
|
|
|
|
|
if (menuMusic)
|
|
|
|
|
track.Start();
|
2017-02-26 20:15:33 +08:00
|
|
|
|
|
2017-04-02 14:56:12 +08:00
|
|
|
|
LoadComponentAsync(mainMenu = new MainMenu());
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
2016-11-02 00:02:48 +08:00
|
|
|
|
Scheduler.AddDelayed(delegate
|
|
|
|
|
{
|
2017-02-26 20:15:33 +08:00
|
|
|
|
DidLoadMenu = true;
|
|
|
|
|
Push(mainMenu);
|
2017-11-01 19:54:58 +08:00
|
|
|
|
}, delay_step_one);
|
|
|
|
|
}, delay_step_two);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const double delay_step_one = 2300;
|
|
|
|
|
private const double delay_step_two = 600;
|
|
|
|
|
|
|
|
|
|
public const int EXIT_DELAY = 3000;
|
|
|
|
|
|
2017-11-09 16:38:20 +08:00
|
|
|
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
2017-11-01 19:54:58 +08:00
|
|
|
|
{
|
2017-11-09 16:38:20 +08:00
|
|
|
|
base.LogoArriving(logo, resuming);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
|
logo.RelativePositionAxes = Axes.Both;
|
2017-11-08 13:31:11 +08:00
|
|
|
|
logo.Colour = Color4.White;
|
2017-11-01 19:54:58 +08:00
|
|
|
|
logo.Ripple = false;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
2017-11-02 20:52:23 +08:00
|
|
|
|
const int quick_appear = 350;
|
2016-11-01 22:24:14 +08:00
|
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
|
int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0;
|
|
|
|
|
|
|
|
|
|
logo.MoveTo(new Vector2(0.5f), initialMovementTime, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
if (!resuming)
|
|
|
|
|
{
|
2017-11-08 13:31:11 +08:00
|
|
|
|
logo.ScaleTo(1);
|
|
|
|
|
logo.FadeIn();
|
|
|
|
|
logo.PlayIntro();
|
2017-11-01 19:54:58 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-09 16:52:38 +08:00
|
|
|
|
logo.Triangles = false;
|
|
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
|
logo
|
|
|
|
|
.ScaleTo(1, initialMovementTime, Easing.OutQuint)
|
|
|
|
|
.FadeIn(quick_appear, Easing.OutQuint)
|
|
|
|
|
.Then()
|
|
|
|
|
.RotateTo(20, EXIT_DELAY * 1.5f)
|
|
|
|
|
.FadeOut(EXIT_DELAY);
|
|
|
|
|
}
|
2016-10-07 16:07:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnSuspending(Screen next)
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
|
|
|
|
Content.FadeOut(300);
|
|
|
|
|
base.OnSuspending(next);
|
2016-10-06 20:10:01 +08:00
|
|
|
|
}
|
2016-10-07 17:34:37 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override bool OnExiting(Screen next)
|
2016-10-07 17:58:20 +08:00
|
|
|
|
{
|
|
|
|
|
//cancel exiting if we haven't loaded the menu yet.
|
2016-10-07 18:12:36 +08:00
|
|
|
|
return !DidLoadMenu;
|
2016-10-07 17:58:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-07 17:34:37 +08:00
|
|
|
|
{
|
2017-02-17 14:33:08 +08:00
|
|
|
|
if (!(last is MainMenu))
|
|
|
|
|
Content.FadeIn(300);
|
|
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
|
double fadeOutTime = EXIT_DELAY;
|
2016-12-05 18:34:52 +08:00
|
|
|
|
//we also handle the exit transition.
|
2017-04-15 01:42:42 +08:00
|
|
|
|
if (menuVoice)
|
|
|
|
|
seeya.Play();
|
|
|
|
|
else
|
|
|
|
|
fadeOutTime = 500;
|
2016-12-05 18:34:52 +08:00
|
|
|
|
|
2017-04-15 01:42:42 +08:00
|
|
|
|
Scheduler.AddDelayed(Exit, fadeOutTime);
|
2016-12-05 18:34:52 +08:00
|
|
|
|
|
|
|
|
|
//don't want to fade out completely else we will stop running updates and shit will hit the fan.
|
2017-04-15 01:42:42 +08:00
|
|
|
|
Game.FadeTo(0.01f, fadeOutTime);
|
2016-10-07 17:34:37 +08:00
|
|
|
|
|
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
}
|
2016-10-06 20:10:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|