1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 05:22:54 +08:00

Merge pull request #3732 from UselessToucan/notify_track_completion_failure

Use `Track.Completed` event
This commit is contained in:
Dean Herbert 2019-02-25 20:48:03 +09:00 committed by GitHub
commit d6cfce8bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -28,6 +28,7 @@ namespace osu.Game.Audio
private void load()
{
track = GetTrack();
track.Completed += Stop;
}
/// <summary>
@ -50,15 +51,6 @@ namespace osu.Game.Audio
/// </summary>
public bool IsRunning => track?.IsRunning ?? false;
protected override void Update()
{
base.Update();
// Todo: Track currently doesn't signal its completion, so we have to handle it manually
if (hasStarted && track.HasCompleted)
Stop();
}
private ScheduledDelegate startDelegate;
/// <summary>

View File

@ -258,9 +258,6 @@ namespace osu.Game.Overlays
progressBar.CurrentTime = track.CurrentTime;
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
if (track.HasCompleted && !track.Looping && !beatmap.Disabled && beatmapSets.Any())
next();
}
else
{
@ -315,13 +312,13 @@ namespace osu.Game.Overlays
private WorkingBeatmap current;
private TransformDirection? queuedDirection;
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
{
TransformDirection direction = TransformDirection.None;
if (current != null)
{
bool audioEquals = e.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
bool audioEquals = beatmap.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
if (audioEquals)
direction = TransformDirection.None;
@ -334,13 +331,18 @@ namespace osu.Game.Overlays
{
//figure out the best direction based on order in playlist.
var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
var next = beatmap == null ? -1 : beatmapSets.TakeWhile(b => b.ID != e.NewValue.BeatmapSetInfo?.ID).Count();
var next = beatmap.NewValue == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.NewValue.BeatmapSetInfo?.ID).Count();
direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
}
current.Track.Completed -= currentTrackCompleted;
}
current = e.NewValue;
current = beatmap.NewValue;
if (current != null)
current.Track.Completed += currentTrackCompleted;
progressBar.CurrentTime = 0;
@ -349,6 +351,12 @@ namespace osu.Game.Overlays
queuedDirection = null;
}
private void currentTrackCompleted()
{
if (!beatmap.Disabled && beatmapSets.Any())
next();
}
private ScheduledDelegate pendingBeatmapSwitch;
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)