- changed display in key binding menu to list all bound keys for an action, not just the first two.

This commit is contained in:
Christoph Oelckers 2020-10-04 19:28:20 +02:00
parent f6eac89677
commit 63a338fd73
3 changed files with 25 additions and 5 deletions

View file

@ -569,6 +569,14 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, NameKeys)
ACTION_RETURN_STRING(buffer);
}
DEFINE_ACTION_FUNCTION(FKeyBindings, NameAllKeys)
{
PARAM_PROLOGUE;
PARAM_POINTER(array, TArray<int>);
auto buffer = C_NameKeys(array->Data(), array->Size(), true);
ACTION_RETURN_STRING(buffer);
}
DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand)
{
PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings);
@ -580,6 +588,15 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand)
return MIN(numret, 2);
}
DEFINE_ACTION_FUNCTION(FKeyBindings, GetAllKeysForCommand)
{
PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings);
PARAM_POINTER(array, TArray<int>);
PARAM_STRING(cmd);
*array = self->GetKeysForCommand(cmd);
return 0;
}
DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand)
{
PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings);

View file

@ -2,8 +2,11 @@
struct KeyBindings native version("2.4")
{
native static String NameKeys(int k1, int k2);
native static String NameAllKeys(array<int> list);
native int, int GetKeysForCommand(String cmd);
native void GetAllKeysForCommand(out array<int> list, String cmd);
native void SetBind(int key, String cmd);
native void UnbindACommand (String str);
}

View file

@ -502,14 +502,14 @@ class OptionMenuItemControlBase : OptionMenuItem
//=============================================================================
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
{
drawLabel(indent, y, mWaiting? OptionMenuSettings.mFontColorHighlight:
(selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor));
drawLabel(indent, y, mWaiting ? OptionMenuSettings.mFontColorHighlight :
(selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor));
String description;
int Key1, Key2;
Array<int> keys;
[Key1, Key2] = mBindings.GetKeysForCommand(mAction);
description = KeyBindings.NameKeys (Key1, Key2);
mBindings.GetAllKeysForCommand(keys, mAction);
description = KeyBindings.NameAllKeys(keys);
if (description.Length() > 0)
{
drawValue(indent, y, Font.CR_WHITE, description);