From 5bf513eba83e16d1e16231cd776bb9bc5727550a Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 17 May 2019 11:24:34 +0900 Subject: [PATCH 01/11] Don't track immediately when entering mode --- .../UserInterface/TestCaseButtonSystem.cs | 21 ++++++++++++++++++- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs index 04aa8bce7e..814558547a 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.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 @@ -42,7 +43,25 @@ namespace osu.Game.Tests.Visual.UserInterface buttons.SetOsuLogo(logo); foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType().Skip(1)) - AddStep($"State to {s}", () => buttons.State = s); + AddStep($"State to {s}", () => + { + buttons.State = s; + + if (buttons.State == ButtonSystemState.EnteringMode) + { + buttons.FadeOut(400, Easing.InSine); + buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); + logo.FadeOut(300, Easing.InSine) + .ScaleTo(0.2f, 300, Easing.InSine); + } + else + { + buttons.FadeIn(400, Easing.OutQuint); + buttons.MoveTo(new Vector2(0), 400, Easing.OutQuint); + logo.FadeColour(Color4.White, 100, Easing.OutQuint); + logo.FadeIn(100, Easing.OutQuint); + } + }); } } } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a098d42c83..9784e8cfcb 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, 400, Easing.InSine); break; } } From b7aed0a0147e8881a05cac4404ea3a22d8addcf0 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 17 May 2019 12:21:34 +0900 Subject: [PATCH 02/11] Interpolate to tracking position on from Initial button state --- osu.Game/Screens/Menu/ButtonSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 9784e8cfcb..900e5ae514 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -332,7 +332,8 @@ namespace osu.Game.Screens.Menu break; case ButtonSystemState.EnteringMode: - logoTrackingContainer.StartTracking(logo, 400, Easing.InSine); + // When coming from the Initial (untracked) state, interpolate to the tracking position over a brief duration instead of tracking immediately. + logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? 400 : 0, Easing.InSine); break; } } From 6391d21af1b5c671fc99d6cfc9d483971840b6f6 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 3 Jul 2019 15:54:21 +0900 Subject: [PATCH 03/11] Remove test used for visualization --- .../UserInterface/TestSceneButtonSystem.cs | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index 6c4d9b20f7..c8cc864089 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -9,7 +9,6 @@ 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 @@ -43,25 +42,7 @@ namespace osu.Game.Tests.Visual.UserInterface buttons.SetOsuLogo(logo); foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType().Skip(1)) - AddStep($"State to {s}", () => - { - buttons.State = s; - - if (buttons.State == ButtonSystemState.EnteringMode) - { - buttons.FadeOut(400, Easing.InSine); - buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); - logo.FadeOut(300, Easing.InSine) - .ScaleTo(0.2f, 300, Easing.InSine); - } - else - { - buttons.FadeIn(400, Easing.OutQuint); - buttons.MoveTo(new Vector2(0), 400, Easing.OutQuint); - logo.FadeColour(Color4.White, 100, Easing.OutQuint); - logo.FadeIn(100, Easing.OutQuint); - } - }); + AddStep($"State to {s}", () => buttons.State = s); } } } From 530675f3642a5da7729e9720276c4a4fe34c159e Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 4 Jul 2019 17:05:29 +0900 Subject: [PATCH 04/11] Add tests as separate steps --- .../UserInterface/TestSceneButtonSystem.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index 6c4d9b20f7..88129308db 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -43,25 +43,25 @@ namespace osu.Game.Tests.Visual.UserInterface buttons.SetOsuLogo(logo); foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType().Skip(1)) - AddStep($"State to {s}", () => - { - buttons.State = s; + AddStep($"State to {s}", () => buttons.State = s); - if (buttons.State == ButtonSystemState.EnteringMode) - { - buttons.FadeOut(400, Easing.InSine); - buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); - logo.FadeOut(300, Easing.InSine) - .ScaleTo(0.2f, 300, Easing.InSine); - } - else - { - buttons.FadeIn(400, Easing.OutQuint); - buttons.MoveTo(new Vector2(0), 400, Easing.OutQuint); - logo.FadeColour(Color4.White, 100, Easing.OutQuint); - logo.FadeIn(100, Easing.OutQuint); - } - }); + AddStep("Exiting menu", () => + { + buttons.State = ButtonSystemState.EnteringMode; + buttons.FadeOut(400, Easing.InSine); + buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); + logo.FadeOut(300, Easing.InSine) + .ScaleTo(0.2f, 300, Easing.InSine); + }); + + AddStep("Entering menu", () => + { + buttons.State = ButtonSystemState.Play; + buttons.FadeIn(400, Easing.OutQuint); + buttons.MoveTo(new Vector2(0), 400, Easing.OutQuint); + logo.FadeColour(Color4.White, 100, Easing.OutQuint); + logo.FadeIn(100, Easing.OutQuint); + }); } } } From 07078b735c7909fd192570d531bfd3a883312afb Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 4 Jul 2019 17:06:28 +0900 Subject: [PATCH 05/11] use new vector2 --- osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index e5a27dac81..88129308db 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 From be4e7d0f5059ea1d5d6d00eea71c368207c6bc36 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 4 Jul 2019 17:08:21 +0900 Subject: [PATCH 06/11] remove comment --- osu.Game/Screens/Menu/ButtonSystem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 040a9f8843..87c009c437 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -332,7 +332,6 @@ namespace osu.Game.Screens.Menu break; case ButtonSystemState.EnteringMode: - // When coming from the Initial (untracked) state, interpolate to the tracking position over a brief duration instead of tracking immediately. logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? 400 : 0, Easing.InSine); break; } From 29bc2a27514a8573f17ebc1a9acf1e2e7813f003 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 Jul 2019 11:29:47 +0900 Subject: [PATCH 07/11] Split out tests --- .../UserInterface/TestSceneButtonSystem.cs | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index 88129308db..3b790d33b6 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -24,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 @@ -37,15 +38,23 @@ 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("Exiting menu", () => + AddStep("Enter mode", () => { buttons.State = ButtonSystemState.EnteringMode; buttons.FadeOut(400, Easing.InSine); @@ -54,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface .ScaleTo(0.2f, 300, Easing.InSine); }); - AddStep("Entering menu", () => + AddStep("Return to menu", () => { buttons.State = ButtonSystemState.Play; buttons.FadeIn(400, Easing.OutQuint); @@ -63,5 +72,18 @@ namespace osu.Game.Tests.Visual.UserInterface logo.FadeIn(100, Easing.OutQuint); }); } + + [Test] + public void TestSmoothExit() + { + AddStep("Enter mode", () => + { + buttons.State = ButtonSystemState.EnteringMode; + buttons.FadeOut(400, Easing.InSine); + buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); + logo.FadeOut(300, Easing.InSine) + .ScaleTo(0.2f, 300, Easing.InSine); + }); + } } } From 79d6670dc581ed27edaef31a0b57466fce707aeb Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 5 Jul 2019 13:08:45 +0900 Subject: [PATCH 08/11] Expose durations from MainMenu and reorder --- .../UserInterface/TestSceneButtonSystem.cs | 8 ++++---- osu.Game/Screens/Menu/MainMenu.cs | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index 88129308db..461db4a30c 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -48,8 +48,8 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("Exiting menu", () => { buttons.State = ButtonSystemState.EnteringMode; - buttons.FadeOut(400, Easing.InSine); - buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); + 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); }); @@ -57,8 +57,8 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("Entering menu", () => { buttons.State = ButtonSystemState.Play; - buttons.FadeIn(400, Easing.OutQuint); - buttons.MoveTo(new Vector2(0), 400, Easing.OutQuint); + 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); }); 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); } From 4eb01b12be4f0cba9ec6a8aa8d17cabafb88284d Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 5 Jul 2019 13:10:59 +0900 Subject: [PATCH 09/11] Convert to method --- .../UserInterface/TestSceneButtonSystem.cs | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs index 9bc8f332f4..f0e1c38525 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneButtonSystem.cs @@ -54,14 +54,7 @@ namespace osu.Game.Tests.Visual.UserInterface foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType().Skip(1)) AddStep($"State to {s}", () => buttons.State = s); - AddStep("Enter mode", () => - { - 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); - }); + AddStep("Enter mode", performEnterMode); AddStep("Return to menu", () => { @@ -76,14 +69,16 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestSmoothExit() { - AddStep("Enter mode", () => - { - buttons.State = ButtonSystemState.EnteringMode; - buttons.FadeOut(400, Easing.InSine); - buttons.MoveTo(new Vector2(-800, 0), 400, Easing.InSine); - logo.FadeOut(300, Easing.InSine) - .ScaleTo(0.2f, 300, Easing.InSine); - }); + 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); } } } From a259247a98fa40d4beb3db268032225533df2e34 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 5 Jul 2019 16:07:17 +0900 Subject: [PATCH 10/11] use const --- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 87c009c437..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, lastState == ButtonSystemState.Initial ? 400 : 0, Easing.InSine); + logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? MainMenu.FADE_OUT_DURATION : 0, Easing.InSine); break; } } From 6fd3ad5c1dac275e6a8112f4ae8af31f64ee99f4 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 6 Jul 2019 12:10:30 +0300 Subject: [PATCH 11/11] Remove unnecessary fading --- .../Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index 1fd3502799..30346a8a96 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -35,15 +35,15 @@ namespace osu.Game.Beatmaps.Drawables protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func createContentFunc, double timeBeforeLoad) => new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay); + protected override double TransformDuration => 400; + protected override Drawable CreateDrawable(BeatmapInfo model) { - Drawable drawable = getDrawableForModel(model); - + var drawable = getDrawableForModel(model); drawable.RelativeSizeAxes = Axes.Both; drawable.Anchor = Anchor.Centre; drawable.Origin = Anchor.Centre; drawable.FillMode = FillMode.Fill; - drawable.OnLoadComplete += d => d.FadeInFromZero(400); return drawable; }