1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Make prev button can do restart track

This commit is contained in:
Ganendra Afrasya 2019-10-11 00:12:36 +07:00
parent c708ea327d
commit d7fc904381

View File

@ -136,11 +136,20 @@ namespace osu.Game.Overlays
}
/// <summary>
/// Play the previous track.
/// Play the previous track or restart the current track if it's current time below 5000ms
/// </summary>
/// <returns>Whether the operation was successful.</returns>
public bool PrevTrack()
{
var currentTrackPosition = current?.Track.CurrentTime;
if (currentTrackPosition >= 5000)
{
SeekTo(0);
return true;
}
queuedDirection = TrackChangeDirection.Prev;
var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault();
@ -260,8 +269,9 @@ namespace osu.Game.Overlays
return true;
case GlobalAction.MusicPrev:
var shouldRestart = current?.Track.CurrentTime >= 5000;
if (PrevTrack())
onScreenDisplay?.Display(new MusicControllerToast("Previous track"));
onScreenDisplay?.Display(new MusicControllerToast(shouldRestart ? "Restart track" : "Previous track"));
return true;
}