mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Remove custom back action logic (use receptor as intended)
This commit is contained in:
@ -10,8 +10,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
|
||||||
using osu.Framework.Input.Bindings;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
@ -20,7 +18,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Tournament.Screens.Editors
|
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 TDrawable : Drawable, IModelBacked<TModel>
|
||||||
where TModel : class, new()
|
where TModel : class, new()
|
||||||
{
|
{
|
||||||
@ -36,8 +34,6 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
private readonly TournamentScreen parentScreen;
|
private readonly TournamentScreen parentScreen;
|
||||||
private BackButton backButton;
|
private BackButton backButton;
|
||||||
|
|
||||||
private System.Action backAction => () => sceneManager?.SetScreen(parentScreen.GetType());
|
|
||||||
|
|
||||||
protected TournamentEditorScreen(TournamentScreen parentScreen = null)
|
protected TournamentEditorScreen(TournamentScreen parentScreen = null)
|
||||||
{
|
{
|
||||||
this.parentScreen = parentScreen;
|
this.parentScreen = parentScreen;
|
||||||
@ -88,16 +84,12 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
|
|
||||||
if (parentScreen != null)
|
if (parentScreen != null)
|
||||||
{
|
{
|
||||||
AddInternal(backButton = new BackButton(new BackButton.Receptor())
|
AddInternal(backButton = new BackButton
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
State = { Value = Visibility.Visible },
|
State = { Value = Visibility.Visible },
|
||||||
Action = () =>
|
Action = () => sceneManager?.SetScreen(parentScreen.GetType())
|
||||||
{
|
|
||||||
if (parentScreen != null)
|
|
||||||
backAction.Invoke();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
|
flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
|
||||||
@ -121,22 +113,6 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
flow.Add(CreateDrawable(model));
|
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);
|
protected abstract TDrawable CreateDrawable(TModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private readonly TwoLayerButton button;
|
private readonly TwoLayerButton button;
|
||||||
|
|
||||||
public BackButton(Receptor receptor)
|
public BackButton(Receptor receptor = null)
|
||||||
{
|
{
|
||||||
receptor.OnBackPressed = () => button.Click();
|
|
||||||
|
|
||||||
Size = TwoLayerButton.SIZE_EXTENDED;
|
Size = TwoLayerButton.SIZE_EXTENDED;
|
||||||
|
|
||||||
Child = button = new TwoLayerButton
|
Child = button = new TwoLayerButton
|
||||||
@ -30,6 +28,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Icon = OsuIcon.LeftCircle,
|
Icon = OsuIcon.LeftCircle,
|
||||||
Action = () => Action?.Invoke()
|
Action = () => Action?.Invoke()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Add(receptor ??= new Receptor());
|
||||||
|
|
||||||
|
receptor.OnBackPressed = () => button.Click();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
Reference in New Issue
Block a user