1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

Fix hit samples playing while paused / seeking in the editor

This commit is contained in:
Dean Herbert 2020-09-28 18:16:19 +09:00
parent 2f5a2d3bba
commit 4f0c0ea5f9
5 changed files with 37 additions and 5 deletions

View File

@ -360,7 +360,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
private ISeekableClock seekableClock { get; set; }
/// <summary>
/// Calculate the position to be used for sample playback at a specified X position (0..1).
@ -377,7 +377,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <summary>
/// Whether samples should currently be playing. Will be false during seek operations.
/// </summary>
protected bool ShouldPlaySamples => gameplayClock?.IsSeeking != true;
protected bool ShouldPlaySamples => seekableClock?.IsSeeking != true;
/// <summary>
/// Plays all the hit sounds for this <see cref="DrawableHitObject"/>.

View File

@ -107,6 +107,7 @@ namespace osu.Game.Screens.Edit
UpdateClockSource();
dependencies.CacheAs(clock);
dependencies.CacheAs<ISeekableClock>(clock);
AddInternal(clock);
// todo: remove caching of this and consume via editorBeatmap?

View File

@ -7,17 +7,18 @@ using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.Edit
{
/// <summary>
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
/// </summary>
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock, ISeekableClock
{
public IBindable<Track> Track => track;
@ -211,8 +212,25 @@ namespace osu.Game.Screens.Edit
private const double transform_time = 300;
public bool IsSeeking { get; private set; }
protected override void Update()
{
base.Update();
if (IsSeeking)
{
// we are either running a seek tween or doing an immediate seek.
// in the case of an immediate seek the seeking bool will be set to false after one update.
// this allows for silencing hit sounds and the likes.
IsSeeking = Transforms.Any();
}
}
public void SeekTo(double seekDestination)
{
IsSeeking = true;
if (IsRunning)
Seek(seekDestination);
else

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
/// </remarks>
/// </summary>
public class GameplayClock : IFrameBasedClock
public class GameplayClock : IFrameBasedClock, ISeekableClock
{
private readonly IFrameBasedClock underlyingClock;

View File

@ -0,0 +1,13 @@
// 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.
namespace osu.Game.Screens.Play
{
public interface ISeekableClock
{
/// <summary>
/// Whether an ongoing seek operation is active.
/// </summary>
bool IsSeeking { get; }
}
}