From fead1d4c6f423183a5f5536b094656a11e2d6dde Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 25 Oct 2016 09:18:47 +0800 Subject: [PATCH] Seek by clicking and dragging on progress bar. --- osu.Game/Overlays/MusicController.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 74c3d3392b..4d83070ef5 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -247,6 +247,28 @@ namespace osu.Game.Overlays return scaledSprite; } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + trySeek(state); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseMove(InputState state) + { + trySeek(state); + return base.OnMouseMove(state); + } + + private void trySeek(InputState state) + { + if (state.Mouse.LeftButton) + { + Vector2 pos = GetLocalPosition(state.Mouse.NativeState.Position); + if (pos.Y > 120) + CurrentTrack?.Seek(CurrentTrack.Length * pos.X / 400f); + } + } + //placeholder for toggling protected override void PopIn() => FadeIn(500);