Fix MusicActionHandler unnecessarily depending on OnScreenDisplay's existance

This commit is contained in:
Salman Ahmed 2020-09-06 01:54:08 +03:00
parent b8e5acfef1
commit 33b76015d8

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Music
[Resolved] [Resolved]
private MusicController musicController { get; set; } private MusicController musicController { get; set; }
[Resolved] [Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; } private OnScreenDisplay onScreenDisplay { get; set; }
public bool OnPressed(GlobalAction action) public bool OnPressed(GlobalAction action)
@ -34,14 +34,14 @@ namespace osu.Game.Overlays.Music
{ {
case GlobalAction.MusicPlay: case GlobalAction.MusicPlay:
if (musicController.TogglePause()) if (musicController.TogglePause())
onScreenDisplay.Display(new MusicActionToast(musicController.IsPlaying ? "Play track" : "Pause track")); onScreenDisplay?.Display(new MusicActionToast(musicController.IsPlaying ? "Play track" : "Pause track"));
return true; return true;
case GlobalAction.MusicNext: case GlobalAction.MusicNext:
musicController.NextTrack(() => musicController.NextTrack(() =>
{ {
onScreenDisplay.Display(new MusicActionToast("Next track")); onScreenDisplay?.Display(new MusicActionToast("Next track"));
}).RunTask(); }).RunTask();
return true; return true;
@ -52,11 +52,11 @@ namespace osu.Game.Overlays.Music
switch (res) switch (res)
{ {
case PreviousTrackResult.Restart: case PreviousTrackResult.Restart:
onScreenDisplay.Display(new MusicActionToast("Restart track")); onScreenDisplay?.Display(new MusicActionToast("Restart track"));
break; break;
case PreviousTrackResult.Previous: case PreviousTrackResult.Previous:
onScreenDisplay.Display(new MusicActionToast("Previous track")); onScreenDisplay?.Display(new MusicActionToast("Previous track"));
break; break;
} }
}).RunTask(); }).RunTask();