mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Just set music shortcut text locally
This commit is contained in:
parent
52f5473cc0
commit
1fd4b04767
@ -196,7 +196,7 @@ namespace osu.Game.Configuration
|
||||
|
||||
public Func<int, string> LookupSkinName { private get; set; }
|
||||
|
||||
public Func<GlobalAction?, string> LookupKeyBindings { get; set; }
|
||||
public Func<GlobalAction, string> LookupKeyBindings { get; set; }
|
||||
}
|
||||
|
||||
public enum OsuSetting
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Input
|
||||
/// </summary>
|
||||
/// <param name="globalAction">The action to lookup.</param>
|
||||
/// <returns>A set of display strings for all the user's key configuration for the action.</returns>
|
||||
public IEnumerable<string> GetReadableKeyCombinationsFor(GlobalAction? globalAction)
|
||||
public IEnumerable<string> GetReadableKeyCombinationsFor(GlobalAction globalAction)
|
||||
{
|
||||
foreach (var action in Query().Where(b => (GlobalAction)b.Action == globalAction))
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
@ -72,9 +73,18 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
private class MusicActionToast : Toast
|
||||
{
|
||||
private readonly GlobalAction action;
|
||||
|
||||
public MusicActionToast(string value, GlobalAction action)
|
||||
: base("Music Playback", value, action: action)
|
||||
: base("Music Playback", value, string.Empty)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
ShortcutText.Text = config.LookupKeyBindings(action).ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -20,21 +17,14 @@ namespace osu.Game.Overlays.OSD
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private readonly OsuSpriteText spriteText;
|
||||
|
||||
private readonly string shortcut;
|
||||
|
||||
private readonly GlobalAction? action;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected readonly OsuSpriteText ValueText;
|
||||
|
||||
protected Toast(string description, string value, string shortcut = null, GlobalAction? action = null)
|
||||
{
|
||||
this.shortcut = shortcut;
|
||||
this.action = action;
|
||||
protected readonly OsuSpriteText ShortcutText;
|
||||
|
||||
protected Toast(string description, string value, string shortcut)
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
@ -81,7 +71,7 @@ namespace osu.Game.Overlays.OSD
|
||||
Origin = Anchor.Centre,
|
||||
Text = value
|
||||
},
|
||||
spriteText = new OsuSpriteText
|
||||
ShortcutText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
@ -89,23 +79,9 @@ namespace osu.Game.Overlays.OSD
|
||||
Alpha = 0.3f,
|
||||
Margin = new MarginPadding { Bottom = 15 },
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Text = string.IsNullOrEmpty(shortcut) ? "NO KEY BOUND" : shortcut.ToUpperInvariant()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
string text;
|
||||
|
||||
if (action != null)
|
||||
text = config.LookupKeyBindings(action);
|
||||
else if (!string.IsNullOrEmpty(shortcut))
|
||||
text = shortcut;
|
||||
else
|
||||
text = "no key bound";
|
||||
|
||||
spriteText.Text = text.ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user