Skip to content

Commit

Permalink
Merge pull request ppy#25893 from smoogipoo/fix-early-slide-sample
Browse files Browse the repository at this point in the history
Fix sliding sample playing before Slider's start time
  • Loading branch information
bdach authored Dec 19, 2023
2 parents c078d63 + fe5e071 commit 1161e0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Screens;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Judgements;
Expand Down Expand Up @@ -160,6 +161,10 @@ private void performTest(List<ReplayFrame> frames, Action<Slider>? adjustSliderF
Position = new Vector2(256 - slider_path_length / 2, 192),
TickDistanceMultiplier = 3,
ClassicSliderBehaviour = classic,
Samples = new[]
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
},
Path = new SliderPath(PathType.LINEAR, new[]
{
Vector2.Zero,
Expand Down
25 changes: 12 additions & 13 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ private void load()
foreach (var drawableHitObject in NestedHitObjects)
drawableHitObject.AccentColour.Value = colour.NewValue;
}, true);

Tracking.BindValueChanged(updateSlidingSample);
}

protected override void OnApply()
Expand Down Expand Up @@ -166,14 +164,6 @@ public override void StopAllSamples()
slidingSample?.Stop();
}

private void updateSlidingSample(ValueChangedEvent<bool> tracking)
{
if (tracking.NewValue)
slidingSample?.Play();
else
slidingSample?.Stop();
}

protected override void AddNestedHitObject(DrawableHitObject hitObject)
{
base.AddNestedHitObject(hitObject);
Expand Down Expand Up @@ -238,9 +228,18 @@ protected override void Update()

Tracking.Value = SliderInputManager.Tracking;

if (Tracking.Value && slidingSample != null)
// keep the sliding sample playing at the current tracking position
slidingSample.Balance.Value = CalculateSamplePlaybackBalance(CalculateDrawableRelativePosition(Ball));
if (slidingSample != null)
{
if (Tracking.Value && Time.Current >= HitObject.StartTime)
{
// keep the sliding sample playing at the current tracking position
if (!slidingSample.IsPlaying)
slidingSample.Play();
slidingSample.Balance.Value = CalculateSamplePlaybackBalance(CalculateDrawableRelativePosition(Ball));
}
else if (slidingSample.IsPlaying)
slidingSample.Stop();
}

double completionProgress = Math.Clamp((Time.Current - HitObject.StartTime) / HitObject.Duration, 0, 1);

Expand Down

0 comments on commit 1161e0a

Please sign in to comment.