From 13d4997c9165401c5123fd8a995cb9c8d9cb52e8 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Sun, 17 May 2020 17:35:10 +0900
Subject: [PATCH] Remove custom back action logic (use receptor as intended)

---
 .../Screens/Editors/TournamentEditorScreen.cs | 30 ++-----------------
 osu.Game/Graphics/UserInterface/BackButton.cs |  8 +++--
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
index b92818b84a..a5a2c5c15f 100644
--- a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
@@ -10,8 +10,6 @@ using osu.Framework.Graphics;
 using osu.Framework.Graphics.Containers;
 using osu.Framework.Graphics.Shapes;
 using osu.Game.Graphics.UserInterface;
-using osu.Game.Input.Bindings;
-using osu.Framework.Input.Bindings;
 using osu.Game.Graphics;
 using osu.Game.Graphics.Containers;
 using osu.Game.Overlays.Settings;
@@ -20,7 +18,7 @@ using osuTK;
 
 namespace osu.Game.Tournament.Screens.Editors
 {
-    public abstract class TournamentEditorScreen<TDrawable, TModel> : TournamentScreen, IProvideVideo, IKeyBindingHandler<GlobalAction>
+    public abstract class TournamentEditorScreen<TDrawable, TModel> : TournamentScreen, IProvideVideo
         where TDrawable : Drawable, IModelBacked<TModel>
         where TModel : class, new()
     {
@@ -36,8 +34,6 @@ namespace osu.Game.Tournament.Screens.Editors
         private readonly TournamentScreen parentScreen;
         private BackButton backButton;
 
-        private System.Action backAction => () => sceneManager?.SetScreen(parentScreen.GetType());
-
         protected TournamentEditorScreen(TournamentScreen parentScreen = null)
         {
             this.parentScreen = parentScreen;
@@ -88,16 +84,12 @@ namespace osu.Game.Tournament.Screens.Editors
 
             if (parentScreen != null)
             {
-                AddInternal(backButton = new BackButton(new BackButton.Receptor())
+                AddInternal(backButton = new BackButton
                 {
                     Anchor = Anchor.BottomLeft,
                     Origin = Anchor.BottomLeft,
                     State = { Value = Visibility.Visible },
-                    Action = () =>
-                    {
-                        if (parentScreen != null)
-                            backAction.Invoke();
-                    }
+                    Action = () => sceneManager?.SetScreen(parentScreen.GetType())
                 });
 
                 flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
@@ -121,22 +113,6 @@ namespace osu.Game.Tournament.Screens.Editors
                 flow.Add(CreateDrawable(model));
         }
 
-        public bool OnPressed(GlobalAction action)
-        {
-            switch (action)
-            {
-                case GlobalAction.Back:
-                    backAction?.Invoke();
-                    return true;
-            }
-
-            return false;
-        }
-
-        public void OnReleased(GlobalAction action)
-        {
-        }
-
         protected abstract TDrawable CreateDrawable(TModel model);
     }
 }
diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs
index 88ba7ede6e..37a8f7b1b4 100644
--- a/osu.Game/Graphics/UserInterface/BackButton.cs
+++ b/osu.Game/Graphics/UserInterface/BackButton.cs
@@ -16,10 +16,8 @@ namespace osu.Game.Graphics.UserInterface
 
         private readonly TwoLayerButton button;
 
-        public BackButton(Receptor receptor)
+        public BackButton(Receptor receptor = null)
         {
-            receptor.OnBackPressed = () => button.Click();
-
             Size = TwoLayerButton.SIZE_EXTENDED;
 
             Child = button = new TwoLayerButton
@@ -30,6 +28,10 @@ namespace osu.Game.Graphics.UserInterface
                 Icon = OsuIcon.LeftCircle,
                 Action = () => Action?.Invoke()
             };
+
+            Add(receptor ??= new Receptor());
+
+            receptor.OnBackPressed = () => button.Click();
         }
 
         [BackgroundDependencyLoader]