osu/osu.Game/GameModes/Menu/MainMenu.cs

87 lines
3.0 KiB
C#
Raw Normal View History

2016-08-26 03:28:23 +00:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
2016-08-26 08:27:49 +00:00
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-08-26 03:28:23 +00:00
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
2016-09-29 11:13:58 +00:00
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
2016-10-01 08:02:20 +00:00
using osu.Framework.Graphics.Transformations;
2016-09-29 11:13:58 +00: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 08:02:20 +00:00
using OpenTK;
2016-08-26 03:28:23 +00:00
namespace osu.Game.GameModes.Menu
{
internal class MainMenu : OsuGameMode
2016-08-26 03:28:23 +00:00
{
2016-10-01 08:02:20 +00:00
private ButtonSystem buttons;
2016-08-26 03:28:23 +00:00
public override string Name => @"Main Menu";
2016-10-01 08:02:20 +00:00
private AudioTrack bgm;
2016-08-26 03:28:23 +00:00
2016-09-30 04:31:05 +00:00
public override void Load()
{
base.Load();
2016-09-30 04:31:05 +00:00
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
2016-09-29 11:13:58 +00:00
welcome.Play();
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[]
{
buttons = new ButtonSystem()
{
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new SongSelectEdit()); },
OnSolo = delegate { Push(new SongSelectPlay()); },
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate {
Game.Scheduler.AddDelayed(delegate {
Game.Host.Exit();
}, ButtonSystem.EXIT_DELAY);
},
OnSettings = delegate {
Game.Options.PoppedOut = !Game.Options.PoppedOut;
},
}
}
2016-09-29 11:13:58 +00:00
}
2016-09-30 04:31:05 +00:00
};
}
protected override double OnSuspending(GameMode next)
{
const float length = 400;
buttons.State = ButtonSystem.MenuState.EnteringMode;
Content.FadeOut(length, EasingTypes.InSine);
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
return base.OnSuspending(next);
}
protected override double OnResuming(GameMode last)
{
const float length = 300;
buttons.State = ButtonSystem.MenuState.TopLevel;
Content.FadeIn(length, EasingTypes.OutQuint);
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
return base.OnResuming(last);
}
2016-08-26 03:28:23 +00:00
}
}