diff --git a/osu.Game/Screens/Menu/ExitConfirmOverlay.cs b/osu.Game/Screens/Menu/ExitConfirmOverlay.cs index 253ec17c28..a90b83c5fe 100644 --- a/osu.Game/Screens/Menu/ExitConfirmOverlay.cs +++ b/osu.Game/Screens/Menu/ExitConfirmOverlay.cs @@ -3,7 +3,6 @@ using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Game.Configuration; using osu.Game.Input.Bindings; using osu.Game.Overlays; @@ -43,26 +42,4 @@ namespace osu.Game.Screens.Menu } } } - - /// - /// An that behaves as if the is always 0. - /// - /// This is useful for mobile devices using gesture navigation, where holding to confirm is not possible. - public class NoHoldExitConfirmOverlay : ExitConfirmOverlay, IKeyBindingHandler - { - public new bool OnPressed(KeyBindingPressEvent e) - { - if (e.Repeat) - return false; - - if (e.Action == GlobalAction.Back) - { - Progress.Value = 1; - Confirm(); - return true; - } - - return false; - } - } } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 7bc0cb48bf..a2cb448d40 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -6,12 +6,15 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Input.Bindings; +using osu.Framework.Input.Events; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Input.Bindings; using osu.Game.IO; using osu.Game.Online.API; using osu.Game.Overlays; @@ -26,7 +29,7 @@ using osuTK.Graphics; namespace osu.Game.Screens.Menu { - public class MainMenu : OsuScreen, IHandlePresentBeatmap + public class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHandler { public const float FADE_IN_DURATION = 300; @@ -90,14 +93,6 @@ namespace osu.Game.Screens.Menu } }); } - else if (host.CanSuspendToBackground) - { - AddInternal(exitConfirmOverlay = new NoHoldExitConfirmOverlay - { - // treat as if the UIHoldActivationDelay is always 0. see NoHoldExitConfirmOverlay xmldoc for more info. - Action = this.Exit - }); - } AddRangeInternal(new[] { @@ -157,24 +152,6 @@ namespace osu.Game.Screens.Menu private void confirmAndExit() { - if (host.CanSuspendToBackground) - { - // cancel the overlay as we're not actually exiting. - // this is the same action as 'onCancel' in `ConfirmExitDialog`. - exitConfirmOverlay.Abort(); - - // fade the track so the Bass.Pause() on suspend isn't as jarring. - const double fade_time = 500; - musicController.CurrentTrack - .VolumeTo(0, fade_time, Easing.Out).Then() - .VolumeTo(1, fade_time, Easing.In); - - host.SuspendToBackground(); - - // on hosts that can only suspend, we don't ever want to exit the game. - return; - } - if (exitConfirmed) return; exitConfirmed = true; @@ -324,5 +301,33 @@ namespace osu.Game.Screens.Menu Schedule(loadSoloSongSelect); } + + public bool OnPressed(KeyBindingPressEvent e) + { + if (e.Repeat) + return false; + + if (e.Action == GlobalAction.Back && host.CanSuspendToBackground) + { + bool didSuspend = host.SuspendToBackground(); + + if (didSuspend) + { + // fade the track so the Bass.Pause() on suspend isn't as jarring. + const double fade_time = 500; + musicController.CurrentTrack + .VolumeTo(0, fade_time, Easing.Out).Then() + .VolumeTo(1, fade_time, Easing.In); + + return true; + } + } + + return false; + } + + public void OnReleased(KeyBindingReleaseEvent e) + { + } } }