mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 08:27:23 +08:00
Merge pull request #31445 from bdach/reset-speed-on-test-play
Reset playback speed to 100% on entering test play
This commit is contained in:
commit
f216c22806
@ -19,6 +19,7 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -127,6 +128,35 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayTestResetsPlaybackSpeedAdjustment()
|
||||
{
|
||||
AddStep("start track", () => EditorClock.Start());
|
||||
AddStep("change playback speed", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<PlaybackControl.PlaybackTabControl.PlaybackTabItem>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("track playback rate is 0.25x", () => Beatmap.Value.Track.AggregateTempo.Value, () => Is.EqualTo(0.25));
|
||||
|
||||
AddStep("click test gameplay button", () =>
|
||||
{
|
||||
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
AddAssert("editor track stopped", () => !EditorClock.IsRunning);
|
||||
AddAssert("track playback rate is 1x", () => Beatmap.Value.Track.AggregateTempo.Value, () => Is.EqualTo(1));
|
||||
|
||||
AddStep("exit player", () => editorPlayer.Exit());
|
||||
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||
AddAssert("track playback rate is 0.25x", () => Beatmap.Value.Track.AggregateTempo.Value, () => Is.EqualTo(0.25));
|
||||
}
|
||||
|
||||
[TestCase(2000)] // chosen to be after last object in the map
|
||||
[TestCase(22000)] // chosen to be in the middle of the last spinner
|
||||
public void TestGameplayTestAtEndOfBeatmap(int offsetFromEnd)
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -18,8 +17,6 @@ namespace osu.Game.Screens.Edit.Components
|
||||
|
||||
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
protected readonly IBindable<Track> Track = new Bindable<Track>();
|
||||
|
||||
public readonly Drawable Background;
|
||||
private readonly Container content;
|
||||
|
||||
@ -45,10 +42,9 @@ namespace osu.Game.Screens.Edit.Components
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, EditorClock clock)
|
||||
private void load(IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
Beatmap.BindTo(beatmap);
|
||||
Track.BindTo(clock.Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
@ -148,7 +150,7 @@ namespace osu.Game.Screens.Edit.Components
|
||||
public LocalisableString TooltipText { get; set; }
|
||||
}
|
||||
|
||||
private partial class PlaybackTabControl : OsuTabControl<double>
|
||||
public partial class PlaybackTabControl : OsuTabControl<double>
|
||||
{
|
||||
private static readonly double[] tempo_values = { 0.25, 0.5, 0.75, 1 };
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osuTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -26,7 +26,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
[Resolved]
|
||||
protected EditorBeatmap EditorBeatmap { get; private set; } = null!;
|
||||
|
||||
protected readonly IBindable<Track> Track = new Bindable<Track>();
|
||||
[Resolved]
|
||||
private EditorClock editorClock { get; set; } = null!;
|
||||
|
||||
private readonly Container<T> content;
|
||||
|
||||
@ -35,22 +36,17 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
public TimelinePart(Container<T>? content = null)
|
||||
{
|
||||
AddInternal(this.content = content ?? new Container<T> { RelativeSizeAxes = Axes.Both });
|
||||
|
||||
beatmap.ValueChanged += _ =>
|
||||
{
|
||||
updateRelativeChildSize();
|
||||
};
|
||||
|
||||
Track.ValueChanged += _ => updateRelativeChildSize();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, EditorClock clock)
|
||||
private void load(IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
this.beatmap.BindTo(beatmap);
|
||||
LoadBeatmap(EditorBeatmap);
|
||||
|
||||
Track.BindTo(clock.Track);
|
||||
this.beatmap.ValueChanged += _ => updateRelativeChildSize();
|
||||
editorClock.TrackChanged += updateRelativeChildSize;
|
||||
updateRelativeChildSize();
|
||||
}
|
||||
|
||||
private void updateRelativeChildSize()
|
||||
@ -68,5 +64,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
{
|
||||
content.Clear();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (editorClock.IsNotNull())
|
||||
editorClock.TrackChanged -= updateRelativeChildSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -49,6 +49,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[Resolved]
|
||||
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The timeline's scroll position in the last frame.
|
||||
/// </summary>
|
||||
@ -86,8 +89,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private double trackLengthForZoom;
|
||||
|
||||
private readonly IBindable<Track> track = new Bindable<Track>();
|
||||
|
||||
public Timeline(Drawable userContent)
|
||||
{
|
||||
this.userContent = userContent;
|
||||
@ -101,7 +102,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OverlayColourProvider colourProvider, OsuConfigManager config)
|
||||
private void load(OsuColour colours, OverlayColourProvider colourProvider, OsuConfigManager config)
|
||||
{
|
||||
CentreMarker centreMarker;
|
||||
|
||||
@ -150,16 +151,18 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
controlPointsVisible = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
||||
ticksVisible = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
||||
|
||||
track.BindTo(editorClock.Track);
|
||||
track.BindValueChanged(_ =>
|
||||
{
|
||||
waveform.Waveform = beatmap.Value.Waveform;
|
||||
Scheduler.AddOnce(applyVisualOffset, beatmap);
|
||||
}, true);
|
||||
editorClock.TrackChanged += updateWaveform;
|
||||
updateWaveform();
|
||||
|
||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.TimelineZoom);
|
||||
}
|
||||
|
||||
private void updateWaveform()
|
||||
{
|
||||
waveform.Waveform = beatmap.Value.Waveform;
|
||||
Scheduler.AddOnce(applyVisualOffset, beatmap);
|
||||
}
|
||||
|
||||
private void applyVisualOffset(IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
waveform.RelativePositionAxes = Axes.X;
|
||||
@ -334,5 +337,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
double time = TimeAtPosition(Content.ToLocalSpace(screenSpacePosition).X);
|
||||
return new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(time));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (editorClock.IsNotNull())
|
||||
editorClock.TrackChanged -= updateWaveform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,8 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -23,12 +25,15 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public partial class EditorClock : CompositeComponent, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||
{
|
||||
public IBindable<Track> Track => track;
|
||||
[CanBeNull]
|
||||
public event Action TrackChanged;
|
||||
|
||||
private readonly Bindable<Track> track = new Bindable<Track>();
|
||||
|
||||
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; }
|
||||
@ -56,6 +61,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
underlyingClock = new FramedBeatmapClock(applyOffsets: true, requireDecoupling: true);
|
||||
AddInternal(underlyingClock);
|
||||
|
||||
track.BindValueChanged(_ => TrackChanged?.Invoke());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -208,7 +215,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 +247,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;
|
||||
|
@ -4,8 +4,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -305,7 +305,8 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||
|
||||
private readonly IBindable<Track> track = new Bindable<Track>();
|
||||
[Resolved]
|
||||
private EditorClock editorClock { get; set; } = null!;
|
||||
|
||||
public WaveformRow(bool isMainRow)
|
||||
{
|
||||
@ -313,7 +314,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(EditorClock clock)
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
@ -343,13 +344,16 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
Colour = colourProvider.Content2
|
||||
}
|
||||
};
|
||||
|
||||
track.BindTo(clock.Track);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
track.ValueChanged += _ => waveformGraph.Waveform = beatmap.Value.Waveform;
|
||||
editorClock.TrackChanged += updateWaveform;
|
||||
}
|
||||
|
||||
private void updateWaveform()
|
||||
{
|
||||
waveformGraph.Waveform = beatmap.Value.Waveform;
|
||||
}
|
||||
|
||||
public int BeatIndex { set => beatIndexText.Text = value.ToString(); }
|
||||
@ -363,6 +367,14 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
get => waveformGraph.X;
|
||||
set => waveformGraph.X = value;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (editorClock.IsNotNull())
|
||||
editorClock.TrackChanged -= updateWaveform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user