mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 16:12:54 +08:00
Add intro and begin to create central logic nest.
This commit is contained in:
parent
9b76a0ffb8
commit
d6042bd689
34
osu.Game/GameModes/Menu/Intro.cs
Normal file
34
osu.Game/GameModes/Menu/Intro.cs
Normal file
@ -0,0 +1,34 @@
|
||||
//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;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.GameModes;
|
||||
|
||||
namespace osu.Game.GameModes.Menu
|
||||
{
|
||||
class Intro : OsuGameMode
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
|
||||
welcome.Play();
|
||||
|
||||
AudioTrack bgm = Game.Audio.Track.Get(@"circles");
|
||||
bgm.Looping = true;
|
||||
|
||||
Game.Scheduler.AddDelayed(delegate
|
||||
{
|
||||
bgm.Start();
|
||||
}, 600);
|
||||
|
||||
Game.Scheduler.AddDelayed(delegate
|
||||
{
|
||||
Push(new MainMenu());
|
||||
}, 2900);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,10 +22,6 @@ namespace osu.Game.GameModes.Menu
|
||||
private ButtonSystem buttons;
|
||||
public override string Name => @"Main Menu";
|
||||
|
||||
protected override bool IsTopLevel => true;
|
||||
|
||||
private AudioTrack bgm;
|
||||
|
||||
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault();
|
||||
|
||||
public override void Load()
|
||||
@ -34,13 +30,6 @@ namespace osu.Game.GameModes.Menu
|
||||
|
||||
OsuGame osu = (OsuGame)Game;
|
||||
|
||||
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
|
||||
welcome.Play();
|
||||
|
||||
bgm = Game.Audio.Track.Get(@"circles");
|
||||
bgm.Looping = true;
|
||||
bgm.Start();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ParallaxContainer
|
||||
@ -50,6 +39,7 @@ namespace osu.Game.GameModes.Menu
|
||||
{
|
||||
buttons = new ButtonSystem()
|
||||
{
|
||||
Alpha = 0,
|
||||
OnChart = delegate { Push(new ChartListing()); },
|
||||
OnDirect = delegate { Push(new OnlineListing()); },
|
||||
OnEdit = delegate { Push(new EditSongSelect()); },
|
||||
@ -68,6 +58,8 @@ namespace osu.Game.GameModes.Menu
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
buttons.FadeIn(500);
|
||||
}
|
||||
|
||||
protected override void OnSuspending(GameMode next)
|
||||
|
@ -1,7 +1,9 @@
|
||||
//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;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.GameModes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.GameModes.Menu;
|
||||
using OpenTK;
|
||||
@ -18,7 +20,8 @@ namespace osu.Game
|
||||
public class OsuGame : OsuGameBase
|
||||
{
|
||||
public Toolbar Toolbar;
|
||||
public MainMenu MainMenu;
|
||||
public MainMenu MainMenu => intro?.ChildGameMode as MainMenu;
|
||||
private Intro intro;
|
||||
|
||||
public Bindable<PlayMode> PlayMode;
|
||||
|
||||
@ -34,18 +37,51 @@ namespace osu.Game
|
||||
base.Load();
|
||||
|
||||
Add(new Drawable[] {
|
||||
MainMenu = new MainMenu(),
|
||||
intro = new Intro(),
|
||||
Toolbar = new Toolbar
|
||||
{
|
||||
OnHome = delegate { MainMenu.MakeCurrent(); },
|
||||
OnHome = delegate { MainMenu?.MakeCurrent(); },
|
||||
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
|
||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||
Alpha = 0.001f //fixes invalidation fuckup
|
||||
},
|
||||
});
|
||||
|
||||
intro.ModePushed += modeAdded;
|
||||
|
||||
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
||||
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
||||
PlayMode.TriggerChange();
|
||||
|
||||
Cursor.Alpha = 0;
|
||||
}
|
||||
|
||||
public Action<GameMode> ModeChanged;
|
||||
|
||||
private void modeChanged(GameMode newMode)
|
||||
{
|
||||
//central game mode change logic.
|
||||
if (newMode is Player)
|
||||
Toolbar.FadeOut(100);
|
||||
else
|
||||
Toolbar.FadeIn(100);
|
||||
|
||||
Cursor.FadeIn(100);
|
||||
|
||||
ModeChanged?.Invoke(newMode);
|
||||
}
|
||||
|
||||
private void modeAdded(GameMode newMode)
|
||||
{
|
||||
newMode.ModePushed += modeAdded;
|
||||
newMode.Exited += modeRemoved;
|
||||
|
||||
modeChanged(newMode);
|
||||
}
|
||||
|
||||
private void modeRemoved(GameMode newMode)
|
||||
{
|
||||
modeChanged(newMode);
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
|
@ -73,6 +73,7 @@
|
||||
<Compile Include="GameModes\Charts\ChartInfo.cs" />
|
||||
<Compile Include="GameModes\Edit\Editor.cs" />
|
||||
<Compile Include="GameModes\GameModeWhiteBox.cs" />
|
||||
<Compile Include="GameModes\Menu\Intro.cs" />
|
||||
<Compile Include="GameModes\Menu\ButtonSystem.cs" />
|
||||
<Compile Include="GameModes\Menu\MainMenu.cs" />
|
||||
<Compile Include="GameModes\Multiplayer\Lobby.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user