Skip to content

Commit

Permalink
Merge pull request ppy#23372 from peppy/fix-slider-end-circle-appear-…
Browse files Browse the repository at this point in the history
…delay

Fix fade in delay for first slider end circle being incorrect when snaking disabled
  • Loading branch information
bdach authored May 3, 2023
2 parents fa3f42b + a619812 commit a45f0b6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
26 changes: 26 additions & 0 deletions osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
using osu.Game.Rulesets.Mods;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Configuration;

namespace osu.Game.Rulesets.Osu.Tests
{
Expand All @@ -30,6 +35,27 @@ public partial class TestSceneSlider : OsuSkinnableTestScene
{
private int depthIndex;

private readonly BindableBool snakingIn = new BindableBool();
private readonly BindableBool snakingOut = new BindableBool();

[SetUpSteps]
public void SetUpSteps()
{
AddToggleStep("toggle snaking", v =>
{
snakingIn.Value = v;
snakingOut.Value = v;
});
}

[BackgroundDependencyLoader]
private void load()
{
var config = (OsuRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(OsuRulesetSetting.SnakingInSliders, snakingIn);
config.BindWith(OsuRulesetSetting.SnakingOutSliders, snakingOut);
}

[Test]
public void TestVariousSliders()
{
Expand Down
11 changes: 7 additions & 4 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)

protected override void UpdateInitialTransforms()
{
// When snaking in is enabled, the first end circle needs to be delayed until the snaking completes.
bool delayFadeIn = DrawableSlider.SliderBody?.SnakingIn.Value == true && HitObject.RepeatIndex == 0;

animDuration = Math.Min(300, HitObject.SpanDuration);

this.Animate(
d => d.FadeIn(animDuration),
d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 2, Easing.OutElasticHalf)
);
this
.FadeOut()
.Delay(delayFadeIn ? (Slider?.TimePreempt ?? 0) / 3 : 0)
.FadeIn(HitObject.RepeatIndex == 0 ? HitObject.TimeFadeIn : animDuration);
}

protected override void UpdateHitStateTransforms(ArmedState state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();

CirclePiece.FadeInFromZero(HitObject.TimeFadeIn);
// When snaking in is enabled, the first end circle needs to be delayed until the snaking completes.
bool delayFadeIn = DrawableSlider.SliderBody?.SnakingIn.Value == true && HitObject.RepeatIndex == 0;

CirclePiece
.FadeOut()
.Delay(delayFadeIn ? (Slider?.TimePreempt ?? 0) / 3 : 0)
.FadeIn(HitObject.TimeFadeIn);
}

protected override void UpdateHitStateTransforms(ArmedState state)
Expand Down
5 changes: 1 addition & 4 deletions osu.Game.Rulesets.Osu/Objects/SliderEndCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I
}
else
{
// taken from osu-stable
const float first_end_circle_preempt_adjust = 2 / 3f;

// The first end circle should fade in with the slider.
TimePreempt = (StartTime - slider.StartTime) + slider.TimePreempt * first_end_circle_preempt_adjust;
TimePreempt += StartTime - slider.StartTime;
}
}

Expand Down

0 comments on commit a45f0b6

Please sign in to comment.