mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +08:00
Add music bindings to on screen display
This commit is contained in:
parent
ae1a5b8955
commit
2071cba944
@ -196,7 +196,7 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
public Func<int, string> LookupSkinName { private get; set; }
|
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
|
public enum OsuSetting
|
||||||
|
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays.OSD;
|
using osu.Game.Overlays.OSD;
|
||||||
|
|
||||||
@ -25,6 +26,9 @@ namespace osu.Game.Overlays.Music
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private OnScreenDisplay onScreenDisplay { get; set; }
|
private OnScreenDisplay onScreenDisplay { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
{
|
{
|
||||||
if (beatmap.Disabled)
|
if (beatmap.Disabled)
|
||||||
@ -37,11 +41,11 @@ namespace osu.Game.Overlays.Music
|
|||||||
bool wasPlaying = musicController.IsPlaying;
|
bool wasPlaying = musicController.IsPlaying;
|
||||||
|
|
||||||
if (musicController.TogglePause())
|
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;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.MusicNext:
|
case GlobalAction.MusicNext:
|
||||||
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast("Next track")));
|
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast("Next track", config.LookupKeyBindings(action))));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -51,11 +55,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", config.LookupKeyBindings(action)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PreviousTrackResult.Previous:
|
case PreviousTrackResult.Previous:
|
||||||
onScreenDisplay?.Display(new MusicActionToast("Previous track"));
|
onScreenDisplay?.Display(new MusicActionToast("Previous track", config.LookupKeyBindings(action)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -72,8 +76,8 @@ namespace osu.Game.Overlays.Music
|
|||||||
|
|
||||||
private class MusicActionToast : Toast
|
private class MusicActionToast : Toast
|
||||||
{
|
{
|
||||||
public MusicActionToast(string action)
|
public MusicActionToast(string action, string shortcut)
|
||||||
: base("Music Playback", action, string.Empty)
|
: base("Music Playback", action, shortcut)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user