Make sure intro can't be exited unless the main menu has displayed once.

This commit is contained in:
Dean Herbert 2016-10-07 18:58:20 +09:00
parent c5228b63cb
commit 08728b84d1
8 changed files with 26 additions and 15 deletions

View File

@ -9,6 +9,8 @@ using System.Threading.Tasks;
using osu.Framework.GameModes; using osu.Framework.GameModes;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
using OpenTK; using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Input;
namespace osu.Game.GameModes namespace osu.Game.GameModes
{ {
@ -46,12 +48,12 @@ namespace osu.Game.GameModes
base.OnSuspending(next); base.OnSuspending(next);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
Content.FadeOut(transition_length, EasingTypes.OutExpo); Content.FadeOut(transition_length, EasingTypes.OutExpo);
Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo); Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo);
base.OnExiting(next); return base.OnExiting(next);
} }
protected override void OnResuming(GameMode last) protected override void OnResuming(GameMode last)

View File

@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Edit
Background.FadeColour(Color4.DarkGray, 500); Background.FadeColour(Color4.DarkGray, 500);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
base.OnExiting(next);
Background.FadeColour(Color4.White, 500); Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
} }
} }
} }

View File

@ -53,12 +53,12 @@ namespace osu.Game.GameModes
Content.FadeIn(transition_time, EasingTypes.OutExpo); Content.FadeIn(transition_time, EasingTypes.OutExpo);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
base.OnExiting(next);
textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo); textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo); Content.FadeOut(transition_time, EasingTypes.OutExpo);
return base.OnExiting(next);
} }
protected override void OnSuspending(GameMode next) protected override void OnSuspending(GameMode next)

View File

@ -15,6 +15,8 @@ namespace osu.Game.GameModes.Menu
class Intro : OsuGameMode class Intro : OsuGameMode
{ {
private OsuLogo logo; private OsuLogo logo;
private bool didLoadMenu;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public override void Load() public override void Load()
@ -52,6 +54,7 @@ namespace osu.Game.GameModes.Menu
Game.Scheduler.AddDelayed(delegate Game.Scheduler.AddDelayed(delegate
{ {
didLoadMenu = true;
Push(new MainMenu()); Push(new MainMenu());
}, 2900); }, 2900);
@ -67,6 +70,12 @@ namespace osu.Game.GameModes.Menu
base.OnSuspending(next); base.OnSuspending(next);
} }
protected override bool OnExiting(GameMode next)
{
//cancel exiting if we haven't loaded the menu yet.
return !didLoadMenu;
}
protected override void OnResuming(GameMode last) protected override void OnResuming(GameMode last)
{ {
//we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out). //we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out).

View File

@ -28,10 +28,10 @@ namespace osu.Game.GameModes.Multiplayer
Background.FadeColour(Color4.DarkGray, 500); Background.FadeColour(Color4.DarkGray, 500);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
base.OnExiting(next);
Background.FadeColour(Color4.White, 500); Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
} }
} }
} }

View File

@ -55,14 +55,14 @@ namespace osu.Game.GameModes
base.OnEntering(last); base.OnEntering(last);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
OsuGameMode nextOsu = next as OsuGameMode; OsuGameMode nextOsu = next as OsuGameMode;
if (Background != null && !Background.Equals(nextOsu?.Background)) if (Background != null && !Background.Equals(nextOsu?.Background))
Background.Exit(); Background.Exit();
base.OnExiting(next); return base.OnExiting(next);
} }
} }
} }

View File

@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Play
Background.FadeColour(Color4.DarkGray, 500); Background.FadeColour(Color4.DarkGray, 500);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
base.OnExiting(next);
Background.FadeColour(Color4.White, 500); Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
} }
} }
} }

View File

@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Play
Background.FadeColour(Color4.DarkGray, 500); Background.FadeColour(Color4.DarkGray, 500);
} }
protected override void OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
base.OnExiting(next);
Background.FadeColour(Color4.White, 500); Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
} }
} }
} }