diff --git a/osu-framework b/osu-framework index eb076a3301..a191c104b8 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit eb076a3301231eb73917073499051e49a9b12978 +Subproject commit a191c104b8e254e81a1a7bb1c200ccdf02628796 diff --git a/osu.Game.Tests/Visual/TestCaseQuitButton.cs b/osu.Game.Tests/Visual/TestCaseQuitButton.cs index f0f8d41074..c2ddc5fef5 100644 --- a/osu.Game.Tests/Visual/TestCaseQuitButton.cs +++ b/osu.Game.Tests/Visual/TestCaseQuitButton.cs @@ -44,13 +44,13 @@ namespace osu.Game.Tests.Visual { exitAction = false; InputManager.MoveMouseTo(quitButton); - InputManager.ButtonDown(MouseButton.Left); + InputManager.PressButton(MouseButton.Left); }); - AddStep("Early release", () => InputManager.ButtonUp(MouseButton.Left)); + AddStep("Early release", () => InputManager.ReleaseButton(MouseButton.Left)); AddAssert("action not triggered", () => !exitAction); - AddStep("Trigger exit action", () => InputManager.ButtonDown(MouseButton.Left)); + AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left)); AddUntilStep(() => exitAction, $"{nameof(quitButton.Action)} was triggered"); } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index b657fe5597..be08fffc77 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit { // TODO: should probably be done at a RulesetContainer level to share logic with Player. var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock(); - clock = new EditorClock(Beatmap.Value.Beatmap.ControlPointInfo, beatDivisor) { IsCoupled = false }; + clock = new EditorClock(Beatmap, beatDivisor) { IsCoupled = false }; clock.ChangeSource(sourceClock); dependencies.CacheAs(clock); diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 67025f0620..72fb91e7df 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -3,10 +3,13 @@ using System; using System.Linq; +using osu.Framework.Configuration; using osu.Framework.MathUtils; using osu.Framework.Timing; +using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Screens.Edit.Screens.Compose; +using OpenTK; namespace osu.Game.Screens.Edit { @@ -15,15 +18,26 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { + public readonly double TrackLength; + public ControlPointInfo ControlPointInfo; private readonly BindableBeatDivisor beatDivisor; - public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor) + public EditorClock(Bindable beatmap, BindableBeatDivisor beatDivisor) + { + this.beatDivisor = beatDivisor; + + ControlPointInfo = beatmap.Value.Beatmap.ControlPointInfo; + TrackLength = beatmap.Value.Track.Length; + } + + public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; ControlPointInfo = controlPointInfo; + TrackLength = trackLength; } /// @@ -111,6 +125,8 @@ namespace osu.Game.Screens.Edit if (seekTime > nextTimingPoint?.Time) seekTime = nextTimingPoint.Time; + // Ensure the sought point is within the boundaries + seekTime = MathHelper.Clamp(seekTime, 0, TrackLength); Seek(seekTime); } } diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 43b20f7021..85d3684530 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual protected EditorClockTestCase() { - Clock = new EditorClock(new ControlPointInfo(), BeatDivisor) { IsCoupled = false }; + Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false }; } [BackgroundDependencyLoader]