1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 15:23:14 +08:00

Debounce editor summary timeline seeks

This commit is contained in:
smoogipoo 2018-11-05 15:59:40 +09:00
parent 5cba0942db
commit 171700cb91

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -43,17 +44,23 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
return true; return true;
} }
private ScheduledDelegate scheduledSeek;
/// <summary> /// <summary>
/// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>. /// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>.
/// </summary> /// </summary>
/// <param name="screenPosition">The position in screen coordinates.</param> /// <param name="screenPosition">The position in screen coordinates.</param>
private void seekToPosition(Vector2 screenPosition) private void seekToPosition(Vector2 screenPosition)
{ {
if (Beatmap.Value == null) scheduledSeek?.Cancel();
return; scheduledSeek = Schedule(() =>
{
if (Beatmap.Value == null)
return;
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth); float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length); adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
});
} }
protected override void Update() protected override void Update()