Use bindable for track to fix rate adjustments not applying correctly

This commit is contained in:
Dean Herbert 2020-09-24 19:01:28 +09:00
parent 978f6edf38
commit 7e7e2fd64a
3 changed files with 14 additions and 7 deletions

View File

@ -18,7 +18,8 @@ namespace osu.Game.Screens.Edit.Components
private const float contents_padding = 15; private const float contents_padding = 15;
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>(); protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
protected Track Track => Beatmap.Value.Track;
protected readonly IBindable<Track> Track = new Bindable<Track>();
private readonly Drawable background; private readonly Drawable background;
private readonly Container content; private readonly Container content;
@ -42,9 +43,11 @@ namespace osu.Game.Screens.Edit.Components
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours) private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, EditorClock clock)
{ {
Beatmap.BindTo(beatmap); Beatmap.BindTo(beatmap);
Track.BindTo(clock.Track);
background.Colour = colours.Gray1; background.Colour = colours.Gray1;
} }
} }

View File

@ -62,12 +62,12 @@ namespace osu.Game.Screens.Edit.Components
} }
}; };
Track?.AddAdjustment(AdjustableProperty.Tempo, tempo); Track.BindValueChanged(tr => tr.NewValue?.AddAdjustment(AdjustableProperty.Tempo, tempo), true);
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
Track?.RemoveAdjustment(AdjustableProperty.Tempo, tempo); Track.Value?.RemoveAdjustment(AdjustableProperty.Tempo, tempo);
base.Dispose(isDisposing); base.Dispose(isDisposing);
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.Transforms;
using osu.Framework.Utils; using osu.Framework.Utils;
@ -18,7 +19,11 @@ namespace osu.Game.Screens.Edit
/// </summary> /// </summary>
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
{ {
public double TrackLength; public IBindable<Track> Track => track;
private readonly Bindable<Track> track = new Bindable<Track>();
public double TrackLength => track.Value?.Length ?? 60000;
public ControlPointInfo ControlPointInfo; public ControlPointInfo ControlPointInfo;
@ -36,7 +41,6 @@ namespace osu.Game.Screens.Edit
this.beatDivisor = beatDivisor; this.beatDivisor = beatDivisor;
ControlPointInfo = controlPointInfo; ControlPointInfo = controlPointInfo;
TrackLength = trackLength;
underlyingClock = new DecoupleableInterpolatingFramedClock(); underlyingClock = new DecoupleableInterpolatingFramedClock();
} }
@ -193,8 +197,8 @@ namespace osu.Game.Screens.Edit
public void ChangeSource(IClock source) public void ChangeSource(IClock source)
{ {
track.Value = source as Track;
underlyingClock.ChangeSource(source); underlyingClock.ChangeSource(source);
TrackLength = (source as Track)?.Length ?? 60000;
} }
public IClock Source => underlyingClock.Source; public IClock Source => underlyingClock.Source;