1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 02:57:25 +08:00

Revert "Handle mouse back button using OnMouseDown override instead of using GlobalAction"

This reverts commit 44bbb8700ecc1bdd652c35766bfbaa54310a5855.
This commit is contained in:
Roman Kapustin 2018-05-14 20:27:05 +03:00
parent 38d54f2a6c
commit e802b722f0
7 changed files with 48 additions and 47 deletions

View File

@ -26,7 +26,7 @@ namespace osu.Game.Input.Bindings
{
new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
new KeyBinding(InputKey.F12,GlobalAction.TakeScreenshot),
new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
@ -36,6 +36,9 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Down, GlobalAction.DecreaseVolume),
new KeyBinding(InputKey.MouseWheelDown, GlobalAction.DecreaseVolume),
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.MouseButton1, GlobalAction.Back)
};
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
@ -76,6 +79,9 @@ namespace osu.Game.Input.Bindings
QuickRetry,
[Description("Take screenshot")]
TakeScreenshot
TakeScreenshot,
[Description("Go back")]
Back
}
}

View File

@ -18,7 +18,6 @@ namespace osu.Game.Screens
private bool showDisclaimer;
public override bool ShowOverlaysOnEnter => false;
protected override bool AllowBackButton => false;
public Loader()
{

View File

@ -13,15 +13,17 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
namespace osu.Game.Screens.Menu
{
public class ButtonSystem : Container, IStateful<MenuState>
public class ButtonSystem : Container, IStateful<MenuState>, IKeyBindingHandler<GlobalAction>
{
public event Action<MenuState> StateChanged;
@ -146,36 +148,44 @@ namespace osu.Game.Screens.Menu
case Key.Space:
logo?.TriggerOnClick(state);
return true;
case Key.Escape:
return handleBack();
}
return false;
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
public bool OnPressed(GlobalAction action)
{
if (state.Mouse.IsPressed(MouseButton.Button1))
return handleBack();
return base.OnMouseDown(state, args);
}
private bool handleBack()
{
switch (State)
switch (action)
{
case MenuState.TopLevel:
State = MenuState.Initial;
return true;
case MenuState.Play:
backButton.TriggerOnClick();
return true;
case GlobalAction.Back:
switch (State)
{
case MenuState.TopLevel:
State = MenuState.Initial;
return true;
case MenuState.Play:
backButton.TriggerOnClick();
return true;
default:
return false;
}
default:
return false;
}
return false;
}
public bool OnReleased(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
return true;
default:
return false;
}
}
private void onPlay()
{
State = MenuState.Play;

View File

@ -25,7 +25,6 @@ namespace osu.Game.Screens.Menu
private readonly ButtonSystem buttons;
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
protected override bool AllowBackButton => false;
private readonly BackgroundScreenDefault background;
private Screen songSelect;

View File

@ -7,18 +7,18 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.Screens
{
public abstract class OsuScreen : Screen
public abstract class OsuScreen : Screen, IKeyBindingHandler<GlobalAction>
{
public BackgroundScreen Background { get; private set; }
@ -92,31 +92,19 @@ namespace osu.Game.Screens
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
public bool OnPressed(GlobalAction action)
{
if (args.Repeat || !IsCurrentScreen) return false;
switch (args.Key)
{
case Key.Escape:
Exit();
return true;
}
return base.OnKeyDown(state, args);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
if (AllowBackButton && state.Mouse.IsPressed(MouseButton.Button1))
if (action == GlobalAction.Back && AllowBackButton)
{
Exit();
return true;
}
return base.OnMouseDown(state, args);
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton;
protected override void OnResuming(Screen last)
{
sampleExit?.Play();

View File

@ -27,6 +27,7 @@ namespace osu.Game.Screens.Play
private bool showOverlays = true;
public override bool ShowOverlaysOnEnter => showOverlays;
protected override bool AllowBackButton => false;
private Task loadTask;

View File

@ -17,8 +17,6 @@ namespace osu.Game.Screens.Play
public override bool AllowBeatmapRulesetChange => false;
protected override bool AllowBackButton => false;
protected const float BACKGROUND_FADE_DURATION = 800;
protected float BackgroundOpacity => 1 - (float)DimLevel;