2017-02-07 04:59:30 +00:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-26 03:28:23 +00:00
|
|
|
|
2017-05-06 07:37:53 +00:00
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Input;
|
2016-11-14 08:23:33 +00:00
|
|
|
using osu.Framework.Allocation;
|
2016-09-17 20:33:46 +00:00
|
|
|
using osu.Framework.Graphics;
|
2017-05-06 07:37:53 +00:00
|
|
|
using osu.Framework.Input;
|
2017-03-28 12:26:20 +00:00
|
|
|
using osu.Framework.Screens;
|
2016-09-30 04:30:55 +00:00
|
|
|
using osu.Game.Graphics.Containers;
|
2016-11-14 08:23:33 +00:00
|
|
|
using osu.Game.Screens.Backgrounds;
|
|
|
|
using osu.Game.Screens.Charts;
|
|
|
|
using osu.Game.Screens.Direct;
|
2017-03-14 14:18:40 +00:00
|
|
|
using osu.Game.Screens.Edit;
|
2016-11-14 08:23:33 +00:00
|
|
|
using osu.Game.Screens.Multiplayer;
|
2016-11-20 19:34:16 +00:00
|
|
|
using osu.Game.Screens.Select;
|
2017-02-27 14:38:29 +00:00
|
|
|
using osu.Game.Screens.Tournament;
|
2016-08-26 03:28:23 +00:00
|
|
|
|
2016-11-14 08:23:33 +00:00
|
|
|
namespace osu.Game.Screens.Menu
|
2016-08-26 03:28:23 +00:00
|
|
|
{
|
2017-02-17 09:59:30 +00:00
|
|
|
public class MainMenu : OsuScreen
|
2016-08-26 03:28:23 +00:00
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
private readonly ButtonSystem buttons;
|
2016-08-26 03:28:23 +00:00
|
|
|
|
2017-02-08 10:46:05 +00:00
|
|
|
internal override bool ShowOverlays => buttons.State != MenuState.Initial;
|
2016-11-09 06:22:54 +00:00
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
private readonly BackgroundScreen background;
|
2017-03-17 11:09:33 +00:00
|
|
|
private Screen songSelect;
|
2016-10-05 07:35:10 +00:00
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
protected override BackgroundScreen CreateBackground() => background;
|
2016-09-17 20:33:46 +00:00
|
|
|
|
2016-11-01 14:24:14 +00:00
|
|
|
public MainMenu()
|
|
|
|
{
|
2017-02-17 09:59:30 +00:00
|
|
|
background = new BackgroundScreenDefault();
|
2016-10-01 06:02:38 +00:00
|
|
|
|
2016-09-30 04:31:05 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2016-10-01 08:02:20 +00:00
|
|
|
new ParallaxContainer
|
2016-09-29 11:13:58 +00:00
|
|
|
{
|
2016-10-01 08:02:20 +00:00
|
|
|
ParallaxAmount = 0.01f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2017-02-08 10:46:05 +00:00
|
|
|
buttons = new ButtonSystem
|
2016-10-01 08:02:20 +00:00
|
|
|
{
|
|
|
|
OnChart = delegate { Push(new ChartListing()); },
|
|
|
|
OnDirect = delegate { Push(new OnlineListing()); },
|
2017-03-14 14:18:40 +00:00
|
|
|
OnEdit = delegate { Push(new Editor()); },
|
2017-03-17 11:09:33 +00:00
|
|
|
OnSolo = delegate { Push(consumeSongSelect()); },
|
2016-10-01 08:02:20 +00:00
|
|
|
OnMulti = delegate { Push(new Lobby()); },
|
2016-12-05 10:34:52 +00:00
|
|
|
OnExit = delegate { Exit(); },
|
2017-05-20 16:02:42 +00:00
|
|
|
},
|
|
|
|
new MenuSideFlashes(),
|
2016-10-01 08:02:20 +00:00
|
|
|
}
|
2016-09-29 11:13:58 +00:00
|
|
|
}
|
2016-09-30 04:31:05 +00:00
|
|
|
};
|
2016-11-01 14:24:14 +00:00
|
|
|
}
|
2016-10-06 12:10:01 +00:00
|
|
|
|
2016-11-12 10:44:16 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2017-05-23 07:26:51 +00:00
|
|
|
private void load(OsuGame game)
|
2016-11-01 14:24:14 +00:00
|
|
|
{
|
2017-04-02 06:56:12 +00:00
|
|
|
LoadComponentAsync(background);
|
2016-11-01 14:24:14 +00:00
|
|
|
|
2017-05-15 01:55:29 +00:00
|
|
|
buttons.OnSettings = game.ToggleSettings;
|
2017-05-17 08:58:34 +00:00
|
|
|
buttons.OnDirect = game.ToggleDirect;
|
2017-03-17 11:09:33 +00:00
|
|
|
|
|
|
|
preloadSongSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void preloadSongSelect()
|
|
|
|
{
|
|
|
|
if (songSelect == null)
|
2017-04-02 06:56:12 +00:00
|
|
|
LoadComponentAsync(songSelect = new PlaySongSelect());
|
2017-03-17 11:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Screen consumeSongSelect()
|
|
|
|
{
|
|
|
|
var s = songSelect;
|
|
|
|
songSelect = null;
|
|
|
|
return s;
|
2016-11-01 14:24:14 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
protected override void OnEntering(Screen last)
|
2016-11-01 14:24:14 +00:00
|
|
|
{
|
2017-02-07 12:37:34 +00:00
|
|
|
base.OnEntering(last);
|
2016-11-01 14:24:14 +00:00
|
|
|
buttons.FadeInFromZero(500);
|
2017-05-06 06:03:08 +00:00
|
|
|
if (last is Intro && Beatmap != null)
|
2017-04-25 04:33:34 +00:00
|
|
|
{
|
2017-05-23 07:26:51 +00:00
|
|
|
if (!Beatmap.Track.IsRunning)
|
2017-04-23 05:36:23 +00:00
|
|
|
{
|
2017-05-06 06:03:08 +00:00
|
|
|
Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime);
|
|
|
|
if (Beatmap.Metadata.PreviewTime == -1)
|
|
|
|
Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f);
|
|
|
|
Beatmap.Track.Start();
|
2017-05-23 07:26:51 +00:00
|
|
|
}
|
2017-04-25 04:33:34 +00:00
|
|
|
}
|
2016-09-30 04:31:05 +00:00
|
|
|
}
|
2016-10-01 08:01:29 +00:00
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
protected override void OnSuspending(Screen next)
|
2016-10-01 08:01:29 +00:00
|
|
|
{
|
2016-10-05 07:35:10 +00:00
|
|
|
base.OnSuspending(next);
|
|
|
|
|
2016-10-01 08:01:29 +00:00
|
|
|
const float length = 400;
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
buttons.State = MenuState.EnteringMode;
|
2016-10-01 08:01:29 +00:00
|
|
|
|
|
|
|
Content.FadeOut(length, EasingTypes.InSine);
|
|
|
|
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
|
|
|
|
}
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-01 08:01:29 +00:00
|
|
|
{
|
2016-10-05 07:35:10 +00:00
|
|
|
base.OnResuming(last);
|
|
|
|
|
2017-03-17 11:09:33 +00:00
|
|
|
//we may have consumed our preloaded instance, so let's make another.
|
|
|
|
preloadSongSelect();
|
|
|
|
|
2016-10-01 08:01:29 +00:00
|
|
|
const float length = 300;
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
buttons.State = MenuState.TopLevel;
|
2016-10-01 08:01:29 +00:00
|
|
|
|
|
|
|
Content.FadeIn(length, EasingTypes.OutQuint);
|
|
|
|
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
|
|
|
|
}
|
2016-12-05 10:34:52 +00:00
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
protected override bool OnExiting(Screen next)
|
2016-12-05 10:34:52 +00:00
|
|
|
{
|
|
|
|
buttons.State = MenuState.Exit;
|
2017-02-17 06:33:08 +00:00
|
|
|
Content.FadeOut(3000);
|
2016-12-05 10:34:52 +00:00
|
|
|
return base.OnExiting(next);
|
|
|
|
}
|
2017-03-03 03:42:03 +00: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 11:21:11 +00:00
|
|
|
Push(new Drawings());
|
2017-03-03 03:42:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
}
|
2016-08-26 03:28:23 +00:00
|
|
|
}
|
|
|
|
}
|