Reset slider input manager state completely on new object application

Kind of scary this wasn't happening already.

Mirrors `SpinnerRotationTracker`.
This commit is contained in:
Bartłomiej Dach 2024-02-29 11:54:42 +01:00
parent d05b31933f
commit 1d1db951f0
No known key found for this signature in database
1 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Screens.Play;
using osuTK;
@ -56,6 +57,7 @@ public partial class SliderInputManager : Component, IRequireHighFrequencyMouseP
public SliderInputManager(DrawableSlider slider)
{
this.slider = slider;
this.slider.HitObjectApplied += resetState;
}
/// <summary>
@ -287,5 +289,22 @@ private bool isValidTrackingAction(OsuAction action)
return action == OsuAction.LeftButton || action == OsuAction.RightButton;
}
private void resetState(DrawableHitObject obj)
{
Tracking = false;
trackingHistory.Clear();
trackingHistory.Push((double.NegativeInfinity, false));
timeToAcceptAnyKeyAfter = null;
lastPressedActions.Clear();
screenSpaceMousePosition = null;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
slider.HitObjectApplied -= resetState;
}
}
}