mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Merge pull request #3732 from UselessToucan/notify_track_completion_failure
Use `Track.Completed` event
This commit is contained in:
@ -28,6 +28,7 @@ namespace osu.Game.Audio
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
track = GetTrack();
|
track = GetTrack();
|
||||||
|
track.Completed += Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -50,15 +51,6 @@ namespace osu.Game.Audio
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRunning => track?.IsRunning ?? false;
|
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;
|
private ScheduledDelegate startDelegate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -258,9 +258,6 @@ namespace osu.Game.Overlays
|
|||||||
progressBar.CurrentTime = track.CurrentTime;
|
progressBar.CurrentTime = track.CurrentTime;
|
||||||
|
|
||||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -315,13 +312,13 @@ namespace osu.Game.Overlays
|
|||||||
private WorkingBeatmap current;
|
private WorkingBeatmap current;
|
||||||
private TransformDirection? queuedDirection;
|
private TransformDirection? queuedDirection;
|
||||||
|
|
||||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
|
||||||
{
|
{
|
||||||
TransformDirection direction = TransformDirection.None;
|
TransformDirection direction = TransformDirection.None;
|
||||||
|
|
||||||
if (current != null)
|
if (current != null)
|
||||||
{
|
{
|
||||||
bool audioEquals = e.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
|
bool audioEquals = beatmap.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
|
||||||
|
|
||||||
if (audioEquals)
|
if (audioEquals)
|
||||||
direction = TransformDirection.None;
|
direction = TransformDirection.None;
|
||||||
@ -334,13 +331,18 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
//figure out the best direction based on order in playlist.
|
//figure out the best direction based on order in playlist.
|
||||||
var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
|
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;
|
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;
|
progressBar.CurrentTime = 0;
|
||||||
|
|
||||||
@ -349,6 +351,12 @@ namespace osu.Game.Overlays
|
|||||||
queuedDirection = null;
|
queuedDirection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void currentTrackCompleted()
|
||||||
|
{
|
||||||
|
if (!beatmap.Disabled && beatmapSets.Any())
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
private ScheduledDelegate pendingBeatmapSwitch;
|
private ScheduledDelegate pendingBeatmapSwitch;
|
||||||
|
|
||||||
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
||||||
|
Reference in New Issue
Block a user