Merge pull request #11626 from peppy/fix-spinner-spm-negative

Ensure spinners only handle input during their hittable time
This commit is contained in:
Dean Herbert 2021-02-01 16:27:22 +09:00 committed by GitHub
commit 0dd1208579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View File

@ -243,7 +243,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
base.Update();
if (HandleUserInput)
RotationTracker.Tracking = !Result.HasResult && (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
{
bool isValidSpinningTime = Time.Current >= HitObject.StartTime && Time.Current <= HitObject.EndTime;
bool correctButtonPressed = (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
RotationTracker.Tracking = !Result.HasResult
&& correctButtonPressed
&& isValidSpinningTime;
}
if (spinningSample != null && spinnerFrequencyModulate)
spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress;
@ -255,6 +262,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (!SpmCounter.IsPresent && RotationTracker.Tracking)
SpmCounter.FadeIn(HitObject.TimeFadeIn);
SpmCounter.SetRotation(Result.RateAdjustedRotation);
updateBonusScore();

View File

@ -4,16 +4,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public class SpinnerSpmCounter : Container
{
[Resolved]
private DrawableHitObject drawableSpinner { get; set; }
private readonly OsuSpriteText spmText;
public SpinnerSpmCounter()
@ -38,6 +43,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
};
}
protected override void LoadComplete()
{
base.LoadComplete();
drawableSpinner.HitObjectApplied += resetState;
}
private double spm;
public double SpinsPerMinute
@ -82,5 +93,19 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
records.Enqueue(new RotationRecord { Rotation = currentRotation, Time = Time.Current });
}
private void resetState(DrawableHitObject hitObject)
{
SpinsPerMinute = 0;
records.Clear();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (drawableSpinner != null)
drawableSpinner.HitObjectApplied -= resetState;
}
}
}