From 28dba7f3c1bef7f20dcdec3bf7682eef148004e1 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Wed, 23 Nov 2022 18:35:51 +0100 Subject: [PATCH] Add a separate control for switching to the previous viewpoint --- src/deh_tables.c | 4 +- src/g_game.c | 13 ++++-- src/g_input.c | 105 ++++++++++++++++++++++++----------------------- src/g_input.h | 3 +- src/m_menu.c | 31 +++++++------- 5 files changed, 85 insertions(+), 71 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 11d8b1a01..4a3467f78 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5694,7 +5694,9 @@ struct int_const_s const INT_CONST[] = { {"GC_SYSTEMMENU",GC_SYSTEMMENU}, {"GC_SCREENSHOT",GC_SCREENSHOT}, {"GC_RECORDGIF",GC_RECORDGIF}, - {"GC_VIEWPOINT",GC_VIEWPOINT}, + {"GC_VIEWPOINTNEXT",GC_VIEWPOINTNEXT}, + {"GC_VIEWPOINT",GC_VIEWPOINTNEXT}, // Alias for retrocompatibility. Remove for the next major version + {"GC_VIEWPOINTPREV",GC_VIEWPOINTPREV}, {"GC_CUSTOM1",GC_CUSTOM1}, {"GC_CUSTOM2",GC_CUSTOM2}, {"GC_CUSTOM3",GC_CUSTOM3}, diff --git a/src/g_game.c b/src/g_game.c index 331f8a768..43057d0eb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1963,10 +1963,17 @@ static boolean ViewpointSwitchResponder(event_t *ev) { // ViewpointSwitch Lua hook. UINT8 canSwitchView = 0; - boolean pressed = (ev->key == KEY_F12 || ev->key == gamecontrol[GC_VIEWPOINT][0] || ev->key == gamecontrol[GC_VIEWPOINT][1]); + + INT32 direction = 0; + if (ev->key == KEY_F12 || ev->key == gamecontrol[GC_VIEWPOINTNEXT][0] || ev->key == gamecontrol[GC_VIEWPOINTNEXT][1]) + direction = 1; + if (ev->key == gamecontrol[GC_VIEWPOINTPREV][0] || ev->key == gamecontrol[GC_VIEWPOINTPREV][1]) + direction = -1; + if (shiftdown) + direction = -direction; // allow spy mode changes even during the demo - if (!(gamestate == GS_LEVEL && ev->type == ev_keydown && pressed)) + if (!(gamestate == GS_LEVEL && ev->type == ev_keydown && direction != 0)) return false; if (splitscreen || !netgame) @@ -1979,7 +1986,7 @@ static boolean ViewpointSwitchResponder(event_t *ev) do { // Wrap in both directions - displayplayer += shiftdown ? -1 : 1; + displayplayer += direction; displayplayer = (displayplayer + MAXPLAYERS) % MAXPLAYERS; if (!playeringame[displayplayer]) diff --git a/src/g_input.c b/src/g_input.c index 7bb2e799d..79bd2a4a2 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -593,7 +593,8 @@ static const char *gamecontrolname[NUM_GAMECONTROLS] = "systemmenu", "screenshot", "recordgif", - "viewpoint", + "viewpoint", // Rename this to "viewpointnext" for the next major version + "viewpointprev", "custom1", "custom2", "custom3", @@ -713,61 +714,61 @@ void G_DefineDefaultControls(void) for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) { - gamecontroldefault[i][GC_WEAPONNEXT ][0] = KEY_MOUSEWHEELUP+0; - gamecontroldefault[i][GC_WEAPONPREV ][0] = KEY_MOUSEWHEELDOWN+0; - gamecontroldefault[i][GC_WEPSLOT1 ][0] = '1'; - gamecontroldefault[i][GC_WEPSLOT2 ][0] = '2'; - gamecontroldefault[i][GC_WEPSLOT3 ][0] = '3'; - gamecontroldefault[i][GC_WEPSLOT4 ][0] = '4'; - gamecontroldefault[i][GC_WEPSLOT5 ][0] = '5'; - gamecontroldefault[i][GC_WEPSLOT6 ][0] = '6'; - gamecontroldefault[i][GC_WEPSLOT7 ][0] = '7'; - gamecontroldefault[i][GC_WEPSLOT8 ][0] = '8'; - gamecontroldefault[i][GC_WEPSLOT9 ][0] = '9'; - gamecontroldefault[i][GC_WEPSLOT10 ][0] = '0'; - gamecontroldefault[i][GC_TOSSFLAG ][0] = '\''; - gamecontroldefault[i][GC_CAMTOGGLE ][0] = 'v'; - gamecontroldefault[i][GC_CAMRESET ][0] = 'r'; - gamecontroldefault[i][GC_TALKKEY ][0] = 't'; - gamecontroldefault[i][GC_TEAMKEY ][0] = 'y'; - gamecontroldefault[i][GC_SCORES ][0] = KEY_TAB; - gamecontroldefault[i][GC_CONSOLE ][0] = KEY_CONSOLE; - gamecontroldefault[i][GC_PAUSE ][0] = 'p'; - gamecontroldefault[i][GC_SCREENSHOT ][0] = KEY_F8; - gamecontroldefault[i][GC_RECORDGIF ][0] = KEY_F9; - gamecontroldefault[i][GC_VIEWPOINT ][0] = KEY_F12; + gamecontroldefault[i][GC_WEAPONNEXT ][0] = KEY_MOUSEWHEELUP+0; + gamecontroldefault[i][GC_WEAPONPREV ][0] = KEY_MOUSEWHEELDOWN+0; + gamecontroldefault[i][GC_WEPSLOT1 ][0] = '1'; + gamecontroldefault[i][GC_WEPSLOT2 ][0] = '2'; + gamecontroldefault[i][GC_WEPSLOT3 ][0] = '3'; + gamecontroldefault[i][GC_WEPSLOT4 ][0] = '4'; + gamecontroldefault[i][GC_WEPSLOT5 ][0] = '5'; + gamecontroldefault[i][GC_WEPSLOT6 ][0] = '6'; + gamecontroldefault[i][GC_WEPSLOT7 ][0] = '7'; + gamecontroldefault[i][GC_WEPSLOT8 ][0] = '8'; + gamecontroldefault[i][GC_WEPSLOT9 ][0] = '9'; + gamecontroldefault[i][GC_WEPSLOT10 ][0] = '0'; + gamecontroldefault[i][GC_TOSSFLAG ][0] = '\''; + gamecontroldefault[i][GC_CAMTOGGLE ][0] = 'v'; + gamecontroldefault[i][GC_CAMRESET ][0] = 'r'; + gamecontroldefault[i][GC_TALKKEY ][0] = 't'; + gamecontroldefault[i][GC_TEAMKEY ][0] = 'y'; + gamecontroldefault[i][GC_SCORES ][0] = KEY_TAB; + gamecontroldefault[i][GC_CONSOLE ][0] = KEY_CONSOLE; + gamecontroldefault[i][GC_PAUSE ][0] = 'p'; + gamecontroldefault[i][GC_SCREENSHOT ][0] = KEY_F8; + gamecontroldefault[i][GC_RECORDGIF ][0] = KEY_F9; + gamecontroldefault[i][GC_VIEWPOINTNEXT][0] = KEY_F12; // Gamepad controls -- same for both schemes - gamecontroldefault[i][GC_JUMP ][1] = KEY_JOY1+0; // A - gamecontroldefault[i][GC_SPIN ][1] = KEY_JOY1+2; // X - gamecontroldefault[i][GC_CUSTOM1 ][1] = KEY_JOY1+1; // B - gamecontroldefault[i][GC_CUSTOM2 ][1] = KEY_JOY1+3; // Y - gamecontroldefault[i][GC_CUSTOM3 ][1] = KEY_JOY1+8; // Left Stick - gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+9; // Right Stick - gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_JOY1+4; // LB - gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_JOY1+5; // RB - gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_JOY1+6; // Back - gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start - gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+0; // D-Pad Up - gamecontroldefault[i][GC_VIEWPOINT ][1] = KEY_HAT1+1; // D-Pad Down - gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_HAT1+2; // D-Pad Left - gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+3; // D-Pad Right + gamecontroldefault[i][GC_JUMP ][1] = KEY_JOY1+0; // A + gamecontroldefault[i][GC_SPIN ][1] = KEY_JOY1+2; // X + gamecontroldefault[i][GC_CUSTOM1 ][1] = KEY_JOY1+1; // B + gamecontroldefault[i][GC_CUSTOM2 ][1] = KEY_JOY1+3; // Y + gamecontroldefault[i][GC_CUSTOM3 ][1] = KEY_JOY1+8; // Left Stick + gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+9; // Right Stick + gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_JOY1+4; // LB + gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_JOY1+5; // RB + gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_JOY1+6; // Back + gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start + gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+0; // D-Pad Up + gamecontroldefault[i][GC_VIEWPOINTNEXT][1] = KEY_HAT1+1; // D-Pad Down + gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_HAT1+2; // D-Pad Left + gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+3; // D-Pad Right // Second player controls only have joypad defaults - gamecontrolbisdefault[i][GC_JUMP ][1] = KEY_2JOY1+0; // A - gamecontrolbisdefault[i][GC_SPIN ][1] = KEY_2JOY1+2; // X - gamecontrolbisdefault[i][GC_CUSTOM1 ][1] = KEY_2JOY1+1; // B - gamecontrolbisdefault[i][GC_CUSTOM2 ][1] = KEY_2JOY1+3; // Y - gamecontrolbisdefault[i][GC_CUSTOM3 ][1] = KEY_2JOY1+8; // Left Stick - gamecontrolbisdefault[i][GC_CENTERVIEW ][1] = KEY_2JOY1+9; // Right Stick - gamecontrolbisdefault[i][GC_WEAPONPREV ][1] = KEY_2JOY1+4; // LB - gamecontrolbisdefault[i][GC_WEAPONNEXT ][1] = KEY_2JOY1+5; // RB - gamecontrolbisdefault[i][GC_SCREENSHOT ][1] = KEY_2JOY1+6; // Back - //gamecontrolbisdefault[i][GC_SYSTEMMENU ][0] = KEY_2JOY1+7; // Start - gamecontrolbisdefault[i][GC_CAMTOGGLE ][1] = KEY_2HAT1+0; // D-Pad Up - gamecontrolbisdefault[i][GC_VIEWPOINT ][1] = KEY_2HAT1+1; // D-Pad Down - gamecontrolbisdefault[i][GC_TOSSFLAG ][1] = KEY_2HAT1+2; // D-Pad Left - //gamecontrolbisdefault[i][GC_SCORES ][1] = KEY_2HAT1+3; // D-Pad Right + gamecontrolbisdefault[i][GC_JUMP ][1] = KEY_2JOY1+0; // A + gamecontrolbisdefault[i][GC_SPIN ][1] = KEY_2JOY1+2; // X + gamecontrolbisdefault[i][GC_CUSTOM1 ][1] = KEY_2JOY1+1; // B + gamecontrolbisdefault[i][GC_CUSTOM2 ][1] = KEY_2JOY1+3; // Y + gamecontrolbisdefault[i][GC_CUSTOM3 ][1] = KEY_2JOY1+8; // Left Stick + gamecontrolbisdefault[i][GC_CENTERVIEW ][1] = KEY_2JOY1+9; // Right Stick + gamecontrolbisdefault[i][GC_WEAPONPREV ][1] = KEY_2JOY1+4; // LB + gamecontrolbisdefault[i][GC_WEAPONNEXT ][1] = KEY_2JOY1+5; // RB + gamecontrolbisdefault[i][GC_SCREENSHOT ][1] = KEY_2JOY1+6; // Back + //gamecontrolbisdefault[i][GC_SYSTEMMENU ][0] = KEY_2JOY1+7; // Start + gamecontrolbisdefault[i][GC_CAMTOGGLE ][1] = KEY_2HAT1+0; // D-Pad Up + gamecontrolbisdefault[i][GC_VIEWPOINTNEXT][1] = KEY_2HAT1+1; // D-Pad Down + gamecontrolbisdefault[i][GC_TOSSFLAG ][1] = KEY_2HAT1+2; // D-Pad Left + //gamecontrolbisdefault[i][GC_SCORES ][1] = KEY_2HAT1+3; // D-Pad Right } } diff --git a/src/g_input.h b/src/g_input.h index bf6ad39b3..400e3fd12 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -96,7 +96,8 @@ typedef enum GC_SYSTEMMENU, GC_SCREENSHOT, GC_RECORDGIF, - GC_VIEWPOINT, + GC_VIEWPOINTNEXT, + GC_VIEWPOINTPREV, GC_CUSTOM1, // Lua scriptable GC_CUSTOM2, // Lua scriptable GC_CUSTOM3, // Lua scriptable diff --git a/src/m_menu.c b/src/m_menu.c index 83b788fd5..6dffe0d51 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1129,10 +1129,11 @@ static menuitem_t OP_ChangeControlsMenu[] = {IT_CALL | IT_STRING2, NULL, "Game Status", M_ChangeControl, GC_SCORES }, {IT_CALL | IT_STRING2, NULL, "Pause / Run Retry", M_ChangeControl, GC_PAUSE }, - {IT_CALL | IT_STRING2, NULL, "Screenshot", M_ChangeControl, GC_SCREENSHOT }, - {IT_CALL | IT_STRING2, NULL, "Toggle GIF Recording", M_ChangeControl, GC_RECORDGIF }, - {IT_CALL | IT_STRING2, NULL, "Open/Close Menu (ESC)", M_ChangeControl, GC_SYSTEMMENU }, - {IT_CALL | IT_STRING2, NULL, "Change Viewpoint", M_ChangeControl, GC_VIEWPOINT }, + {IT_CALL | IT_STRING2, NULL, "Screenshot", M_ChangeControl, GC_SCREENSHOT }, + {IT_CALL | IT_STRING2, NULL, "Toggle GIF Recording", M_ChangeControl, GC_RECORDGIF }, + {IT_CALL | IT_STRING2, NULL, "Open/Close Menu (ESC)", M_ChangeControl, GC_SYSTEMMENU }, + {IT_CALL | IT_STRING2, NULL, "Next Viewpoint", M_ChangeControl, GC_VIEWPOINTNEXT }, + {IT_CALL | IT_STRING2, NULL, "Prev Viewpoint", M_ChangeControl, GC_VIEWPOINTPREV }, {IT_CALL | IT_STRING2, NULL, "Console", M_ChangeControl, GC_CONSOLE }, {IT_HEADER, NULL, "Multiplayer", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding @@ -12750,13 +12751,14 @@ static void M_Setup1PControlsMenu(INT32 choice) OP_ChangeControlsMenu[18+5].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[18+6].status = IT_CALL|IT_STRING2; //OP_ChangeControlsMenu[18+7].status = IT_CALL|IT_STRING2; - OP_ChangeControlsMenu[18+8].status = IT_CALL|IT_STRING2; + //OP_ChangeControlsMenu[18+8].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+9].status = IT_CALL|IT_STRING2; // ... - OP_ChangeControlsMenu[27+0].status = IT_HEADER; - OP_ChangeControlsMenu[27+1].status = IT_SPACE; + OP_ChangeControlsMenu[28+0].status = IT_HEADER; + OP_ChangeControlsMenu[28+1].status = IT_SPACE; // ... - OP_ChangeControlsMenu[27+2].status = IT_CALL|IT_STRING2; - OP_ChangeControlsMenu[27+3].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[28+2].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[28+3].status = IT_CALL|IT_STRING2; OP_ChangeControlsDef.prevMenu = &OP_P1ControlsDef; OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level @@ -12781,13 +12783,14 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_ChangeControlsMenu[18+5].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[18+6].status = IT_GRAYEDOUT2; //OP_ChangeControlsMenu[18+7].status = IT_GRAYEDOUT2; - OP_ChangeControlsMenu[18+8].status = IT_GRAYEDOUT2; + //OP_ChangeControlsMenu[18+8].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+9].status = IT_GRAYEDOUT2; // ... - OP_ChangeControlsMenu[27+0].status = IT_GRAYEDOUT2; - OP_ChangeControlsMenu[27+1].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[28+0].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[28+1].status = IT_GRAYEDOUT2; // ... - OP_ChangeControlsMenu[27+2].status = IT_GRAYEDOUT2; - OP_ChangeControlsMenu[27+3].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[28+2].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[28+3].status = IT_GRAYEDOUT2; OP_ChangeControlsDef.prevMenu = &OP_P2ControlsDef; OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level