diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a2ced329d..38512cb78 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -997,6 +997,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_litesteer[i]); + CV_RegisterVar(&cv_autoaccel[i]); + CV_RegisterVar(&cv_usejoystick[i]); CV_RegisterVar(&cv_joyscale[i]); CV_RegisterVar(&cv_rumble[i]); diff --git a/src/g_game.c b/src/g_game.c index 50ec124e6..c304c2e6f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -451,6 +451,14 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = { {"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; +//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}}; +consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = { + {"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -797,6 +805,10 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +// +// G_HandleLocalDriftturn +// Hack for Lua menus that check directional inputs with driftturn +// static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) { INT32 axis = 0; @@ -859,9 +871,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) // static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { - boolean moveinput = false; INT32 axis = 0; - const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); + const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; // check for inputs and return button commands // for stuff like joining with item button, saltyhop, honking, etc. @@ -896,15 +907,11 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) #undef CHECKINPUT - moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) - || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || - (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); - axis = JoyAxis(AXISLOOKBACK, ssplayer); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); // Reset to our spec player if we watch someone else. - if ((moveinput || cmd->buttons) + if ((cmd->driftturn || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { if (cv_director.value) @@ -916,6 +923,63 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) } } +// +// G_HandleAutoAcceleration +// +static void G_HandleAutoAcceleration(ticcmd_t *cmd, player_t *player, UINT8 forplayer) +{ + if (!cv_autoaccel[forplayer].value) + return; + + if (gamestate != GS_LEVEL) + return; + + // dont accel before and during countdown + if (leveltime <= starttime) + return; + + // dont do this in menus or when console is onscreen + if (menuactive || CON_Ready()) + return; + + // gotta have a player that aint respawning + if (!player->mo || player->kartstuff[k_respawn]) + return; + + // dont need for "finished" players + if (player->exiting || (player->pflags & PF_TIMEOVER)) + return; + + // dont do during spinout + if (player->kartstuff[k_spinouttimer]) + return; + + // spectators and freecam dont need special handling, see G_BuildTiccmd + + if (cmd->buttons & BT_BRAKE) + { + if (cmd->buttons & BT_DRIFT || + player->kartstuff[k_sneakertimer] || + player->kartstuff[k_squishedtimer]) + { + cmd->forwardmove = (SINT8)forwardmove[0]; + cmd->buttons |= BT_ACCELERATE; + } + else + { + // allows us to drive backwards if we need to + if (cmd->forwardmove > 0) + cmd->forwardmove = 0; + cmd->buttons &= ~BT_ACCELERATE; + } + } + else + { + cmd->forwardmove = (SINT8)forwardmove[1]; + cmd->buttons |= BT_ACCELERATE; + } +} + // // G_BuildTiccmd // Builds a ticcmd from all of the available inputs @@ -1063,7 +1127,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_accelerate, ssplayer) || (gamepadjoystickmove && axis > 0) || player->kartstuff[k_sneakertimer]) { cmd->buttons |= BT_ACCELERATE; - forward = forwardmove[1]; // 50 + forward = forwardmove[1]; // 50 } else if (analogjoystickmove && axis > 0) { @@ -1144,6 +1208,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->sidemove = (SINT8)(cmd->sidemove + side); } + G_HandleAutoAcceleration(cmd, player, forplayer); + //{ SRB2kart - Drift support // Not grouped with the rest of turn stuff because it needs to know what buttons you're pressing for rubber-burn turn // limit turning to angleturn[1] to stop mouselook letting you look too fast diff --git a/src/g_game.h b/src/g_game.h index c3b89435d..509749c5f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -74,6 +74,8 @@ extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS]; + extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; // Hud offsets diff --git a/src/m_menu.c b/src/m_menu.c index 3cdc45169..144242c96 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9358,29 +9358,32 @@ static void M_SetupControlsMenu(UINT8 pnum) break; } + OP_AllControlsMenu[2].itemaction = &cv_litesteer[pnum]; + OP_AllControlsMenu[3].itemaction = &cv_turnsmooth[pnum]; + if (pnum > 0) { // Hide P1-only controls - OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat - OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // Chat + OP_AllControlsMenu[10].status = IT_GRAYEDOUT2; // Rankings + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[25].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[41].status = IT_GRAYEDOUT2; // Director } else { // Unhide P1-only controls - OP_AllControlsMenu[15].status = IT_CONTROL; // Chat - OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - OP_AllControlsMenu[17].status = IT_CONTROL; // Pause - OP_AllControlsMenu[18].status = IT_CONTROL; // Screenshot - OP_AllControlsMenu[19].status = IT_CONTROL; // GIF - OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu - OP_AllControlsMenu[21].status = IT_CONTROL; // Console - OP_AllControlsMenu[37].status = IT_CONTROL; // Director + OP_AllControlsMenu[19].status = IT_CONTROL; // Chat + OP_AllControlsMenu[10].status = IT_CONTROL; // Rankings + OP_AllControlsMenu[21].status = IT_CONTROL; // Pause + OP_AllControlsMenu[22].status = IT_CONTROL; // Screenshot + OP_AllControlsMenu[23].status = IT_CONTROL; // GIF + OP_AllControlsMenu[24].status = IT_CONTROL; // System Menu + OP_AllControlsMenu[25].status = IT_CONTROL; // Console + OP_AllControlsMenu[41].status = IT_CONTROL; // Director } M_SetupNextMenu(&OP_AllControlsDef); @@ -9494,12 +9497,36 @@ static void M_DrawControl(void) else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1)) V_DrawString(19, y+6, highlightflags|V_ALLOWLOWERCASE, currentMenu->menuitems[i].text); else if (currentMenu->menuitems[i].status & IT_STRING) + { V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); + if (currentMenu->menuitems[i].status & IT_CVAR) + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + + // IT_HEADER matches IT_CVAR, for some reason... + if (cv) + { + INT32 w = V_StringWidth(cv->string, 0); + V_DrawString(BASEVIDWIDTH - x - w, y, + ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? warningflags : highlightflags)|MENUCAPS, cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - w - (skullAnimCounter/5), y, + '\x1C' | highlightflags, false); // left arrow + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | highlightflags, false); // right arrow + } + } + } + } + y += SMALLLINEHEIGHT; } V_DrawScaledPatch(currentMenu->x - 20, cursory, 0, (patch_t *)W_CachePatchName("M_CURSOR", PU_PATCH)); + + M_DoToolTips(currentMenu); } #undef controlheight diff --git a/src/m_menu.h b/src/m_menu.h index 22a174f8a..d94df99f6 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -403,7 +403,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na NULL\ } -#define CONTROLMENUSTYLE(source, prev)\ +#define CONTROLMENUSTYLE(source, prev, tooltip)\ {\ "M_CONTRO",\ sizeof (source)/sizeof (menuitem_t),\ @@ -414,7 +414,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 26, 40,\ 0,\ NULL,\ - NULL\ + tooltip\ } #define IMAGEDEF(source)\ diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3d8d9549a..cbdaac587 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -648,17 +648,6 @@ static menuitem_t OP_ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 55}, {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 75}, - - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P1)", &cv_turnsmooth[0], 85}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P2)", &cv_turnsmooth[1], 95}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P3)", &cv_turnsmooth[2], 105}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P4)", &cv_turnsmooth[3], 115}, - - // i hate our menus sincerly - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P1)", &cv_litesteer[0], 135}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P2)", &cv_litesteer[1], 145}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P3)", &cv_litesteer[2], 155}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P4)", &cv_litesteer[3], 165}, }; static const char* OP_ControlsTooltips[] = @@ -669,15 +658,6 @@ static const char* OP_ControlsTooltips[] = "Setup player 4 controls.", "Options for mouse control.", "Allowed amount of controls per key.", - "Turn smoothing for non-analog turning (Player 1).", - "Turn smoothing for non-analog turning (Player 2).", - "Turn smoothing for non-analog turning (Player 3).", - "Turn smoothing for non-analog turning (Player 4).", - - "Hold DOWN on d-pad/keyboard for shallow turns (Player 1).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 2).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 3).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 4).", }; static menuitem_t OP_AllControlsMenu[] = @@ -685,6 +665,13 @@ static menuitem_t OP_AllControlsMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def, 0}, {IT_CALL|IT_STRING, NULL, "Reset to defaults", M_ResetControls, 8}, + {IT_HEADER, NULL, "Control Options", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, + + // Cvars are set in M_SetupControlsMenu + {IT_STRING|IT_CVAR, NULL, "Lite Steer", &cv_litesteer[0], 18}, + {IT_STRING|IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth[0], 26}, + //{IT_SPACE, NULL, NULL, NULL, 0}, {IT_HEADER, NULL, "Gameplay Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, @@ -733,6 +720,17 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Custom Action 3", M_ChangeControl, gc_custom3 }, }; +// Has to be same length as OP_AllControlsMenu, but otherwise its mostly empty +static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_AllControlsMenu[0])] = { + NULL, + NULL, + NULL, + NULL, + "Hold DOWN on d-pad/keyboard for shallow turns.", + "Turn smoothing for non-analog turning.", + // The rest is null, for now +}; + #define OP_JOYMENU(pnum) \ {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ @@ -1652,6 +1650,13 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, + + {IT_HEADER, NULL, "Controls", NULL, 100}, + + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, }; static const char* OP_AccessibilityTooltips[] = @@ -1673,6 +1678,11 @@ static const char* OP_AccessibilityTooltips[] = NULL, "Reverse left and right channels of audio.", "Change how often the same Sound is allowed to play at once.", + NULL, + "Automatically hold acceleration button (Player 1).", + "Automatically hold acceleration button (Player 2).", + "Automatically hold acceleration button (Player 3).", + "Automatically hold acceleration button (Player 4).", }; static menuitem_t OP_SaturnMenu[] = @@ -2480,7 +2490,7 @@ menu_t OP_MainDef = menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 40, 15, OP_ControlsTooltips); //WTF menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips); -menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); +menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef, OP_AllControlsTooltips); menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36, NULL); menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36, NULL); menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL);