diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index c8cc864089..f0e1c38525 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Shapes; using osu.Game.Screens.Menu; +using osuTK; using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface @@ -23,11 +24,12 @@ namespace osu.Game.Tests.Visual.UserInterface typeof(Button) }; - public TestSceneButtonSystem() - { - OsuLogo logo; - ButtonSystem buttons; + private OsuLogo logo; + private ButtonSystem buttons; + [SetUp] + public void SetUp() => Schedule(() => + { Children = new Drawable[] { new Box @@ -36,13 +38,47 @@ namespace osu.Game.Tests.Visual.UserInterface RelativeSizeAxes = Axes.Both, }, buttons = new ButtonSystem(), - logo = new OsuLogo { RelativePositionAxes = Axes.Both } + logo = new OsuLogo + { + RelativePositionAxes = Axes.Both, + Position = new Vector2(0.5f) + } }; buttons.SetOsuLogo(logo); + }); + [Test] + public void TestAllStates() + { foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType().Skip(1)) AddStep($"State to {s}", () => buttons.State = s); + + AddStep("Enter mode", performEnterMode); + + AddStep("Return to menu", () => + { + buttons.State = ButtonSystemState.Play; + buttons.FadeIn(MainMenu.FADE_IN_DURATION, Easing.OutQuint); + buttons.MoveTo(new Vector2(0), MainMenu.FADE_IN_DURATION, Easing.OutQuint); + logo.FadeColour(Color4.White, 100, Easing.OutQuint); + logo.FadeIn(100, Easing.OutQuint); + }); + } + + [Test] + public void TestSmoothExit() + { + AddStep("Enter mode", performEnterMode); + } + + private void performEnterMode() + { + buttons.State = ButtonSystemState.EnteringMode; + buttons.FadeOut(MainMenu.FADE_OUT_DURATION, Easing.InSine); + buttons.MoveTo(new Vector2(-800, 0), MainMenu.FADE_OUT_DURATION, Easing.InSine); + logo.FadeOut(300, Easing.InSine) + .ScaleTo(0.2f, 300, Easing.InSine); } } } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 5aa244cc06..1a3e1213b4 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -332,7 +332,7 @@ namespace osu.Game.Screens.Menu break; case ButtonSystemState.EnteringMode: - logoTrackingContainer.StartTracking(logo, 0, Easing.In); + logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? MainMenu.FADE_OUT_DURATION : 0, Easing.InSine); break; } } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 7e6de54d1b..c64bea840f 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -23,7 +23,9 @@ namespace osu.Game.Screens.Menu { public class MainMenu : OsuScreen { - private ButtonSystem buttons; + public const float FADE_IN_DURATION = 300; + + public const float FADE_OUT_DURATION = 400; public override bool HideOverlaysOnEnter => buttons == null || buttons.State == ButtonSystemState.Initial; @@ -35,6 +37,8 @@ namespace osu.Game.Screens.Menu private MenuSideFlashes sideFlashes; + private ButtonSystem buttons; + [Resolved] private GameHost host { get; set; } @@ -141,12 +145,10 @@ namespace osu.Game.Screens.Menu { buttons.State = ButtonSystemState.TopLevel; - const float length = 300; + this.FadeIn(FADE_IN_DURATION, Easing.OutQuint); + this.MoveTo(new Vector2(0, 0), FADE_IN_DURATION, Easing.OutQuint); - this.FadeIn(length, Easing.OutQuint); - this.MoveTo(new Vector2(0, 0), length, Easing.OutQuint); - - sideFlashes.Delay(length).FadeIn(64, Easing.InQuint); + sideFlashes.Delay(FADE_IN_DURATION).FadeIn(64, Easing.InQuint); } } @@ -171,12 +173,10 @@ namespace osu.Game.Screens.Menu { base.OnSuspending(next); - const float length = 400; - buttons.State = ButtonSystemState.EnteringMode; - this.FadeOut(length, Easing.InSine); - this.MoveTo(new Vector2(-800, 0), length, Easing.InSine); + this.FadeOut(FADE_OUT_DURATION, Easing.InSine); + this.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); sideFlashes.FadeOut(64, Easing.OutQuint); }