mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into cinema-mod
This commit is contained in:
@ -28,9 +28,9 @@ namespace osu.Game.Screens.Play
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
|
||||
/// <summary>
|
||||
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
|
||||
/// The <see cref="WorkingBeatmap"/>'s track.
|
||||
/// </summary>
|
||||
private IAdjustableClock sourceClock;
|
||||
private Track track;
|
||||
|
||||
public readonly BindableBool IsPaused = new BindableBool();
|
||||
|
||||
@ -72,8 +72,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
sourceClock = (IAdjustableClock)beatmap.Track ?? new StopwatchClock();
|
||||
(sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
track = beatmap.Track;
|
||||
track.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
@ -127,11 +127,11 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
sourceClock.Reset();
|
||||
track.Reset();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
adjustableClock.ChangeSource(track);
|
||||
updateRate();
|
||||
|
||||
if (!IsPaused.Value)
|
||||
@ -197,13 +197,13 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public void StopUsingBeatmapClock()
|
||||
{
|
||||
if (sourceClock != beatmap.Track)
|
||||
if (track != beatmap.Track)
|
||||
return;
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
|
||||
sourceClock = new TrackVirtual(beatmap.Track.Length);
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
track = new TrackVirtual(beatmap.Track.Length);
|
||||
adjustableClock.ChangeSource(track);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -214,19 +214,19 @@ namespace osu.Game.Screens.Play
|
||||
base.Update();
|
||||
}
|
||||
|
||||
private bool speedAdjustmentsApplied;
|
||||
|
||||
private void updateRate()
|
||||
{
|
||||
if (sourceClock == null) return;
|
||||
if (track == null) return;
|
||||
|
||||
sourceClock.ResetSpeedAdjustments();
|
||||
speedAdjustmentsApplied = true;
|
||||
track.ResetSpeedAdjustments();
|
||||
|
||||
if (sourceClock is IHasTempoAdjust tempo)
|
||||
tempo.TempoAdjust = UserPlaybackRate.Value;
|
||||
else
|
||||
sourceClock.Rate = UserPlaybackRate.Value;
|
||||
track.Tempo.Value = UserPlaybackRate.Value;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(sourceClock);
|
||||
foreach (var mod in mods.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(track);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -234,13 +234,18 @@ namespace osu.Game.Screens.Play
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
sourceClock = null;
|
||||
track = null;
|
||||
}
|
||||
|
||||
private void removeSourceClockAdjustments()
|
||||
{
|
||||
sourceClock.ResetSpeedAdjustments();
|
||||
(sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
if (speedAdjustmentsApplied)
|
||||
{
|
||||
track.ResetSpeedAdjustments();
|
||||
speedAdjustmentsApplied = false;
|
||||
}
|
||||
|
||||
track.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -539,6 +539,12 @@ namespace osu.Game.Screens.Play
|
||||
return true;
|
||||
}
|
||||
|
||||
if (canPause)
|
||||
{
|
||||
Pause();
|
||||
return true;
|
||||
}
|
||||
|
||||
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
||||
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
||||
GameplayClockContainer.StopUsingBeatmapClock();
|
||||
|
@ -55,7 +55,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override bool PlayResumeSound => false;
|
||||
|
||||
private Task loadTask;
|
||||
protected Task LoadTask { get; private set; }
|
||||
|
||||
protected Task DisposalTask { get; private set; }
|
||||
|
||||
private InputManager inputManager;
|
||||
private IdleTracker idleTracker;
|
||||
@ -159,7 +161,7 @@ namespace osu.Game.Screens.Play
|
||||
player.RestartCount = restartCount;
|
||||
player.RestartRequested = restartRequested;
|
||||
|
||||
loadTask = LoadComponentAsync(player, _ => info.Loading = false);
|
||||
LoadTask = LoadComponentAsync(player, _ => info.Loading = false);
|
||||
}
|
||||
|
||||
private void contentIn()
|
||||
@ -250,7 +252,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
loadTask = null;
|
||||
LoadTask = null;
|
||||
|
||||
//By default, we want to load the player and never be returned to.
|
||||
//Note that this may change if the player we load requested a re-run.
|
||||
@ -301,7 +303,7 @@ namespace osu.Game.Screens.Play
|
||||
if (isDisposing)
|
||||
{
|
||||
// if the player never got pushed, we should explicitly dispose it.
|
||||
loadTask?.ContinueWith(_ => player.Dispose());
|
||||
DisposalTask = LoadTask?.ContinueWith(_ => player.Dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user