1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 00:42:55 +08:00

Merge branch 'master' into force-sort-objects

This commit is contained in:
Dean Herbert 2018-11-05 16:23:11 +09:00 committed by GitHub
commit 998a540cf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()