1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Silence hit sounds while seeking

This commit is contained in:
Dean Herbert 2020-05-21 10:58:30 +09:00
parent c2697d3907
commit ce223a2bd8
3 changed files with 28 additions and 5 deletions

View File

@ -17,6 +17,7 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using osu.Game.Configuration;
using osu.Game.Screens.Play;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Objects.Drawables
@ -348,6 +349,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
}
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
/// <summary>
/// Plays all the hit sounds for this <see cref="DrawableHitObject"/>.
/// This is invoked automatically when this <see cref="DrawableHitObject"/> is hit.
@ -356,7 +360,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
const float balance_adjust_amount = 0.4f;
if (Samples != null)
if (Samples != null && gameplayClock?.IsSeeking != true)
{
Samples.Balance.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
Samples.Play();

View File

@ -29,14 +29,16 @@ namespace osu.Game.Rulesets.UI
/// </summary>
internal bool FrameStablePlayback = true;
[Cached]
public GameplayClock GameplayClock { get; }
public GameplayClock GameplayClock => stabilityGameplayClock;
[Cached(typeof(GameplayClock))]
private readonly StabilityGameplayClock stabilityGameplayClock;
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
{
RelativeSizeAxes = Axes.Both;
GameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
stabilityGameplayClock = new StabilityGameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
this.gameplayStartTime = gameplayStartTime;
}
@ -57,7 +59,7 @@ namespace osu.Game.Rulesets.UI
{
if (clock != null)
{
parentGameplayClock = clock;
stabilityGameplayClock.ParentGameplayClock = parentGameplayClock = clock;
GameplayClock.IsPaused.BindTo(clock.IsPaused);
}
}
@ -187,5 +189,17 @@ namespace osu.Game.Rulesets.UI
}
public ReplayInputHandler ReplayInputHandler { get; set; }
private class StabilityGameplayClock : GameplayClock
{
public IFrameBasedClock ParentGameplayClock;
public StabilityGameplayClock(FramedClock underlyingClock)
: base(underlyingClock)
{
}
public override bool IsSeeking => ParentGameplayClock != null && Math.Abs(CurrentTime - ParentGameplayClock.CurrentTime) > 200;
}
}
}

View File

@ -31,6 +31,11 @@ namespace osu.Game.Screens.Play
public bool IsRunning => underlyingClock.IsRunning;
/// <summary>
/// Whether an ongoing seek operation is active.
/// </summary>
public virtual bool IsSeeking => false;
public void ProcessFrame()
{
// we do not want to process the underlying clock.