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-08-26 11:28:23 +08:00
|
|
|
|
2017-05-06 15:37:53 +08:00
|
|
|
using OpenTK;
|
2017-11-01 19:54:58 +08:00
|
|
|
using OpenTK.Graphics;
|
2017-05-06 15:37:53 +08:00
|
|
|
using OpenTK.Input;
|
2016-11-14 16:23:33 +08:00
|
|
|
using osu.Framework.Allocation;
|
2016-09-18 04:33:46 +08:00
|
|
|
using osu.Framework.Graphics;
|
2017-05-06 15:37:53 +08:00
|
|
|
using osu.Framework.Input;
|
2017-03-28 20:26:20 +08:00
|
|
|
using osu.Framework.Screens;
|
2017-06-26 18:06:08 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2016-09-30 12:30:55 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2016-11-14 16:23:33 +08:00
|
|
|
using osu.Game.Screens.Backgrounds;
|
|
|
|
using osu.Game.Screens.Charts;
|
|
|
|
using osu.Game.Screens.Direct;
|
2017-03-14 22:18:40 +08:00
|
|
|
using osu.Game.Screens.Edit;
|
2016-11-14 16:23:33 +08:00
|
|
|
using osu.Game.Screens.Multiplayer;
|
2016-11-21 03:34:16 +08:00
|
|
|
using osu.Game.Screens.Select;
|
2017-02-27 22:38:29 +08:00
|
|
|
using osu.Game.Screens.Tournament;
|
2016-08-26 11:28:23 +08:00
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
namespace osu.Game.Screens.Menu
|
2016-08-26 11:28:23 +08:00
|
|
|
{
|
2017-02-17 17:59:30 +08:00
|
|
|
public class MainMenu : OsuScreen
|
2016-08-26 11:28:23 +08:00
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
private readonly ButtonSystem buttons;
|
2016-08-26 11:28:23 +08:00
|
|
|
|
2017-12-25 17:52:09 +08:00
|
|
|
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
|
2016-11-09 14:22:54 +08:00
|
|
|
|
2017-06-26 18:06:08 +08:00
|
|
|
private readonly BackgroundScreenDefault background;
|
2017-03-17 19:09:33 +08:00
|
|
|
private Screen songSelect;
|
2016-10-05 15:35:10 +08:00
|
|
|
|
2017-07-19 15:34:18 +08:00
|
|
|
private readonly MenuSideFlashes sideFlashes;
|
2017-07-19 15:13:01 +08:00
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
protected override BackgroundScreen CreateBackground() => background;
|
2016-09-18 04:33:46 +08:00
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
public MainMenu()
|
|
|
|
{
|
2017-02-17 17:59:30 +08:00
|
|
|
background = new BackgroundScreenDefault();
|
2016-10-01 14:02:38 +08:00
|
|
|
|
2016-09-30 12:31:05 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2016-10-01 16:02:20 +08:00
|
|
|
new ParallaxContainer
|
2016-09-29 19:13:58 +08:00
|
|
|
{
|
2016-10-01 16:02:20 +08:00
|
|
|
ParallaxAmount = 0.01f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2017-02-08 18:46:05 +08:00
|
|
|
buttons = new ButtonSystem
|
2016-10-01 16:02:20 +08:00
|
|
|
{
|
|
|
|
OnChart = delegate { Push(new ChartListing()); },
|
|
|
|
OnDirect = delegate { Push(new OnlineListing()); },
|
2017-03-14 22:18:40 +08:00
|
|
|
OnEdit = delegate { Push(new Editor()); },
|
2017-03-17 19:09:33 +08:00
|
|
|
OnSolo = delegate { Push(consumeSongSelect()); },
|
2016-10-01 16:02:20 +08:00
|
|
|
OnMulti = delegate { Push(new Lobby()); },
|
2017-09-14 11:58:32 +08:00
|
|
|
OnExit = Exit,
|
2017-07-19 15:07:11 +08:00
|
|
|
}
|
2016-10-01 16:02:20 +08:00
|
|
|
}
|
2017-07-19 15:07:11 +08:00
|
|
|
},
|
2017-07-19 15:13:01 +08:00
|
|
|
sideFlashes = new MenuSideFlashes(),
|
2016-09-30 12:31:05 +08:00
|
|
|
};
|
2016-11-01 22:24:14 +08:00
|
|
|
}
|
2016-10-06 20:10:01 +08:00
|
|
|
|
2017-11-08 12:52:44 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(OsuGame game = null)
|
2016-11-01 22:24:14 +08:00
|
|
|
{
|
2017-04-02 14:56:12 +08:00
|
|
|
LoadComponentAsync(background);
|
2016-11-01 22:24:14 +08:00
|
|
|
|
2017-11-08 12:52:44 +08:00
|
|
|
if (game != null)
|
|
|
|
{
|
|
|
|
buttons.OnSettings = game.ToggleSettings;
|
|
|
|
buttons.OnDirect = game.ToggleDirect;
|
|
|
|
}
|
2017-03-17 19:09:33 +08:00
|
|
|
|
|
|
|
preloadSongSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void preloadSongSelect()
|
|
|
|
{
|
|
|
|
if (songSelect == null)
|
2017-04-02 14:56:12 +08:00
|
|
|
LoadComponentAsync(songSelect = new PlaySongSelect());
|
2017-03-17 19:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private Screen consumeSongSelect()
|
|
|
|
{
|
|
|
|
var s = songSelect;
|
|
|
|
songSelect = null;
|
|
|
|
return s;
|
2016-11-01 22:24:14 +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-02-07 20:37:34 +08:00
|
|
|
base.OnEntering(last);
|
2016-11-01 22:24:14 +08:00
|
|
|
buttons.FadeInFromZero(500);
|
2017-07-19 12:32:16 +08:00
|
|
|
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
var metadata = Beatmap.Value.Metadata;
|
|
|
|
|
|
|
|
if (last is Intro && track != null)
|
2017-04-25 12:33:34 +08:00
|
|
|
{
|
2017-07-19 12:32:16 +08:00
|
|
|
if (!track.IsRunning)
|
2017-04-23 13:36:23 +08:00
|
|
|
{
|
2017-07-20 23:15:39 +08:00
|
|
|
track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length);
|
2017-07-19 12:32:16 +08:00
|
|
|
track.Start();
|
2017-05-23 15:26:51 +08:00
|
|
|
}
|
2017-04-25 12:33:34 +08:00
|
|
|
}
|
2017-07-19 12:32:16 +08:00
|
|
|
|
|
|
|
Beatmap.ValueChanged += beatmap_ValueChanged;
|
|
|
|
}
|
|
|
|
|
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);
|
2017-11-01 19:54:58 +08:00
|
|
|
|
|
|
|
buttons.SetOsuLogo(logo);
|
|
|
|
|
|
|
|
logo.FadeColour(Color4.White, 100, Easing.OutQuint);
|
|
|
|
logo.FadeIn(100, Easing.OutQuint);
|
|
|
|
|
|
|
|
if (resuming)
|
2017-11-10 00:10:40 +08:00
|
|
|
{
|
2017-11-01 19:54:58 +08:00
|
|
|
buttons.State = MenuState.TopLevel;
|
2017-11-10 00:10:40 +08:00
|
|
|
|
|
|
|
const float length = 300;
|
|
|
|
|
|
|
|
Content.FadeIn(length, Easing.OutQuint);
|
|
|
|
Content.MoveTo(new Vector2(0, 0), length, Easing.OutQuint);
|
|
|
|
|
|
|
|
sideFlashes.Delay(length).FadeIn(64, Easing.InQuint);
|
|
|
|
}
|
2017-11-01 19:54:58 +08:00
|
|
|
}
|
|
|
|
|
2017-11-09 16:38:20 +08:00
|
|
|
protected override void LogoSuspending(OsuLogo logo)
|
2017-11-01 19:54:58 +08:00
|
|
|
{
|
|
|
|
logo.FadeOut(300, Easing.InSine)
|
|
|
|
.ScaleTo(0.2f, 300, Easing.InSine)
|
|
|
|
.OnComplete(l => buttons.SetOsuLogo(null));
|
|
|
|
}
|
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
private void beatmap_ValueChanged(WorkingBeatmap newValue)
|
|
|
|
{
|
|
|
|
if (!IsCurrentScreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
background.Next();
|
2016-09-30 12:31:05 +08:00
|
|
|
}
|
2016-10-01 16:01:29 +08:00
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
protected override void OnSuspending(Screen next)
|
2016-10-01 16:01:29 +08:00
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
base.OnSuspending(next);
|
|
|
|
|
2016-10-01 16:01:29 +08:00
|
|
|
const float length = 400;
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
buttons.State = MenuState.EnteringMode;
|
2016-10-01 16:01:29 +08:00
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
Content.FadeOut(length, Easing.InSine);
|
|
|
|
Content.MoveTo(new Vector2(-800, 0), length, Easing.InSine);
|
2017-07-19 15:13:01 +08:00
|
|
|
|
2017-11-10 00:10:40 +08:00
|
|
|
sideFlashes.FadeOut(64, Easing.OutQuint);
|
2016-10-01 16:01:29 +08:00
|
|
|
}
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-01 16:01:29 +08:00
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
base.OnResuming(last);
|
|
|
|
|
2017-06-26 18:06:08 +08:00
|
|
|
background.Next();
|
|
|
|
|
2017-03-17 19:09:33 +08:00
|
|
|
//we may have consumed our preloaded instance, so let's make another.
|
|
|
|
preloadSongSelect();
|
2016-10-01 16:01:29 +08:00
|
|
|
}
|
2016-12-05 18:34:52 +08:00
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
protected override bool OnExiting(Screen next)
|
2016-12-05 18:34:52 +08:00
|
|
|
{
|
|
|
|
buttons.State = MenuState.Exit;
|
2017-02-17 14:33:08 +08:00
|
|
|
Content.FadeOut(3000);
|
2016-12-05 18:34:52 +08:00
|
|
|
return base.OnExiting(next);
|
|
|
|
}
|
2017-03-03 11:42:03 +08:00
|
|
|
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
{
|
|
|
|
if (!args.Repeat && state.Keyboard.ControlPressed && state.Keyboard.ShiftPressed && args.Key == Key.D)
|
|
|
|
{
|
2017-03-03 19:21:11 +08:00
|
|
|
Push(new Drawings());
|
2017-03-03 11:42:03 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
}
|
2016-08-26 11:28:23 +08:00
|
|
|
}
|
|
|
|
}
|