mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 12:42:54 +08:00
Merge pull request #10829 from Joehuu/music-osd-bindings
Add music bindings to on screen display
This commit is contained in:
commit
57ff150051
@ -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;
|
||||||
|
|
||||||
@ -37,11 +38,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", 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", action)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -51,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", action));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PreviousTrackResult.Previous:
|
case PreviousTrackResult.Previous:
|
||||||
onScreenDisplay?.Display(new MusicActionToast("Previous track"));
|
onScreenDisplay?.Display(new MusicActionToast("Previous track", action));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -72,9 +73,18 @@ namespace osu.Game.Overlays.Music
|
|||||||
|
|
||||||
private class MusicActionToast : Toast
|
private class MusicActionToast : Toast
|
||||||
{
|
{
|
||||||
public MusicActionToast(string action)
|
private readonly GlobalAction action;
|
||||||
: base("Music Playback", action, string.Empty)
|
|
||||||
|
public MusicActionToast(string value, GlobalAction action)
|
||||||
|
: base("Music Playback", value, string.Empty)
|
||||||
{
|
{
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
ShortcutText.Text = config.LookupKeyBindings(action).ToUpperInvariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,13 @@ namespace osu.Game.Overlays.OSD
|
|||||||
private const int toast_minimum_width = 240;
|
private const int toast_minimum_width = 240;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
protected readonly OsuSpriteText ValueText;
|
protected readonly OsuSpriteText ValueText;
|
||||||
|
|
||||||
|
protected readonly OsuSpriteText ShortcutText;
|
||||||
|
|
||||||
protected Toast(string description, string value, string shortcut)
|
protected Toast(string description, string value, string shortcut)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
@ -68,7 +71,7 @@ namespace osu.Game.Overlays.OSD
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Text = value
|
Text = value
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
ShortcutText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
|
Loading…
Reference in New Issue
Block a user