Skip to content

Commit

Permalink
Refactor code to read better (and adjust lenience to match stable)
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 22, 2024
1 parent 5fe074a commit 16bc188
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,17 +1098,12 @@ private void updateSampleDisabledState()

private void seekControlPoint(int direction)
{
// Gives margin to seek back after last control point
double seekMargin = 0;

if (clock.IsRunning)
{
IAdjustableClock adjustableClock = clock;
seekMargin = 450 * adjustableClock.Rate;
}
// In the case of a backwards seek while playing, it can be hard to jump before a timing point.
// Adding some lenience here makes it more user-friendly.
double seekLenience = clock.IsRunning ? 1000 * ((IAdjustableClock)clock).Rate : 0;

var found = direction < 1
? editorBeatmap.ControlPointInfo.AllControlPoints.LastOrDefault(p => p.Time < clock.CurrentTime - seekMargin)
ControlPoint found = direction < 1
? editorBeatmap.ControlPointInfo.AllControlPoints.LastOrDefault(p => p.Time < clock.CurrentTime - seekLenience)
: editorBeatmap.ControlPointInfo.AllControlPoints.FirstOrDefault(p => p.Time > clock.CurrentTime);

if (found != null)
Expand Down

0 comments on commit 16bc188

Please sign in to comment.