Commit 9107b896 authored by Dino Bollinger's avatar Dino Bollinger Committed by Richard Gobeille
Browse files

Duke3D: Decouple keybind menu ordering from assigned gamefunc index

parent 8ba7a418
......@@ -873,7 +873,7 @@ static MenuEntry_t *MEL_DISPLAYSETUP_GL_POLYMER[] = {
static char const MenuKeyNone[] = " -";
static char const *MEOSN_Keys[NUMKEYS];
static MenuCustom2Col_t MEO_KEYBOARDSETUPFUNCS_TEMPLATE = { { NULL, NULL, }, MEOSN_Keys, &MF_Minifont, NUMKEYS, 54<<16, 0 };
static MenuCustom2Col_t MEO_KEYBOARDSETUPFUNCS_TEMPLATE = { { NULL, NULL, }, MEOSN_Keys, &MF_Minifont, NUMKEYS, 54<<16, 0, -1 };
static MenuCustom2Col_t MEO_KEYBOARDSETUPFUNCS[NUMGAMEFUNCTIONS];
static MenuEntry_t ME_KEYBOARDSETUPFUNCS_TEMPLATE = MAKE_MENUENTRY( NULL, &MF_Minifont, &MEF_KBFuncList, &MEO_KEYBOARDSETUPFUNCS_TEMPLATE, Custom2Col );
static MenuEntry_t ME_KEYBOARDSETUPFUNCS[NUMGAMEFUNCTIONS];
......@@ -2198,6 +2198,7 @@ void Menu_Init(void)
MEO_KEYBOARDSETUPFUNCS[i] = MEO_KEYBOARDSETUPFUNCS_TEMPLATE;
MEO_KEYBOARDSETUPFUNCS[i].column[0] = &ud.config.KeyboardKeys[i][0];
MEO_KEYBOARDSETUPFUNCS[i].column[1] = &ud.config.KeyboardKeys[i][1];
MEO_KEYBOARDSETUPFUNCS[i].linkIndex = i;
}
M_KEYBOARDKEYS.numEntries = NUMGAMEFUNCTIONS;
for (i = 0; i < ARRAY_SSIZE(MenuMouseData); ++i)
......@@ -3412,10 +3413,13 @@ static void Menu_PreInput(MenuEntry_t *entry)
{
auto column = (MenuCustom2Col_t*)entry->entry;
char key[2];
key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
Bassert(column->linkIndex >= 0);
key[0] = ud.config.KeyboardKeys[column->linkIndex][0];
key[1] = ud.config.KeyboardKeys[column->linkIndex][1];
*column->column[M_KEYBOARDKEYS.currentColumn] = 0xff;
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
CONFIG_MapKey(column->linkIndex, ud.config.KeyboardKeys[column->linkIndex][0], key[0], ud.config.KeyboardKeys[column->linkIndex][1], key[1]);
S_PlaySound(KICK_HIT);
KB_ClearKeyDown(sc_Delete);
}
......@@ -3467,18 +3471,20 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
{
auto column = (MenuCustom2Col_t*)entry->entry;
Bassert(column->linkIndex >= 0);
int32_t sc = KB_GetLastScanCode();
if (sc != sc_None)
{
char key[2];
key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
key[0] = ud.config.KeyboardKeys[column->linkIndex][0];
key[1] = ud.config.KeyboardKeys[column->linkIndex][1];
S_PlaySound(PISTOL_BODYHIT);
*column->column[M_KEYBOARDKEYS.currentColumn] = sc;
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
CONFIG_MapKey(column->linkIndex, ud.config.KeyboardKeys[column->linkIndex][0], key[0], ud.config.KeyboardKeys[column->linkIndex][1], key[1]);
KB_ClearKeyDown(sc);
......
......@@ -244,6 +244,9 @@ typedef struct MenuCustom2Col_t
// state
int8_t screenOpen;
// decoupled link (e.g. gamefunc index)
int32_t linkIndex;
} MenuCustom2Col_t;
enum MenuRangeFlags_t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment