1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:03:21 +08:00

Rewrite disable mouse buttons logic

This commit is contained in:
ekrctb 2018-07-03 20:04:15 +09:00
parent 8ecd235820
commit d71b61c122

View File

@ -222,23 +222,16 @@ namespace osu.Game.Rulesets.UI
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
}
protected override void TransformState(InputState state)
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
base.TransformState(state);
if (mouseDisabled.Value && (args.Button == MouseButton.Left || args.Button == MouseButton.Right)) return false;
return base.OnMouseDown(state, args);
}
// 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);
}
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
if (!CurrentState.Mouse.IsPressed(args.Button)) return false;
return base.OnMouseUp(state, args);
}
#endregion