From 7f5780c615155e2788457bba349d78cdfc47ea53 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Feb 2019 21:30:47 +0900 Subject: [PATCH] Simplify SliderBall and fix incorrect key up handling Was not processing timeToAcceptAnyKeyAfter when cursor was outside valid tracking area, but should have been. --- .../Objects/Drawables/Pieces/SliderBall.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs index a8ee4c42fd..609236311b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -125,6 +125,8 @@ protected override bool OnMouseMove(MouseMoveEvent e) return base.OnMouseMove(e); } + public bool OnReleased(OsuAction action) => false; + public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null) { // Consider the case of rewinding - children's transforms are handled internally, so propagating down @@ -148,8 +150,6 @@ private set } } - private bool canCurrentlyTrack => Time.Current >= slider.StartTime && Time.Current < slider.EndTime && lastScreenSpaceMousePosition.HasValue && base.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value); - /// /// If the cursor moves out of the ball's radius we still need to be able to receive positional updates to stop tracking. /// @@ -183,26 +183,25 @@ protected override void Update() if (headCircleHitAction == null) timeToAcceptAnyKeyAfter = null; - if (canCurrentlyTrack) + var actions = drawableSlider?.OsuActionInputManager?.PressedActions; + + // if the head circle was hit with a specific key, tracking should only occur while that key is pressed. + if (headCircleHitAction != null && timeToAcceptAnyKeyAfter == null) { - var pressed = drawableSlider?.OsuActionInputManager?.PressedActions; + var otherKey = headCircleHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton; - // if the head circle was hit with a specific key, tracking should only occur while that key is pressed. - if (headCircleHitAction != null && timeToAcceptAnyKeyAfter == null) - { - var otherKey = headCircleHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton; - - // we can return to accepting all keys if the initial head circle key is the *only* key pressed, or all keys have been released. - if (!pressed.Contains(otherKey)) - timeToAcceptAnyKeyAfter = Time.Current; - } - - Tracking = drawableSlider?.OsuActionInputManager?.PressedActions.Any(isValidTrackingAction) ?? false; - } - else - { - Tracking = false; + // we can return to accepting all keys if the initial head circle key is the *only* key pressed, or all keys have been released. + if (actions?.Contains(otherKey) != true) + timeToAcceptAnyKeyAfter = Time.Current; } + + Tracking = + // in valid time range + Time.Current >= slider.StartTime && Time.Current < slider.EndTime && + // in valid position range + lastScreenSpaceMousePosition.HasValue && base.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) && + // valid action + (actions?.Any(isValidTrackingAction) ?? false); } ///