1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

Merge branch 'master' into triangle-button-v2

This commit is contained in:
Bartłomiej Dach 2022-11-25 18:35:59 +01:00
commit 73176a1315
No known key found for this signature in database
2 changed files with 40 additions and 0 deletions

View File

@ -25,6 +25,7 @@ namespace osu.Game.Tests.Visual.Editing
beatmap.ControlPointInfo.Clear();
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 });
beatmap.ControlPointInfo.Add(2000, new TimingControlPoint { BeatLength = 500 });
beatmap.ControlPointInfo.Add(20000, new TimingControlPoint { BeatLength = 500 });
return beatmap;
}
@ -116,6 +117,26 @@ namespace osu.Game.Tests.Visual.Editing
pressAndCheckTime(Key.Right, 3000);
}
[Test]
public void TestSeekBetweenControlPoints()
{
AddStep("seek to 0", () => EditorClock.Seek(0));
AddAssert("time is 0", () => EditorClock.CurrentTime == 0);
// already at first control point, noop
pressAndCheckTime(Key.Up, 0);
pressAndCheckTime(Key.Down, 2000);
pressAndCheckTime(Key.Down, 20000);
// at last control point, noop
pressAndCheckTime(Key.Down, 20000);
pressAndCheckTime(Key.Up, 2000);
pressAndCheckTime(Key.Up, 0);
pressAndCheckTime(Key.Up, 0);
}
private void pressAndCheckTime(Key key, double expectedTime)
{
AddStep($"press {key}", () => InputManager.Key(key));

View File

@ -499,6 +499,15 @@ namespace osu.Game.Screens.Edit
seek(e, 1);
return true;
// Of those, these two keys are reversed from stable because it feels more natural (and matches mouse wheel scroll directionality).
case Key.Up:
seekControlPoint(-1);
return true;
case Key.Down:
seekControlPoint(1);
return true;
// Track traversal keys.
// Matching osu-stable implementations.
case Key.Z:
@ -892,6 +901,16 @@ namespace osu.Game.Screens.Edit
}
}
private void seekControlPoint(int direction)
{
var found = direction < 1
? editorBeatmap.ControlPointInfo.AllControlPoints.LastOrDefault(p => p.Time < clock.CurrentTime)
: editorBeatmap.ControlPointInfo.AllControlPoints.FirstOrDefault(p => p.Time > clock.CurrentTime);
if (found != null)
clock.Seek(found.Time);
}
private void seek(UIEvent e, int direction)
{
double amount = e.ShiftPressed ? 4 : 1;