From 6fa02ce9bbd0ec580cc98f029dab46d9683ef66a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Nov 2017 16:57:59 +0900 Subject: [PATCH 01/10] Use internal less Allows for more dynamic compilation to succeed. No reason for using internal here anyways. --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Loader.cs | 2 +- osu.Game/Screens/Menu/Disclaimer.cs | 6 +++--- osu.Game/Screens/Menu/Intro.cs | 4 ++-- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 8 ++++---- osu.Game/Screens/Play/Player.cs | 6 +++--- osu.Game/Screens/Play/PlayerLoader.cs | 4 ++-- osu.Game/Screens/Ranking/Results.cs | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index c610a24e22..74e55e58ad 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Edit { protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; private readonly Box bottomBackground; private readonly Container screenContainer; diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index af084e740b..295b3603be 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -8,7 +8,7 @@ namespace osu.Game.Screens { internal class Loader : OsuScreen { - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; public Loader() { diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 1ac5823ec4..532ee71b72 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -12,15 +12,15 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Menu { - internal class Disclaimer : OsuScreen + public class Disclaimer : OsuScreen { private Intro intro; private readonly SpriteIcon icon; private Color4 iconColour; - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; - internal override bool HasLocalCursorDisplayed => true; + public override bool HasLocalCursorDisplayed => true; public Disclaimer() { diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index ee84cf2d30..fb06edb0b0 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -33,9 +33,9 @@ namespace osu.Game.Screens.Menu private SampleChannel welcome; private SampleChannel seeya; - internal override bool HasLocalCursorDisplayed => true; + public override bool HasLocalCursorDisplayed => true; - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 1c82d15f50..ff902bf28b 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -23,7 +23,7 @@ namespace osu.Game.Screens.Menu { private readonly ButtonSystem buttons; - internal override bool ShowOverlays => buttons.State != MenuState.Initial; + public override bool ShowOverlays => buttons.State != MenuState.Initial; private readonly BackgroundScreenDefault background; private Screen songSelect; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index ae10d8828b..2a3cba0d49 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens { public abstract class OsuScreen : Screen { - internal BackgroundScreen Background { get; private set; } + public BackgroundScreen Background { get; private set; } /// /// Override to create a BackgroundMode for the current screen. @@ -24,17 +24,17 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; - internal virtual bool ShowOverlays => true; + public virtual bool ShowOverlays => true; protected new OsuGameBase Game => base.Game as OsuGameBase; - internal virtual bool HasLocalCursorDisplayed => false; + public virtual bool HasLocalCursorDisplayed => false; /// /// Whether the beatmap or ruleset should be allowed to be changed by the user or game. /// Used to mark exclusive areas where this is strongly prohibited, like gameplay. /// - internal virtual bool AllowBeatmapRulesetChange => true; + public virtual bool AllowBeatmapRulesetChange => true; protected readonly Bindable Beatmap = new Bindable(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 589f4b663a..3775b9c933 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -34,13 +34,13 @@ namespace osu.Game.Screens.Play { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; - internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor; + public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor; public Action RestartRequested; - internal override bool AllowBeatmapRulesetChange => false; + public override bool AllowBeatmapRulesetChange => false; public bool HasFailed { get; private set; } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index a5248acbe4..71c2ec9a6d 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -24,9 +24,9 @@ namespace osu.Game.Screens.Play private BeatmapMetadataDisplay info; private bool showOverlays = true; - internal override bool ShowOverlays => showOverlays; + public override bool ShowOverlays => showOverlays; - internal override bool AllowBeatmapRulesetChange => false; + public override bool AllowBeatmapRulesetChange => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 60ad484673..8e27cb235c 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -31,7 +31,7 @@ namespace osu.Game.Screens.Ranking private ResultModeTabControl modeChangeButtons; - internal override bool AllowBeatmapRulesetChange => false; + public override bool AllowBeatmapRulesetChange => false; private Container currentPage; diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 3d27552212..e540782fc1 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Tournament { private const string results_filename = "drawings_results.txt"; - internal override bool ShowOverlays => false; + public override bool ShowOverlays => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault(); From ed89f039002d97f34522c868c7fac1b596d5d67b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Nov 2017 17:06:55 +0900 Subject: [PATCH 02/10] Make ParallaxContainer public --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 3e0ed4b059..362563507b 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -11,7 +11,7 @@ using osu.Framework.Configuration; namespace osu.Game.Graphics.Containers { - internal class ParallaxContainer : Container, IRequireHighFrequencyMousePosition + public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition { public float ParallaxAmount = 0.02f; From f0c0e8c34c8039cfa4658ca77d125fb0400d7697 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Nov 2017 17:34:36 +0900 Subject: [PATCH 03/10] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 715a8328a8..3c074a0981 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 715a8328a80af072c31dbc807b3119b3c58df8c6 +Subproject commit 3c074a0981844fbaa9f2ecbf879c542f07e2b94d From beb9d621c428abbc5d2cfef498f49671139ef46e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Nov 2017 23:36:52 +0900 Subject: [PATCH 04/10] Revert incorrectly changed GUID --- osu.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.sln b/osu.sln index e86dd70d0b..356ec4cc7b 100644 --- a/osu.sln +++ b/osu.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game", "osu.Game\osu.Game.csproj", "{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Framework", "osu-framework\osu.Framework\osu.Framework.csproj", "{C76BF5B3-985E-4D39-95FE-97C9C879B83A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework", "osu-framework\osu.Framework\osu.Framework.csproj", "{C76BF5B3-985E-4D39-95FE-97C9C879B83A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Resources", "osu-resources\osu.Game.Resources\osu.Game.Resources.csproj", "{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}" EndProject From b0785b2f09924b5ef6dd23c83b0f675034929cf1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Nov 2017 19:41:11 +0900 Subject: [PATCH 05/10] Fix a possible horrendous endless auth loop --- osu.Game/Online/API/APIAccess.cs | 1 + osu.Game/Online/API/OAuth.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 4e26b1b850..daf56657d2 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -118,6 +118,7 @@ namespace osu.Game.Online.API //NotificationOverlay.ShowMessage("Login failed!"); log.Add(@"Login failed!"); Password = null; + authentication.Clear(); continue; } diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 2e00fe6f1b..ca38f72904 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -27,6 +27,9 @@ namespace osu.Game.Online.API internal bool AuthenticateWithLogin(string username, string password) { + if (string.IsNullOrEmpty(username)) return false; + if (string.IsNullOrEmpty(password)) return false; + using (var req = new AccessTokenRequestPassword(username, password) { Url = $@"{endpoint}/oauth/token", From b8b05fe8d277fafe6da7c0f5af55105553846716 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Nov 2017 20:54:58 +0900 Subject: [PATCH 06/10] Make the osu! logo shared game-wide There should only ever be one osu! logo. It is now passed around between screens in a superfluous manner. --- osu.Game/Screens/Loader.cs | 14 ++++ osu.Game/Screens/Menu/ButtonSystem.cs | 116 ++++++++++++++++---------- osu.Game/Screens/Menu/Intro.cs | 75 ++++++++++------- osu.Game/Screens/Menu/MainMenu.cs | 26 +++++- osu.Game/Screens/Menu/OsuLogo.cs | 42 ++++++++-- osu.Game/Screens/OsuScreen.cs | 47 +++++++++++ osu.Game/Screens/Play/PlayerLoader.cs | 27 +++--- osu.Game/Screens/Select/Footer.cs | 13 --- osu.Game/Screens/Select/SongSelect.cs | 38 ++++++++- 9 files changed, 289 insertions(+), 109 deletions(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 295b3603be..6de53aeeb0 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -2,7 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Graphics; using osu.Game.Screens.Menu; +using OpenTK; namespace osu.Game.Screens { @@ -15,6 +17,18 @@ namespace osu.Game.Screens ValidForResume = false; } + protected override void LogoSetup(OsuLogo logo, bool resuming) + { + base.LogoSetup(logo, resuming); + + logo.RelativePositionAxes = Axes.Both; + logo.Triangles = false; + logo.Position = new Vector2(0.9f); + logo.Scale = new Vector2(0.2f); + + logo.FadeInFromZero(5000, Easing.OutQuint); + } + [BackgroundDependencyLoader] private void load(OsuGame game) { diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index e4dbe00a80..9cd92f054f 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -39,12 +39,25 @@ namespace osu.Game.Screens.Menu //todo: make these non-internal somehow. internal const float BUTTON_AREA_HEIGHT = 100; + internal const float BUTTON_WIDTH = 140f; internal const float WEDGE_WIDTH = 20; - public const int EXIT_DELAY = 3000; + private OsuLogo logo; + + public void SetOsuLogo(OsuLogo logo) + { + this.logo = logo; + + if (this.logo != null) + { + this.logo.Action = onOsuLogo; + + // osuLogo.SizeForFlow relies on loading to be complete. + buttonFlow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0); + } + } - private readonly OsuLogo osuLogo; private readonly Drawable iconFacade; private readonly Container buttonArea; private readonly Box buttonAreaBackground; @@ -99,12 +112,6 @@ namespace osu.Game.Screens.Menu } } }, - osuLogo = new OsuLogo - { - Action = onOsuLogo, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - } }; buttonsPlay.Add(new Button(@"solo", @"select-6", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); @@ -127,14 +134,6 @@ namespace osu.Game.Screens.Menu sampleBack = audio.Sample.Get(@"Menu/select-4"); } - protected override void LoadComplete() - { - base.LoadComplete(); - - // osuLogo.SizeForFlow relies on loading to be complete. - buttonFlow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + osuLogo.SizeForFlow / 4), 0); - } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false; @@ -142,7 +141,7 @@ namespace osu.Game.Screens.Menu switch (args.Key) { case Key.Space: - osuLogo.TriggerOnClick(state); + logo.TriggerOnClick(state); return true; case Key.Escape: switch (State) @@ -215,24 +214,31 @@ namespace osu.Game.Screens.Menu backButton.ContractStyle = 0; settingsButton.ContractStyle = 0; - bool fromInitial = lastState == MenuState.Initial; - if (state == MenuState.TopLevel) buttonArea.FinishTransforms(true); - using (buttonArea.BeginDelayedSequence(fromInitial ? 150 : 0, true)) + using (buttonArea.BeginDelayedSequence(lastState == MenuState.Initial ? 150 : 0, true)) { switch (state) { case MenuState.Exit: case MenuState.Initial: + trackingPosition = false; + buttonAreaBackground.ScaleTo(Vector2.One, 500, Easing.Out); buttonArea.FadeOut(300); - osuLogo.Delay(150) - .Schedule(() => toolbar?.Hide()) - .ScaleTo(1, 800, Easing.OutExpo) - .MoveTo(Vector2.Zero, 800, Easing.OutExpo); + logo?.Delay(150) + .Schedule(() => + { + toolbar?.Hide(); + + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; + + logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); + logo.ScaleTo(1, 800, Easing.OutExpo); + }); foreach (Button b in buttonsTopLevel) b.State = ButtonState.Contracted; @@ -240,27 +246,40 @@ namespace osu.Game.Screens.Menu foreach (Button b in buttonsPlay) b.State = ButtonState.Contracted; - if (state == MenuState.Exit) - { - osuLogo.RotateTo(20, EXIT_DELAY * 1.5f); - osuLogo.FadeOut(EXIT_DELAY); - } - else if (lastState == MenuState.TopLevel) + if (state != MenuState.Exit && lastState == MenuState.TopLevel) sampleBack?.Play(); break; case MenuState.TopLevel: buttonAreaBackground.ScaleTo(Vector2.One, 200, Easing.Out); - var sequence = osuLogo - .ScaleTo(0.5f, 200, Easing.In) - .MoveTo(buttonFlow.DrawPosition, 200, Easing.In); + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.None; - if (fromInitial && osuLogo.Scale.X > 0.5f) - sequence.OnComplete(o => - { - o.Impact(); - toolbar?.Show(); - }); + trackingPosition = true; + + switch (lastState) + { + case MenuState.Initial: + logo.ScaleTo(0.5f, 200, Easing.In); + + trackingPosition = false; + logo + .MoveTo(iconTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In) + .OnComplete(o => + { + trackingPosition = true; + + if (logo.Scale.X > 0.5f) + { + o.Impact(); + toolbar?.Show(); + } + }); + break; + default: + logo.ScaleTo(0.5f, 200, Easing.OutQuint); + break; + } buttonArea.FadeIn(300); @@ -280,6 +299,8 @@ namespace osu.Game.Screens.Menu case MenuState.EnteringMode: buttonAreaBackground.ScaleTo(new Vector2(2, 0), 300, Easing.InSine); + trackingPosition = true; + buttonsTopLevel.ForEach(b => b.ContractStyle = 1); buttonsPlay.ForEach(b => b.ContractStyle = 1); backButton.ContractStyle = 1; @@ -301,15 +322,26 @@ namespace osu.Game.Screens.Menu } } + private Vector2 iconTrackingPosition => logo.Parent.ToLocalSpace(iconFacade.ScreenSpaceDrawQuad.Centre); + + private bool trackingPosition; + + public void SetLogoTracking(bool value) => trackingPosition = value; + protected override void Update() { //if (OsuGame.IdleTime > 6000 && State != MenuState.Exit) // State = MenuState.Initial; - osuLogo.Interactive = Alpha > 0.2f; - - iconFacade.Width = osuLogo.SizeForFlow * 0.5f; base.Update(); + + if (logo != null) + { + if (trackingPosition) + logo.Position = iconTrackingPosition; + + iconFacade.Width = logo.SizeForFlow * 0.5f; + } } } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index fb06edb0b0..8553f68b9a 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -14,14 +14,13 @@ using osu.Game.Beatmaps.IO; using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Screens.Backgrounds; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Screens.Menu { public class Intro : OsuScreen { - private readonly OsuLogo logo; - private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; /// @@ -39,32 +38,10 @@ namespace osu.Game.Screens.Menu protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); - public Intro() - { - Children = new Drawable[] - { - new ParallaxContainer - { - ParallaxAmount = 0.01f, - Children = new Drawable[] - { - logo = new OsuLogo - { - Alpha = 0, - Triangles = false, - Blending = BlendingMode.Additive, - Interactive = false, - Colour = Color4.DarkGray, - Ripple = false - } - } - } - }; - } - private Bindable menuVoice; private Bindable menuMusic; private Track track; + private readonly ParallaxContainer parallax; [BackgroundDependencyLoader] private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) @@ -121,14 +98,48 @@ namespace osu.Game.Screens.Menu { DidLoadMenu = true; Push(mainMenu); - }, 2300); - }, 600); + }, delay_step_one); + }, delay_step_two); + } - logo.ScaleTo(0.4f); - logo.FadeOut(); + private const double delay_step_one = 2300; + private const double delay_step_two = 600; - logo.ScaleTo(1, 4400, Easing.OutQuint); - logo.FadeIn(20000, Easing.OutQuint); + public const int EXIT_DELAY = 3000; + + protected override void LogoSetup(OsuLogo logo, bool resuming) + { + base.LogoSetup(logo, resuming); + + logo.RelativePositionAxes = Axes.Both; + + logo.Triangles = false; + logo.Colour = Color4.DarkGray; + logo.Ripple = false; + + const int quick_appear = 150; + + int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0; + + logo.MoveTo(new Vector2(0.5f), initialMovementTime, Easing.OutQuint); + + if (!resuming) + { + logo.ScaleTo(0.4f); + logo.FadeOut(); + + logo.ScaleTo(1, delay_step_one + delay_step_two, Easing.OutQuint); + logo.FadeIn(delay_step_one + delay_step_two, Easing.OutQuint); + } + else + { + logo + .ScaleTo(1, initialMovementTime, Easing.OutQuint) + .FadeIn(quick_appear, Easing.OutQuint) + .Then() + .RotateTo(20, EXIT_DELAY * 1.5f) + .FadeOut(EXIT_DELAY); + } } protected override void OnSuspending(Screen next) @@ -148,7 +159,7 @@ namespace osu.Game.Screens.Menu if (!(last is MainMenu)) Content.FadeIn(300); - double fadeOutTime = 2000; + double fadeOutTime = EXIT_DELAY; //we also handle the exit transition. if (menuVoice) seeya.Play(); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index ff902bf28b..77e45c4575 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -102,6 +103,29 @@ namespace osu.Game.Screens.Menu Beatmap.ValueChanged += beatmap_ValueChanged; } + protected override void LogoSetup(OsuLogo logo, bool resuming) + { + base.LogoSetup(logo, resuming); + + buttons.SetOsuLogo(logo); + + logo.Triangles = true; + logo.Ripple = false; + + logo.FadeColour(Color4.White, 100, Easing.OutQuint); + logo.FadeIn(100, Easing.OutQuint); + + if (resuming) + buttons.State = MenuState.TopLevel; + } + + protected override void LogoOnSuspending(OsuLogo logo) + { + logo.FadeOut(300, Easing.InSine) + .ScaleTo(0.2f, 300, Easing.InSine) + .OnComplete(l => buttons.SetOsuLogo(null)); + } + private void beatmap_ValueChanged(WorkingBeatmap newValue) { if (!IsCurrentScreen) @@ -135,8 +159,6 @@ namespace osu.Game.Screens.Menu const float length = 300; - buttons.State = MenuState.TopLevel; - Content.FadeIn(length, Easing.OutQuint); Content.MoveTo(new Vector2(0, 0), length, Easing.OutQuint); diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 6f4a46b10b..297076a78b 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -29,6 +29,8 @@ namespace osu.Game.Screens.Menu { public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1"); + private const double transition_length = 300; + private readonly Sprite logo; private readonly CircularContainer logoContainer; private readonly Container logoBounceContainer; @@ -54,7 +56,7 @@ namespace osu.Game.Screens.Menu public bool Triangles { - set { colourAndTriangles.Alpha = value ? 1 : 0; } + set { colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } } public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => logoContainer.ReceiveMouseInputAt(screenSpacePos); @@ -62,10 +64,9 @@ namespace osu.Game.Screens.Menu public bool Ripple { get { return rippleContainer.Alpha > 0; } - set { rippleContainer.Alpha = value ? 1 : 0; } + set { rippleContainer.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } } - public bool Interactive = true; private readonly Box flashLayer; private readonly Container impactContainer; @@ -76,11 +77,12 @@ namespace osu.Game.Screens.Menu public OsuLogo() { + AlwaysPresent = true; + EarlyActivationMilliseconds = early_activation; Size = new Vector2(default_size); - Anchor = Anchor.Centre; Origin = Anchor.Centre; AutoSizeAxes = Axes.Both; @@ -222,6 +224,27 @@ namespace osu.Game.Screens.Menu ripple.Texture = textures.Get(@"Menu/logo"); } + private double? reservationEndTime; + private Action reservationCallback; + + private bool canFulfillReservation => !reservationEndTime.HasValue || reservationEndTime <= Time.Current; + + public void RequestUsage(Action callback) + { + reservationCallback = callback; + } + + private void fulfillReservation() + { + reservationCallback(this); + reservationCallback = null; + } + + public void ReserveFor(float duration) + { + reservationEndTime = Time.Current + duration; + } + private int lastBeatIndex; protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) @@ -288,11 +311,16 @@ namespace osu.Game.Screens.Menu { triangles.Velocity = paused_velocity; } + + if (reservationCallback != null && canFulfillReservation) + fulfillReservation(); } + private bool interactive => Action != null && Alpha > 0.2f; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - if (!Interactive) return false; + if (!interactive) return false; logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out); return true; @@ -306,7 +334,7 @@ namespace osu.Game.Screens.Menu protected override bool OnClick(InputState state) { - if (!Interactive) return false; + if (!interactive) return false; sampleClick.Play(); @@ -320,7 +348,7 @@ namespace osu.Game.Screens.Menu protected override bool OnHover(InputState state) { - if (!Interactive) return false; + if (!interactive) return false; logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic); return true; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 2a3cba0d49..412fe02d30 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -10,7 +10,9 @@ using osu.Game.Graphics.Containers; using OpenTK; using osu.Framework.Audio.Sample; using osu.Framework.Audio; +using osu.Framework.Graphics; using osu.Game.Rulesets; +using osu.Game.Screens.Menu; namespace osu.Game.Screens { @@ -30,6 +32,8 @@ namespace osu.Game.Screens public virtual bool HasLocalCursorDisplayed => false; + private OsuLogo logo; + /// /// Whether the beatmap or ruleset should be allowed to be changed by the user or game. /// Used to mark exclusive areas where this is strongly prohibited, like gameplay. @@ -72,9 +76,16 @@ namespace osu.Game.Screens protected override void OnResuming(Screen last) { base.OnResuming(last); + logo.WaitForTransforms().Schedule(() => logoSetup(true)); sampleExit?.Play(); } + protected override void OnSuspending(Screen next) + { + base.OnSuspending(next); + logoOnSuspending(); + } + protected override void OnEntering(Screen last) { OsuScreen lastOsu = last as OsuScreen; @@ -106,11 +117,19 @@ namespace osu.Game.Screens }); } + if ((logo = lastOsu?.logo) == null) + AddInternal(logo = new OsuLogo()); + base.OnEntering(last); + + logo.WaitForTransforms().Schedule(() => logoSetup(false)); } protected override bool OnExiting(Screen next) { + if (ValidForResume && logo != null) + logoOnExiting(); + OsuScreen nextOsu = next as OsuScreen; if (Background != null && !Background.Equals(nextOsu?.Background)) @@ -128,5 +147,33 @@ namespace osu.Game.Screens Beatmap.UnbindAll(); return false; } + + private void logoSetup(bool resuming) => LogoSetup(logo, resuming); + + protected virtual void LogoSetup(OsuLogo logo, bool resuming) + { + logo.Action = null; + logo.FadeOut(300, Easing.OutQuint); + } + + private void logoOnExiting() + { + logo.ClearTransforms(); + LogoOnExiting(logo); + } + + protected virtual void LogoOnExiting(OsuLogo logo) + { + } + + private void logoOnSuspending() + { + logo.ClearTransforms(); + LogoOnSuspending(logo); + } + + protected virtual void LogoOnSuspending(OsuLogo logo) + { + } } } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 71c2ec9a6d..054b4c0a0f 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -10,9 +10,9 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Backgrounds; -using osu.Game.Screens.Menu; using OpenTK; using osu.Framework.Localisation; +using osu.Game.Screens.Menu; namespace osu.Game.Screens.Play { @@ -20,7 +20,6 @@ namespace osu.Game.Screens.Play { private Player player; - private readonly OsuLogo logo; private BeatmapMetadataDisplay info; private bool showOverlays = true; @@ -39,15 +38,6 @@ namespace osu.Game.Screens.Play showOverlays = false; ValidForResume = true; }; - - Children = new Drawable[] - { - logo = new OsuLogo - { - Scale = new Vector2(0.15f), - Interactive = false, - }, - }; } [BackgroundDependencyLoader] @@ -101,11 +91,24 @@ namespace osu.Game.Screens.Play contentIn(); - logo.Delay(500).MoveToOffset(new Vector2(0, -180), 500, Easing.InOutExpo); info.Delay(750).FadeIn(500); this.Delay(2150).Schedule(pushWhenLoaded); } + protected override void LogoSetup(OsuLogo logo, bool resuming) + { + base.LogoSetup(logo, resuming); + + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; + + logo.ScaleTo(new Vector2(0.15f), 300, Easing.In); + logo.MoveTo(new Vector2(0.5f), 300, Easing.In); + logo.FadeIn(); + + logo.Delay(500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); + } + private void pushWhenLoaded() { if (player.LoadState != LoadState.Ready) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 00f311e522..40c3cf0fd4 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -13,7 +13,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Menu; namespace osu.Game.Screens.Select { @@ -31,12 +30,9 @@ namespace osu.Game.Screens.Select private const float padding = 80; public Action OnBack; - public Action OnStart; private readonly FillFlowContainer buttons; - public OsuLogo StartButton; - /// Text on the button. /// Colour of the button. /// Hotkey of the button. @@ -106,13 +102,6 @@ namespace osu.Game.Screens.Select Height = 3, Position = new Vector2(0, -3), }, - StartButton = new OsuLogo - { - Anchor = Anchor.BottomRight, - Scale = new Vector2(0.4f), - Position = new Vector2(-70, -25), - Action = () => OnStart?.Invoke() - }, new BackButton { Anchor = Anchor.BottomLeft, @@ -143,8 +132,6 @@ namespace osu.Game.Screens.Select updateModeLight(); } - public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => base.ReceiveMouseInputAt(screenSpacePos) || StartButton.ReceiveMouseInputAt(screenSpacePos); - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnClick(InputState state) => true; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e11eed7040..f9e3b0902d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -20,6 +20,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Overlays; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Edit; +using osu.Game.Screens.Menu; using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select @@ -153,7 +154,6 @@ namespace osu.Game.Screens.Select Add(Footer = new Footer { OnBack = Exit, - OnStart = () => carouselRaisedStart(), }); FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay()); @@ -309,6 +309,41 @@ namespace osu.Game.Screens.Select FilterControl.Activate(); } + private const double logo_transition = 250; + + protected override void LogoSetup(OsuLogo logo, bool resuming) + { + base.LogoSetup(logo, resuming); + + logo.ClearTransforms(); + logo.RelativePositionAxes = Axes.Both; + + Vector2 position = new Vector2(0.95f, 0.96f); + + if (logo.Alpha > 0.8f) + { + logo.MoveTo(position, 500, Easing.OutQuint); + } + else + { + logo.Hide(); + logo.ScaleTo(0.2f); + logo.MoveTo(position); + } + + logo.FadeIn(logo_transition, Easing.OutQuint); + logo.ScaleTo(0.4f, logo_transition, Easing.OutQuint); + + logo.Action = () => carouselRaisedStart(); + } + + protected override void LogoOnExiting(OsuLogo logo) + { + base.LogoOnExiting(logo); + logo.ScaleTo(0.2f, logo_transition, Easing.OutQuint); + logo.FadeOut(logo_transition, Easing.OutQuint); + } + private void beatmap_ValueChanged(WorkingBeatmap beatmap) { if (!IsCurrentScreen) return; @@ -350,6 +385,7 @@ namespace osu.Game.Screens.Select Content.FadeOut(100); FilterControl.Deactivate(); + return base.OnExiting(next); } From 9b2d41f4eb19a5cb729d45e28d7b9d20b932bca4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Nov 2017 21:52:01 +0900 Subject: [PATCH 07/10] Fix quick retry looking bad --- osu.Game/Screens/Play/PlayerLoader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 054b4c0a0f..e53026fb8d 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -104,9 +104,9 @@ namespace osu.Game.Screens.Play logo.ScaleTo(new Vector2(0.15f), 300, Easing.In); logo.MoveTo(new Vector2(0.5f), 300, Easing.In); - logo.FadeIn(); + logo.FadeIn(350); - logo.Delay(500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); + logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); } private void pushWhenLoaded() From c99ffb4aa39dbea7b0789a1b97d9bb78d47e17ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Nov 2017 21:52:12 +0900 Subject: [PATCH 08/10] Fix potential nullref --- 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 9cd92f054f..6f9b77e18e 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -141,7 +141,7 @@ namespace osu.Game.Screens.Menu switch (args.Key) { case Key.Space: - logo.TriggerOnClick(state); + logo?.TriggerOnClick(state); return true; case Key.Escape: switch (State) From 8f78d84ad6617ba4365cd7dd86c3f4875c9b404b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Nov 2017 21:52:23 +0900 Subject: [PATCH 09/10] Make intro resume slower --- osu.Game/Screens/Menu/Intro.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 8553f68b9a..dcf4a00a9a 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -117,7 +117,7 @@ namespace osu.Game.Screens.Menu logo.Colour = Color4.DarkGray; logo.Ripple = false; - const int quick_appear = 150; + const int quick_appear = 350; int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0; From 6a206c616baff0070ab852f6136a032864f40093 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Nov 2017 14:34:12 +0900 Subject: [PATCH 10/10] Update in line with framework changes --- osu.Game/Screens/OsuScreen.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 412fe02d30..5ecfcd8e8d 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -76,7 +76,7 @@ namespace osu.Game.Screens protected override void OnResuming(Screen last) { base.OnResuming(last); - logo.WaitForTransforms().Schedule(() => logoSetup(true)); + logo.DelayUntilTransformsFinished().Schedule(() => logoSetup(true)); sampleExit?.Play(); } @@ -122,7 +122,7 @@ namespace osu.Game.Screens base.OnEntering(last); - logo.WaitForTransforms().Schedule(() => logoSetup(false)); + logo.DelayUntilTransformsFinished().Schedule(() => logoSetup(false)); } protected override bool OnExiting(Screen next)