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:
parent
420e50b6da
commit
dd9b9a18ac
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user