mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Merge pull request #677 from peppy/fix-mouse-button-disable
Fix disabling mouse buttons causing auto to stop working.
This commit is contained in:
commit
5e76f02b4f
@ -2,10 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using KeyboardState = osu.Framework.Input.KeyboardState;
|
using KeyboardState = osu.Framework.Input.KeyboardState;
|
||||||
@ -17,13 +14,6 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
private bool leftViaKeyboard;
|
private bool leftViaKeyboard;
|
||||||
private bool rightViaKeyboard;
|
private bool rightViaKeyboard;
|
||||||
private Bindable<bool> mouseDisabled;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void TransformState(InputState state)
|
protected override void TransformState(InputState state)
|
||||||
{
|
{
|
||||||
@ -40,12 +30,6 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
|
|
||||||
if (mouse != null)
|
if (mouse != null)
|
||||||
{
|
{
|
||||||
if (mouseDisabled.Value)
|
|
||||||
{
|
|
||||||
mouse.SetPressed(MouseButton.Left, false);
|
|
||||||
mouse.SetPressed(MouseButton.Right, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftViaKeyboard)
|
if (leftViaKeyboard)
|
||||||
mouse.SetPressed(MouseButton.Left, true);
|
mouse.SetPressed(MouseButton.Left, true);
|
||||||
if (rightViaKeyboard)
|
if (rightViaKeyboard)
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK.Input;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -15,7 +19,10 @@ namespace osu.Game.Screens.Play
|
|||||||
private ReplayInputHandler replayInputHandler;
|
private ReplayInputHandler replayInputHandler;
|
||||||
public ReplayInputHandler ReplayInputHandler
|
public ReplayInputHandler ReplayInputHandler
|
||||||
{
|
{
|
||||||
get { return replayInputHandler; }
|
get
|
||||||
|
{
|
||||||
|
return replayInputHandler;
|
||||||
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (replayInputHandler != null) RemoveHandler(replayInputHandler);
|
if (replayInputHandler != null) RemoveHandler(replayInputHandler);
|
||||||
@ -28,6 +35,14 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bindable<bool> mouseDisabled;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -96,5 +111,24 @@ namespace osu.Game.Screens.Play
|
|||||||
requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime;
|
requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime;
|
||||||
base.Update();
|
base.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void TransformState(InputState state)
|
||||||
|
{
|
||||||
|
base.TransformState(state);
|
||||||
|
|
||||||
|
// we don't want to transform the state if a replay is present (for now, at least).
|
||||||
|
if (replayInputHandler != null) return;
|
||||||
|
|
||||||
|
var mouse = state.Mouse as Framework.Input.MouseState;
|
||||||
|
|
||||||
|
if (mouse != null)
|
||||||
|
{
|
||||||
|
if (mouseDisabled.Value)
|
||||||
|
{
|
||||||
|
mouse.SetPressed(MouseButton.Left, false);
|
||||||
|
mouse.SetPressed(MouseButton.Right, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user