mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 02:08:21 +08:00
Merge pull request #27429 from bdach/rewind-slider-tracking
Fix slider tracking state not restoring correctly in all cases on rewind
This commit is contained in:
commit
646edb239a
@ -457,6 +457,33 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
assertMidSliderJudgementFail();
|
assertMidSliderJudgementFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRewindHandling()
|
||||||
|
{
|
||||||
|
performTest(new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Position = new Vector2(0), Actions = { OsuAction.LeftButton }, Time = time_slider_start },
|
||||||
|
new OsuReplayFrame { Position = new Vector2(175, 0), Actions = { OsuAction.LeftButton }, Time = 3250 },
|
||||||
|
new OsuReplayFrame { Position = new Vector2(175, 0), Actions = { OsuAction.LeftButton }, Time = time_slider_end },
|
||||||
|
}, new Slider
|
||||||
|
{
|
||||||
|
StartTime = time_slider_start,
|
||||||
|
Position = new Vector2(0, 0),
|
||||||
|
Path = new SliderPath(PathType.PERFECT_CURVE, new[]
|
||||||
|
{
|
||||||
|
Vector2.Zero,
|
||||||
|
new Vector2(250, 0),
|
||||||
|
}, 250),
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||||
|
AddAssert("no miss judgements recorded", () => judgementResults.All(r => r.Type.IsHit()));
|
||||||
|
|
||||||
|
AddStep("rewind to middle of slider", () => currentPlayer.Seek(time_during_slide_4));
|
||||||
|
AddUntilStep("wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||||
|
AddAssert("no miss judgements recorded", () => judgementResults.All(r => r.Type.IsHit()));
|
||||||
|
}
|
||||||
|
|
||||||
private void assertAllMaxJudgements()
|
private void assertAllMaxJudgements()
|
||||||
{
|
{
|
||||||
AddAssert("All judgements max", () =>
|
AddAssert("All judgements max", () =>
|
||||||
|
20
osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs
Normal file
20
osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Judgements
|
||||||
|
{
|
||||||
|
public class OsuSliderJudgementResult : OsuJudgementResult
|
||||||
|
{
|
||||||
|
public readonly Stack<(double time, bool tracking)> TrackingHistory = new Stack<(double, bool)>();
|
||||||
|
|
||||||
|
public OsuSliderJudgementResult(HitObject hitObject, Judgement judgement)
|
||||||
|
: base(hitObject, judgement)
|
||||||
|
{
|
||||||
|
TrackingHistory.Push((double.NegativeInfinity, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,10 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -27,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public new Slider HitObject => (Slider)base.HitObject;
|
public new Slider HitObject => (Slider)base.HitObject;
|
||||||
|
|
||||||
|
public new OsuSliderJudgementResult Result => (OsuSliderJudgementResult)base.Result;
|
||||||
|
|
||||||
public DrawableSliderHead HeadCircle => headContainer.Child;
|
public DrawableSliderHead HeadCircle => headContainer.Child;
|
||||||
public DrawableSliderTail TailCircle => tailContainer.Child;
|
public DrawableSliderTail TailCircle => tailContainer.Child;
|
||||||
|
|
||||||
@ -134,6 +138,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuSliderJudgementResult(HitObject, judgement);
|
||||||
|
|
||||||
protected override void OnApply()
|
protected override void OnApply()
|
||||||
{
|
{
|
||||||
base.OnApply();
|
base.OnApply();
|
||||||
|
@ -5,11 +5,14 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
@ -21,6 +24,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Tracking { get; private set; }
|
public bool Tracking { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IGameplayClock? gameplayClock { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle.
|
/// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle.
|
||||||
///
|
///
|
||||||
@ -49,6 +55,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
public SliderInputManager(DrawableSlider slider)
|
public SliderInputManager(DrawableSlider slider)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
|
this.slider.HitObjectApplied += resetState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -208,6 +215,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
/// <param name="isValidTrackingPosition">Whether the current mouse position is valid to begin tracking.</param>
|
/// <param name="isValidTrackingPosition">Whether the current mouse position is valid to begin tracking.</param>
|
||||||
private void updateTracking(bool isValidTrackingPosition)
|
private void updateTracking(bool isValidTrackingPosition)
|
||||||
{
|
{
|
||||||
|
if (gameplayClock?.IsRewinding == true)
|
||||||
|
{
|
||||||
|
var trackingHistory = slider.Result.TrackingHistory;
|
||||||
|
while (trackingHistory.TryPeek(out var historyEntry) && Time.Current < historyEntry.time)
|
||||||
|
trackingHistory.Pop();
|
||||||
|
|
||||||
|
Debug.Assert(trackingHistory.Count > 0);
|
||||||
|
|
||||||
|
Tracking = trackingHistory.Peek().tracking;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wasTracking = Tracking;
|
||||||
|
|
||||||
// from the point at which the head circle is hit, this will be non-null.
|
// from the point at which the head circle is hit, this will be non-null.
|
||||||
// it may be null if the head circle was missed.
|
// it may be null if the head circle was missed.
|
||||||
OsuAction? headCircleHitAction = getInitialHitAction();
|
OsuAction? headCircleHitAction = getInitialHitAction();
|
||||||
@ -247,6 +268,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
&& isValidTrackingPosition
|
&& isValidTrackingPosition
|
||||||
// valid action
|
// valid action
|
||||||
&& validTrackingAction;
|
&& validTrackingAction;
|
||||||
|
|
||||||
|
if (wasTracking != Tracking)
|
||||||
|
slider.Result.TrackingHistory.Push((Time.Current, Tracking));
|
||||||
}
|
}
|
||||||
|
|
||||||
private OsuAction? getInitialHitAction() => slider.HeadCircle?.HitAction;
|
private OsuAction? getInitialHitAction() => slider.HeadCircle?.HitAction;
|
||||||
@ -264,5 +288,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
return action == OsuAction.LeftButton || action == OsuAction.RightButton;
|
return action == OsuAction.LeftButton || action == OsuAction.RightButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetState(DrawableHitObject obj)
|
||||||
|
{
|
||||||
|
Tracking = false;
|
||||||
|
timeToAcceptAnyKeyAfter = null;
|
||||||
|
lastPressedActions.Clear();
|
||||||
|
screenSpaceMousePosition = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
slider.HitObjectApplied -= resetState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user