mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 23:22:55 +08:00
Relieve OsuScreen of back button input duties
This commit is contained in:
parent
f53d2fbe76
commit
d9927204f8
@ -3,10 +3,12 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class BackButton : TwoLayerButton
|
||||
public class BackButton : TwoLayerButton, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public BackButton()
|
||||
{
|
||||
@ -22,5 +24,18 @@ namespace osu.Game.Graphics.UserInterface
|
||||
BackgroundColour = colours.Pink;
|
||||
HoverColour = colours.PinkDark;
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (action == GlobalAction.Back)
|
||||
{
|
||||
Action?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
|
||||
}
|
||||
}
|
||||
|
@ -406,6 +406,11 @@ namespace osu.Game
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Alpha = 0,
|
||||
Action = () =>
|
||||
{
|
||||
if ((screenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
|
||||
screenStack.Exit();
|
||||
}
|
||||
},
|
||||
logoContainer = new Container { RelativeSizeAxes = Axes.Both },
|
||||
}
|
||||
|
@ -8,10 +8,8 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Overlays;
|
||||
@ -21,7 +19,7 @@ using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
{
|
||||
public abstract class OsuScreen : Screen, IOsuScreen, IKeyBindingHandler<GlobalAction>, IHasDescription
|
||||
public abstract class OsuScreen : Screen, IOsuScreen, IHasDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of negative padding that should be applied to game background content which touches both the left and right sides of the screen.
|
||||
@ -133,21 +131,6 @@ namespace osu.Game.Screens
|
||||
sampleExit = audio.Samples.Get(@"UI/screen-back");
|
||||
}
|
||||
|
||||
public virtual bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return false;
|
||||
|
||||
if (action == GlobalAction.Back && AllowBackButton)
|
||||
{
|
||||
this.Exit();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton;
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
if (PlayResumeSound)
|
||||
|
@ -34,10 +34,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public abstract class SongSelect : OsuScreen
|
||||
public abstract class SongSelect : OsuScreen, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||
|
||||
@ -645,7 +646,7 @@ namespace osu.Game.Screens.Select
|
||||
Schedule(() => BeatmapDetails.Leaderboard.RefreshScores())));
|
||||
}
|
||||
|
||||
public override bool OnPressed(GlobalAction action)
|
||||
public virtual bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return false;
|
||||
|
||||
@ -656,9 +657,11 @@ namespace osu.Game.Screens.Select
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnPressed(action);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => action == GlobalAction.Select;
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user