mirror of https://github.com/ppy/osu
Remove custom back action logic (use receptor as intended)
This commit is contained in:
parent
864c1a73ae
commit
13d4997c91
|
@ -10,8 +10,6 @@
|
|||
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 @@
|
|||
|
||||
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 @@ public abstract class TournamentEditorScreen<TDrawable, TModel> : TournamentScre
|
|||
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 @@ private void load()
|
|||
|
||||
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 @@ private void load()
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,8 @@ public class BackButton : VisibilityContainer
|
|||
|
||||
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 @@ public BackButton(Receptor receptor)
|
|||
Icon = OsuIcon.LeftCircle,
|
||||
Action = () => Action?.Invoke()
|
||||
};
|
||||
|
||||
Add(receptor ??= new Receptor());
|
||||
|
||||
receptor.OnBackPressed = () => button.Click();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
|
Loading…
Reference in New Issue