1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 21:12:55 +08:00
osu-lazer/osu.Game/GameModes/Menu/MainMenu.cs

87 lines
2.9 KiB
C#
Raw Normal View History

2016-08-26 11:28:23 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
2016-08-26 16:27:49 +08:00
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-08-26 11:28:23 +08:00
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
2016-09-29 19:13:58 +08:00
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
2016-10-01 16:02:20 +08:00
using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
2016-09-29 19:13:58 +08:00
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;
2016-10-01 16:02:20 +08:00
using OpenTK;
2016-08-26 11:28:23 +08:00
namespace osu.Game.GameModes.Menu
{
2016-10-05 15:35:10 +08:00
public class MainMenu : OsuGameMode
2016-08-26 11:28:23 +08:00
{
2016-10-01 16:02:20 +08:00
private ButtonSystem buttons;
2016-08-26 11:28:23 +08:00
public override string Name => @"Main Menu";
2016-10-05 15:35:10 +08:00
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault();
2016-09-30 12:31:05 +08:00
public override void Load()
{
base.Load();
OsuGame osu = (OsuGame)Game;
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[]
{
buttons = new ButtonSystem()
{
Alpha = 0,
2016-10-01 16:02:20 +08:00
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
2016-10-05 19:03:52 +08:00
OnEdit = delegate { Push(new EditSongSelect()); },
OnSolo = delegate { Push(new PlaySongSelect()); },
2016-10-01 16:02:20 +08:00
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate { Game.Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
2016-10-01 16:02:20 +08:00
OnSettings = delegate {
osu.Options.PoppedOut = !osu.Options.PoppedOut;
2016-10-01 16:02:20 +08:00
},
}
}
2016-09-29 19:13:58 +08:00
}
2016-09-30 12:31:05 +08:00
};
buttons.FadeIn(500);
2016-09-30 12:31:05 +08:00
}
2016-10-05 15:35:10 +08:00
protected override void OnSuspending(GameMode next)
{
2016-10-05 15:35:10 +08:00
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);
}
2016-10-05 15:35:10 +08:00
protected override void OnResuming(GameMode last)
{
2016-10-05 15:35:10 +08:00
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);
}
2016-08-26 11:28:23 +08:00
}
}