Skip to content

Commit

Permalink
Add editor track traversal keys (Z-V)
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed May 13, 2022
1 parent 8edbc10 commit c4871eb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Edit.Components.Menus;
using osu.Game.Screens.Edit.Components.Timelines.Summary;
Expand Down Expand Up @@ -475,6 +476,44 @@ protected override bool OnKeyDown(KeyDownEvent e)
case Key.Right:
seek(e, 1);
return true;

// Track traversal keys.
// Matching osu-stable implementations.
case Key.Z:
// Seek to first object time, or track start if already there.
double? firstObjectTime = editorBeatmap.HitObjects.FirstOrDefault()?.StartTime;

if (firstObjectTime == null || clock.CurrentTime == firstObjectTime)
clock.Seek(0);
else
clock.Seek(firstObjectTime.Value);
return true;

case Key.X:
// Restart playback from beginning of track.
clock.Seek(0);
clock.Start();
return true;

case Key.C:
// Pause or resume.
if (clock.IsRunning)
clock.Stop();
else
clock.Start();
return true;

case Key.V:
// Seek to last object time, or track end if already there.
// Note that in osu-stable subsequent presses when at track end won't return to last object.
// This has intentionally been changed to make it more useful.
double? lastObjectTime = editorBeatmap.HitObjects.LastOrDefault()?.GetEndTime();

if (lastObjectTime == null || clock.CurrentTime == lastObjectTime)
clock.Seek(clock.TrackLength);
else
clock.Seek(lastObjectTime.Value);
return true;
}

return base.OnKeyDown(e);
Expand Down

0 comments on commit c4871eb

Please sign in to comment.