1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 11:42:54 +08:00

Add music bindings to on screen display

This commit is contained in:
Joehu 2020-11-13 12:32:23 -08:00
parent ae1a5b8955
commit 2071cba944
2 changed files with 11 additions and 7 deletions

View File

@ -196,7 +196,7 @@ namespace osu.Game.Configuration
public Func<int, string> LookupSkinName { private get; set; }
public Func<GlobalAction, string> LookupKeyBindings { private get; set; }
public Func<GlobalAction, string> LookupKeyBindings { get; set; }
}
public enum OsuSetting

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.OSD;
@ -25,6 +26,9 @@ namespace osu.Game.Overlays.Music
[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }
[Resolved]
private OsuConfigManager config { get; set; }
public bool OnPressed(GlobalAction action)
{
if (beatmap.Disabled)
@ -37,11 +41,11 @@ namespace osu.Game.Overlays.Music
bool wasPlaying = musicController.IsPlaying;
if (musicController.TogglePause())
onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? "Pause track" : "Play track"));
onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? "Pause track" : "Play track", config.LookupKeyBindings(action)));
return true;
case GlobalAction.MusicNext:
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast("Next track")));
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast("Next track", config.LookupKeyBindings(action))));
return true;
@ -51,11 +55,11 @@ namespace osu.Game.Overlays.Music
switch (res)
{
case PreviousTrackResult.Restart:
onScreenDisplay?.Display(new MusicActionToast("Restart track"));
onScreenDisplay?.Display(new MusicActionToast("Restart track", config.LookupKeyBindings(action)));
break;
case PreviousTrackResult.Previous:
onScreenDisplay?.Display(new MusicActionToast("Previous track"));
onScreenDisplay?.Display(new MusicActionToast("Previous track", config.LookupKeyBindings(action)));
break;
}
});
@ -72,8 +76,8 @@ namespace osu.Game.Overlays.Music
private class MusicActionToast : Toast
{
public MusicActionToast(string action)
: base("Music Playback", action, string.Empty)
public MusicActionToast(string action, string shortcut)
: base("Music Playback", action, shortcut)
{
}
}