Menu inputs standardised

Streamlined menu inputs by making most "*_MenuKey(key)" functions to use
Key_GetMenuKey(). "Backspace" is not a special case anymore, so any menus
that have a "delete" option can already handle any input expected, like the
backspace or delete keys, or the "Y" button of the controller, to run it.

Also, fixed a bug where changing the key for "team chat" also changes the one
for "chat" in the "multiplayer" -> "customize controls" menu.
This commit is contained in:
Jaime Moreira 2022-05-07 22:45:44 -04:00
parent 2bb1b33d7e
commit d4100f7113

View file

@ -265,6 +265,12 @@ Key_GetMenuKey(int key)
case K_JOY_BACK: case K_JOY_BACK:
case K_BTN_B: case K_BTN_B:
return K_ESCAPE; return K_ESCAPE;
case K_BACKSPACE:
case K_DEL:
case K_KP_DEL:
case K_BTN_Y:
return K_BACKSPACE;
} }
return key; return key;
@ -800,9 +806,6 @@ static void
M_UnbindCommand(char *command) M_UnbindCommand(char *command)
{ {
int j; int j;
int l;
l = strlen(command);
for (j = 0; j < K_LAST; j++) for (j = 0; j < K_LAST; j++)
{ {
@ -814,7 +817,7 @@ M_UnbindCommand(char *command)
continue; continue;
} }
if (!strncmp(b, command, l)) if (!strcmp(b, command))
{ {
Key_SetBinding(j, ""); Key_SetBinding(j, "");
} }
@ -826,10 +829,8 @@ M_FindKeysForCommand(char *command, int *twokeys)
{ {
int count; int count;
int j; int j;
int l;
twokeys[0] = twokeys[1] = -1; twokeys[0] = twokeys[1] = -1;
l = strlen(command);
count = 0; count = 0;
for (j = 0; j < K_LAST; j++) for (j = 0; j < K_LAST; j++)
@ -842,7 +843,7 @@ M_FindKeysForCommand(char *command, int *twokeys)
continue; continue;
} }
if (!strncmp(b, command, l)) if (!strcmp(b, command))
{ {
twokeys[count] = j; twokeys[count] = j;
count++; count++;
@ -980,15 +981,13 @@ Keys_MenuKey(int key)
return menu_out_sound; return menu_out_sound;
} }
key = Key_GetMenuKey(key);
switch (key) switch (key)
{ {
case K_KP_ENTER:
case K_ENTER: case K_ENTER:
KeyBindingFunc(item); KeyBindingFunc(item);
return menu_in_sound; return menu_in_sound;
case K_BACKSPACE: /* delete bindings */ case K_BACKSPACE: /* delete bindings */
case K_DEL: /* delete bindings */
case K_KP_DEL:
M_UnbindCommand(bindnames[item->generic.localdata[0]][0]); M_UnbindCommand(bindnames[item->generic.localdata[0]][0]);
return menu_out_sound; return menu_out_sound;
default: default:
@ -1131,15 +1130,13 @@ MultiplayerKeys_MenuKey(int key)
return menu_out_sound; return menu_out_sound;
} }
key = Key_GetMenuKey(key);
switch (key) switch (key)
{ {
case K_KP_ENTER:
case K_ENTER: case K_ENTER:
MultiplayerKeyBindingFunc(item); MultiplayerKeyBindingFunc(item);
return menu_in_sound; return menu_in_sound;
case K_BACKSPACE: /* delete bindings */ case K_BACKSPACE: /* delete bindings */
case K_DEL: /* delete bindings */
case K_KP_DEL:
M_UnbindCommand(multiplayer_key_bindnames[item->generic.localdata[0]][0]); M_UnbindCommand(multiplayer_key_bindnames[item->generic.localdata[0]][0]);
return menu_out_sound; return menu_out_sound;
default: default:
@ -2862,8 +2859,6 @@ LoadGame_MenuKey(int key)
return menu_move_sound; return menu_move_sound;
case K_BACKSPACE: case K_BACKSPACE:
case K_DEL:
case K_KP_DEL:
if ((item = Menu_ItemAtCursor(m)) != NULL) if ((item = Menu_ItemAtCursor(m)) != NULL)
{ {
if (item->type == MTYPE_ACTION) if (item->type == MTYPE_ACTION)
@ -3034,8 +3029,6 @@ SaveGame_MenuKey(int key)
return menu_move_sound; return menu_move_sound;
case K_BACKSPACE: case K_BACKSPACE:
case K_DEL:
case K_KP_DEL:
if ((item = Menu_ItemAtCursor(m)) != NULL) if ((item = Menu_ItemAtCursor(m)) != NULL)
{ {
if (item->type == MTYPE_ACTION) if (item->type == MTYPE_ACTION)