mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 16:27:20 +08:00
Re-route editor tempo adjustment via EditorClock
and remove it on gameplay test
This commit is contained in:
parent
3c03406b45
commit
a5036cd092
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
@ -75,7 +76,7 @@ namespace osu.Game.Screens.Edit.Components
|
||||
}
|
||||
};
|
||||
|
||||
Track.BindValueChanged(tr => tr.NewValue?.AddAdjustment(AdjustableProperty.Tempo, tempoAdjustment), true);
|
||||
editorClock.AudioAdjustments.AddAdjustment(AdjustableProperty.Tempo, tempoAdjustment);
|
||||
|
||||
if (editor != null)
|
||||
currentScreenMode.BindTo(editor.Mode);
|
||||
@ -105,7 +106,8 @@ namespace osu.Game.Screens.Edit.Components
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Track.Value?.RemoveAdjustment(AdjustableProperty.Tempo, tempoAdjustment);
|
||||
if (editorClock.IsNotNull())
|
||||
editorClock.AudioAdjustments.RemoveAdjustment(AdjustableProperty.Tempo, tempoAdjustment);
|
||||
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
@ -861,6 +861,7 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
base.OnResuming(e);
|
||||
dimBackground();
|
||||
clock.BindAdjustments();
|
||||
}
|
||||
|
||||
private void dimBackground()
|
||||
@ -925,6 +926,10 @@ namespace osu.Game.Screens.Edit
|
||||
base.OnSuspending(e);
|
||||
clock.Stop();
|
||||
refetchBeatmap();
|
||||
// unfortunately ordering matters here.
|
||||
// this unbind MUST happen after `refetchBeatmap()`, because along other things, `refetchBeatmap()` causes a global working beatmap change,
|
||||
// which causes `EditorClock` to reload the track and automatically reapply adjustments to it.
|
||||
clock.UnbindAdjustments();
|
||||
}
|
||||
|
||||
private void refetchBeatmap()
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -29,6 +30,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public double TrackLength => track.Value?.IsLoaded == true ? track.Value.Length : 60000;
|
||||
|
||||
public AudioAdjustments AudioAdjustments { get; } = new AudioAdjustments();
|
||||
|
||||
public ControlPointInfo ControlPointInfo => Beatmap.ControlPointInfo;
|
||||
|
||||
public IBeatmap Beatmap { get; set; }
|
||||
@ -208,7 +211,16 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSpeedAdjustments() => underlyingClock.ResetSpeedAdjustments();
|
||||
public void BindAdjustments() => track.Value?.BindAdjustments(AudioAdjustments);
|
||||
|
||||
public void UnbindAdjustments() => track.Value?.UnbindAdjustments(AudioAdjustments);
|
||||
|
||||
public void ResetSpeedAdjustments()
|
||||
{
|
||||
AudioAdjustments.RemoveAllAdjustments(AdjustableProperty.Frequency);
|
||||
AudioAdjustments.RemoveAllAdjustments(AdjustableProperty.Tempo);
|
||||
underlyingClock.ResetSpeedAdjustments();
|
||||
}
|
||||
|
||||
double IAdjustableClock.Rate
|
||||
{
|
||||
@ -231,8 +243,12 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public void ChangeSource(IClock source)
|
||||
{
|
||||
UnbindAdjustments();
|
||||
|
||||
track.Value = source as Track;
|
||||
underlyingClock.ChangeSource(source);
|
||||
|
||||
BindAdjustments();
|
||||
}
|
||||
|
||||
public IClock Source => underlyingClock.Source;
|
||||
|
Loading…
x
Reference in New Issue
Block a user