From 326abc1a55be865f4facf10766f5fe89a6a6864b Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Wed, 16 Oct 2019 20:11:25 +0700 Subject: [PATCH] Apply reviews --- osu.Game/Overlays/MusicController.cs | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 12de2019cb..812c4778dd 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -137,26 +137,21 @@ namespace osu.Game.Overlays return true; } - private PreviousButtonAction? prevAction; - /// /// Play the previous track or restart the current track if it's current time below /// /// Whether the operation was successful. - public bool PrevTrack() + public PreviousButtonAction PrevTrack() { var currentTrackPosition = current?.Track.CurrentTime; if (currentTrackPosition >= restart_cutoff_point) { SeekTo(0); - prevAction = PreviousButtonAction.Restart; - - return true; + return PreviousButtonAction.Restart; } queuedDirection = TrackChangeDirection.Prev; - prevAction = PreviousButtonAction.Previous; 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); beatmap.Value.Track.Restart(); - return true; + return PreviousButtonAction.Previous; } - return false; + return PreviousButtonAction.None; } /// @@ -275,10 +270,19 @@ namespace osu.Game.Overlays return true; case GlobalAction.MusicPrev: - if (PrevTrack()) - onScreenDisplay?.Display(new MusicControllerToast(prevAction == PreviousButtonAction.Restart ? "Restart track" : "Previous track")); + switch (PrevTrack()) + { + 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; @@ -302,7 +306,7 @@ namespace osu.Game.Overlays Prev } - internal enum PreviousButtonAction + public enum PreviousButtonAction { None, Restart,