From c4871ebcf4eaf35b3fe804d74a86b95474410e3a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 14 May 2022 02:50:51 +0900 Subject: [PATCH] Add editor track traversal keys (`Z`-`V`) --- osu.Game/Screens/Edit/Editor.cs | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 947c184009..0fa9d4ef01 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -33,6 +33,7 @@ using osu.Game.Overlays.Notifications; 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; @@ -475,6 +476,44 @@ namespace osu.Game.Screens.Edit 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);