mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Refactor track transferring logic for ability to override and disallow
This commit is contained in:
parent
64a371638e
commit
c78d90ccbd
@ -126,11 +126,19 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transfer a valid audio track into this working beatmap. Used as an optimisation to avoid reload / track swap
|
/// Attempts to transfer the audio track to a target working beatmap, if valid for transferring.
|
||||||
/// across difficulties in the same beatmap set.
|
/// Used as an optimisation to avoid reload / track swap across difficulties in the same beatmap set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="track">The track to transfer.</param>
|
/// <param name="target">The target working beatmap to transfer this track to.</param>
|
||||||
public void TransferTrack([NotNull] Track track) => this.track = track ?? throw new ArgumentNullException(nameof(track));
|
/// <returns>Whether the track is valid and has been transferred to this working beatmap.</returns>
|
||||||
|
public virtual bool TryTransferTrack([NotNull] WorkingBeatmap target)
|
||||||
|
{
|
||||||
|
if (BeatmapInfo?.AudioEquals(target.BeatmapInfo) != true)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
target.track = track;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called.
|
/// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called.
|
||||||
|
@ -290,15 +290,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
current = newWorking;
|
current = newWorking;
|
||||||
|
|
||||||
if (!audioEquals || CurrentTrack.IsDummyDevice)
|
if (lastWorking == null || !lastWorking.TryTransferTrack(current))
|
||||||
{
|
|
||||||
changeTrack();
|
changeTrack();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// transfer still valid track to new working beatmap
|
|
||||||
current.TransferTrack(lastWorking.Track);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackChanged?.Invoke(current, direction);
|
TrackChanged?.Invoke(current, direction);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user