1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 11:27:24 +08:00

Apply reviews

This commit is contained in:
Ganendra Afrasya 2019-10-16 20:11:25 +07:00
parent 736a36a326
commit 326abc1a55

View File

@ -137,26 +137,21 @@ namespace osu.Game.Overlays
return true; return true;
} }
private PreviousButtonAction? prevAction;
/// <summary> /// <summary>
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/> /// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>
/// </summary> /// </summary>
/// <returns>Whether the operation was successful.</returns> /// <returns>Whether the operation was successful.</returns>
public bool PrevTrack() public PreviousButtonAction PrevTrack()
{ {
var currentTrackPosition = current?.Track.CurrentTime; var currentTrackPosition = current?.Track.CurrentTime;
if (currentTrackPosition >= restart_cutoff_point) if (currentTrackPosition >= restart_cutoff_point)
{ {
SeekTo(0); SeekTo(0);
prevAction = PreviousButtonAction.Restart; return PreviousButtonAction.Restart;
return true;
} }
queuedDirection = TrackChangeDirection.Prev; queuedDirection = TrackChangeDirection.Prev;
prevAction = PreviousButtonAction.Previous;
var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault(); var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault();
@ -166,10 +161,10 @@ namespace osu.Game.Overlays
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value); working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
beatmap.Value.Track.Restart(); beatmap.Value.Track.Restart();
return true; return PreviousButtonAction.Previous;
} }
return false; return PreviousButtonAction.None;
} }
/// <summary> /// <summary>
@ -275,10 +270,19 @@ namespace osu.Game.Overlays
return true; return true;
case GlobalAction.MusicPrev: case GlobalAction.MusicPrev:
if (PrevTrack()) switch (PrevTrack())
onScreenDisplay?.Display(new MusicControllerToast(prevAction == PreviousButtonAction.Restart ? "Restart track" : "Previous track")); {
case PreviousButtonAction.Restart:
onScreenDisplay?.Display(new MusicControllerToast("Restart track"));
return true; return true;
case PreviousButtonAction.Previous:
onScreenDisplay?.Display(new MusicControllerToast("Previous track"));
return true;
default:
return false;
}
} }
return false; return false;
@ -302,7 +306,7 @@ namespace osu.Game.Overlays
Prev Prev
} }
internal enum PreviousButtonAction public enum PreviousButtonAction
{ {
None, None,
Restart, Restart,