diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 74cba2701..c4499b5a4 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -569,6 +569,14 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, NameKeys) ACTION_RETURN_STRING(buffer); } +DEFINE_ACTION_FUNCTION(FKeyBindings, NameAllKeys) +{ + PARAM_PROLOGUE; + PARAM_POINTER(array, TArray); + 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); + PARAM_STRING(cmd); + *array = self->GetKeysForCommand(cmd); + return 0; +} + DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand) { PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings); diff --git a/wadsrc/static/zscript/ui/menu/menu.zs b/wadsrc/static/zscript/ui/menu/menu.zs index d47af6fc2..65a563211 100644 --- a/wadsrc/static/zscript/ui/menu/menu.zs +++ b/wadsrc/static/zscript/ui/menu/menu.zs @@ -2,8 +2,11 @@ struct KeyBindings native version("2.4") { native static String NameKeys(int k1, int k2); + native static String NameAllKeys(array list); native int, int GetKeysForCommand(String cmd); + native void GetAllKeysForCommand(out array list, String cmd); + native void SetBind(int key, String cmd); native void UnbindACommand (String str); } diff --git a/wadsrc/static/zscript/ui/menu/optionmenuitems.zs b/wadsrc/static/zscript/ui/menu/optionmenuitems.zs index 799d6b455..95a27d055 100644 --- a/wadsrc/static/zscript/ui/menu/optionmenuitems.zs +++ b/wadsrc/static/zscript/ui/menu/optionmenuitems.zs @@ -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 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);