1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:22:54 +08:00

Remove MusicController from EditorClock

This commit is contained in:
smoogipoo 2020-08-06 18:19:55 +09:00
parent f53672193e
commit c8ebbc8594
3 changed files with 13 additions and 30 deletions

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -59,9 +58,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
return;
float markerPos = Math.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
Debug.Assert(editorClock.TrackLength != null);
editorClock.SeekTo(markerPos / DrawWidth * editorClock.TrackLength.Value);
editorClock.SeekTo(markerPos / DrawWidth * editorClock.TrackLength);
});
}

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Edit
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
var sourceClock = (IAdjustableClock)musicController.CurrentTrack ?? new StopwatchClock();
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
clock = new EditorClock(Beatmap.Value, musicController.CurrentTrack?.Length ?? 0, beatDivisor) { IsCoupled = false };
clock.ChangeSource(sourceClock);
dependencies.CacheAs(clock);

View File

@ -2,16 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Overlays;
namespace osu.Game.Screens.Edit
{
@ -20,7 +17,7 @@ namespace osu.Game.Screens.Edit
/// </summary>
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
{
public double? TrackLength { get; private set; }
public readonly double TrackLength;
public ControlPointInfo ControlPointInfo;
@ -28,34 +25,24 @@ namespace osu.Game.Screens.Edit
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
[Resolved]
private MusicController musicController { get; set; }
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
: this(beatmap.Beatmap.ControlPointInfo, null, beatDivisor)
public EditorClock(WorkingBeatmap beatmap, double trackLength, BindableBeatDivisor beatDivisor)
: this(beatmap.Beatmap.ControlPointInfo, trackLength, beatDivisor)
{
}
public EditorClock(ControlPointInfo controlPointInfo, double? trackLength, BindableBeatDivisor beatDivisor)
{
this.beatDivisor = beatDivisor;
ControlPointInfo = controlPointInfo;
TrackLength = trackLength;
underlyingClock = new DecoupleableInterpolatingFramedClock();
}
public EditorClock()
: this(new ControlPointInfo(), 1000, new BindableBeatDivisor())
{
}
[BackgroundDependencyLoader]
private void load()
public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor)
{
// Todo: What.
TrackLength ??= musicController.CurrentTrack?.Length ?? 0;
this.beatDivisor = beatDivisor;
ControlPointInfo = controlPointInfo;
TrackLength = trackLength;
underlyingClock = new DecoupleableInterpolatingFramedClock();
}
/// <summary>
@ -148,8 +135,7 @@ namespace osu.Game.Screens.Edit
seekTime = timingPoint.Time;
// Ensure the sought point is within the boundaries
Debug.Assert(TrackLength != null);
seekTime = Math.Clamp(seekTime, 0, TrackLength.Value);
seekTime = Math.Clamp(seekTime, 0, TrackLength);
SeekTo(seekTime);
}