1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 03:07:51 +08:00
osu-lazer/osu.Game/GameModes/Menu/MainMenu.cs
2016-11-01 23:24:14 +09:00

99 lines
3.1 KiB
C#

//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
using osu.Game.GameModes.Charts;
using osu.Game.GameModes.Direct;
using osu.Game.GameModes.Edit;
using osu.Game.GameModes.Multiplayer;
using osu.Game.GameModes.Play;
using osu.Game.Graphics.Containers;
using OpenTK;
using osu.Framework;
using osu.Game.Overlays;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Menu
{
public class MainMenu : OsuGameMode
{
private ButtonSystem buttons;
public override string Name => @"Main Menu";
private BackgroundMode background;
protected override BackgroundMode CreateBackground() => background;
public MainMenu()
{
background = new BackgroundModeDefault();
Children = new Drawable[]
{
new ParallaxContainer
{
ParallaxAmount = 0.01f,
Children = new Drawable[]
{
buttons = new ButtonSystem()
{
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new EditSongSelect()); },
OnSolo = delegate { Push(new PlaySongSelect()); },
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
}
}
}
};
}
protected override void Load(BaseGame game)
{
base.Load(game);
background.Preload(game);
OsuGame osu = (OsuGame)game;
buttons.OnSettings = osu.Options.ToggleVisibility;
}
protected override void LoadComplete()
{
base.LoadComplete();
buttons.FadeInFromZero(500);
}
protected override void OnSuspending(GameMode next)
{
base.OnSuspending(next);
const float length = 400;
buttons.State = MenuState.EnteringMode;
Content.FadeOut(length, EasingTypes.InSine);
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
}
protected override void OnResuming(GameMode last)
{
base.OnResuming(last);
const float length = 300;
buttons.State = MenuState.TopLevel;
Content.FadeIn(length, EasingTypes.OutQuint);
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
}
}
}