mirror of
https://github.com/ppy/osu.git
synced 2025-01-29 00:32:57 +08:00
Add helper methods for seeking/scrolling
This commit is contained in:
parent
6b0eeb3436
commit
a30f72b477
@ -68,12 +68,12 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
if (handlingDragInput)
|
if (handlingDragInput)
|
||||||
{
|
{
|
||||||
// The user is dragging - the track should always follow the timeline
|
// The user is dragging - the track should always follow the timeline
|
||||||
adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
seekTrackToCurrent();
|
||||||
}
|
}
|
||||||
else if (adjustableClock.IsRunning)
|
else if (adjustableClock.IsRunning)
|
||||||
{
|
{
|
||||||
// If the user hasn't provided mouse input but the track is running, always follow the track
|
// If the user hasn't provided mouse input but the track is running, always follow the track
|
||||||
ScrollTo((float)(adjustableClock.CurrentTime / Beatmap.Value.Track.Length) * Content.DrawWidth, false);
|
scrollToTrackTime();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -86,16 +86,19 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
if (adjustableClock.CurrentTime == lastTrackTime)
|
if (adjustableClock.CurrentTime == lastTrackTime)
|
||||||
{
|
{
|
||||||
// The track hasn't been seeked externally
|
// The track hasn't been seeked externally
|
||||||
adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
seekTrackToCurrent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The track has been seeked externally
|
// The track has been seeked externally
|
||||||
ScrollTo((float)(adjustableClock.CurrentTime / Beatmap.Value.Track.Length) * Content.DrawWidth, false);
|
scrollToTrackTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTrackTime = adjustableClock.CurrentTime;
|
lastTrackTime = adjustableClock.CurrentTime;
|
||||||
|
|
||||||
|
void seekTrackToCurrent() => adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
||||||
|
void scrollToTrackTime() => ScrollTo((float)(adjustableClock.CurrentTime / Beatmap.Value.Track.Length) * Content.DrawWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
Loading…
Reference in New Issue
Block a user