From dd9b9a18ac4571ffda22f5b883452d16dbabcc66 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 8 May 2018 16:21:54 +0300 Subject: [PATCH 1/6] Prevent user from scrolling outside the timeline in the editor --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index adb749b492..0e0f3fa9f1 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -47,7 +47,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..02bf581716 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -3,8 +3,10 @@ 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; @@ -15,10 +17,20 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { + public Bindable Beatmap = new Bindable(); + public ControlPointInfo ControlPointInfo; private readonly BindableBeatDivisor beatDivisor; + public EditorClock(Bindable beatmap, BindableBeatDivisor beatDivisor) + { + this.beatDivisor = beatDivisor; + + Beatmap.BindTo(beatmap); + + ControlPointInfo = Beatmap.Value.Beatmap.ControlPointInfo; + } public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; @@ -111,6 +123,7 @@ namespace osu.Game.Screens.Edit if (seekTime > nextTimingPoint?.Time) seekTime = nextTimingPoint.Time; + seekTime = Math.Min(Math.Max(0, seekTime), Beatmap.Value.Track.Length); // Ensure the sought point is within the song's length Seek(seekTime); } } From e44062b77a54e792fdcb84fd1c9379cec473aafc Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 8 May 2018 16:37:06 +0300 Subject: [PATCH 2/6] Fix tests and implementation --- osu.Game/Screens/Edit/EditorClock.cs | 15 +++++++++------ osu.Game/Tests/Visual/EditorClockTestCase.cs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 02bf581716..88d8477233 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -17,7 +17,9 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { - public Bindable Beatmap = new Bindable(); + //public Bindable Beatmap = new Bindable(); + + public double TrackLength; public ControlPointInfo ControlPointInfo; @@ -27,15 +29,15 @@ namespace osu.Game.Screens.Edit { this.beatDivisor = beatDivisor; - Beatmap.BindTo(beatmap); - - ControlPointInfo = Beatmap.Value.Beatmap.ControlPointInfo; + ControlPointInfo = beatmap.Value.Beatmap.ControlPointInfo; + TrackLength = beatmap.Value.Track.Length; } - public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor) + public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; ControlPointInfo = controlPointInfo; + TrackLength = trackLength; } /// @@ -123,7 +125,8 @@ namespace osu.Game.Screens.Edit if (seekTime > nextTimingPoint?.Time) seekTime = nextTimingPoint.Time; - seekTime = Math.Min(Math.Max(0, seekTime), Beatmap.Value.Track.Length); // Ensure the sought point is within the song's length + // Ensure the sought point is within the boundaries + seekTime = Math.Min(Math.Max(0, seekTime), 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] From 2a90686da622cbf9d6619bb787e3cc370de07906 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Sat, 12 May 2018 15:09:53 +0300 Subject: [PATCH 3/6] Simplify expression --- osu-framework | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 0773d895d9..e793a08417 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 0773d895d9aa0729995cd4a23efc28238e35ceed +Subproject commit e793a084177f53920645c4f6f70cfef91e7fd19e diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 88d8477233..6cae4d9187 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -9,6 +9,7 @@ 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 { @@ -126,7 +127,7 @@ namespace osu.Game.Screens.Edit seekTime = nextTimingPoint.Time; // Ensure the sought point is within the boundaries - seekTime = Math.Min(Math.Max(0, seekTime), TrackLength); + seekTime = MathHelper.Clamp(seekTime, 0, TrackLength); Seek(seekTime); } } From 6f94c110a56e975c74417548efbc9841e67c6315 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Thu, 17 May 2018 23:09:13 +0300 Subject: [PATCH 4/6] Fix submodule conflict --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index e793a08417..fac688633b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e793a084177f53920645c4f6f70cfef91e7fd19e +Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 From a54bda6ce1f15c98643014534e1be914834fa2ae Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Mon, 21 May 2018 13:23:39 +0300 Subject: [PATCH 5/6] Apply requested changes --- osu-framework | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu-framework b/osu-framework index fac688633b..80e78fd45b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 +Subproject commit 80e78fd45bb79ca4bc46ecc05deb6058f3879faa diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 6cae4d9187..72fb91e7df 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -18,9 +18,7 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { - //public Bindable Beatmap = new Bindable(); - - public double TrackLength; + public readonly double TrackLength; public ControlPointInfo ControlPointInfo; @@ -33,6 +31,7 @@ namespace osu.Game.Screens.Edit ControlPointInfo = beatmap.Value.Beatmap.ControlPointInfo; TrackLength = beatmap.Value.Track.Length; } + public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; From 897767008839c64e56d29d92c4e19cdb85ab962d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 19:08:46 +0900 Subject: [PATCH 6/6] Update framework --- osu-framework | 2 +- osu.Game.Tests/Visual/TestCaseQuitButton.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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"); } }