Add the ability for the game OSD to display user bindings

Adds binding display for mouse button toggle / HUD toggle keys.

- [ ] Depends on #10786 for ease-of-merge
This commit is contained in:
Dean Herbert
2020-11-11 12:54:39 +09:00
parent 9caa56c64f
commit 6014751e29
3 changed files with 49 additions and 11 deletions

View File

@ -32,6 +32,23 @@ namespace osu.Game.Input
public void Register(KeyBindingContainer manager) => insertDefaults(manager.DefaultKeyBindings);
/// <summary>
/// Retrieve all user-defined key combinations (in a format that can be displayed) for a specific action.
/// </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)
{
foreach (var action in Query().Where(b => (GlobalAction)b.Action == globalAction))
{
string str = action.KeyCombination.ReadableString();
// even if found, the readable string may be empty for an unbound action.
if (str.Length > 0)
yield return str;
}
}
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
{
using (var usage = ContextFactory.GetForWrite())