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

This reverts commit 44bbb8700e.
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

@ -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;