1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 20:05:29 +08:00

Prevent user from scrolling outside the timeline in the editor

This commit is contained in:
AlFasGD 2018-05-08 16:21:54 +03:00
parent 420e50b6da
commit dd9b9a18ac
2 changed files with 14 additions and 1 deletions

View File

@ -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<IFrameBasedClock>(clock);

View File

@ -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
/// </summary>
public class EditorClock : DecoupleableInterpolatingFramedClock
{
public Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
public ControlPointInfo ControlPointInfo;
private readonly BindableBeatDivisor beatDivisor;
public EditorClock(Bindable<WorkingBeatmap> 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);
}
}