From 52601bdfc2a6dd8916c3c401d70128d2ca11a1ff Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 13 Mar 2025 22:14:31 -0400 Subject: [PATCH] New input display option for stick display --- src/d_netcmd.c | 3 -- src/doomstat.h | 1 - src/k_hud.c | 115 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b3cdc9884..d08112fe6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -255,8 +255,6 @@ static CV_PossibleValue_t sleeping_cons_t[] = {{0, "MIN"}, {1000/TICRATE, "MAX"} static CV_PossibleValue_t pause_cons_t[] = {{0, "Server"}, {1, "All"}, {0, NULL}}; -consvar_t cv_showinputjoy = CVAR_INIT ("showinputjoy", "Off", 0, CV_OnOff, NULL); - static consvar_t cv_dummyconsvar = CVAR_INIT ("dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, DummyConsvar_OnChange); consvar_t cv_restrictskinchange = CVAR_INIT ("restrictskinchange", "No", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL); @@ -998,7 +996,6 @@ void D_RegisterClientCommands(void) // HUD CV_RegisterVar(&cv_itemfinder); - CV_RegisterVar(&cv_showinputjoy); // time attack ghost options are also saved to config CV_RegisterVar(&cv_ghost_besttime); diff --git a/src/doomstat.h b/src/doomstat.h index 23f113966..77c954a25 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -759,7 +759,6 @@ extern boolean singletics; #include "d_clisrv.h" -extern consvar_t cv_showinputjoy; // display joystick in time attack extern consvar_t cv_forceskin; // force clients to use the server's skin extern consvar_t cv_downloading; // allow clients to downloading WADs. extern consvar_t cv_nettimeout; // SRB2Kart: Advanced server options menu diff --git a/src/k_hud.c b/src/k_hud.c index bce20dc7c..8f498c3d0 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -50,7 +50,9 @@ static CV_PossibleValue_t speedo_cons_t[]= { {0, NULL}}; consvar_t cv_newspeedometer = CVAR_INIT ("newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL); -consvar_t cv_showinput = CVAR_INIT ("showinput", "Off", CV_SAVE, CV_OnOff, NULL); +static CV_PossibleValue_t inputdisplay_cons_t[] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}}; + +consvar_t cv_showinput = CVAR_INIT ("showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL); //{ Patch Definitions static patch_t *kp_nodraw; @@ -1359,7 +1361,7 @@ static void K_DrawKartPositionNum(INT32 num) fixed_t scale = FRACUNIT; patch_t *localpatch = kp_positionnum[0][0]; INT32 fx = 0, fy = 0, fflags = 0; - INT32 xoffs = (cv_showinput.value) ? -48 : 0; + INT32 xoffs = (cv_showinput.value > 0) ? -48 : 0; INT32 addOrSub = V_ADD; boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. @@ -1376,7 +1378,7 @@ static void K_DrawKartPositionNum(INT32 num) overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } - if (r_splitscreen || (cv_showinput.value && !r_splitscreen)) + if (r_splitscreen || ((cv_showinput.value > 0) && !r_splitscreen)) scale /= 2; W = FixedMul(W<>FRACBITS; @@ -3841,7 +3843,7 @@ static void K_drawInput(void) #define BUTTH 11 #define drawbutt(xoffs, butt, symb)\ - if (!stplyr->exiting && (K_GetKartButtons(stplyr) & butt))\ + if ((K_GetKartButtons(stplyr) & butt))\ {\ offs = 2*FRACUNIT;\ col = accent1;\ @@ -3867,44 +3869,79 @@ static void K_drawInput(void) y -= FRACUNIT; - if (stplyr->exiting || !stplyr->cmd.turning) // no turn - target = 0; - else // turning of multiple strengths! + if (cv_showinput.value == 2) { - target = ((abs(stplyr->cmd.turning) - 1)/125)+1; - if (target > 4) - target = 4; - if (stplyr->cmd.turning < 0) - target = -target; + INT32 joyx, joyxoffs, joyy, joyyoffs, joyflags; + joyxoffs = -8, joyyoffs = -24; + joyx = x>>FRACBITS, joyy = y>>FRACBITS; + joyflags = V_SNAPTORIGHT|V_SNAPTOBOTTOM; + + // O backing + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, joyflags|accent2); + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, joyflags|splitflags|31); + + if (stplyr->cmd.turning || stplyr->cmd.throwdir) + { + INT16 turning = encoremode ? -stplyr->cmd.turning : stplyr->cmd.turning; + // joystick hole + V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, joyflags|accent1); + // joystick top and back + V_DrawFill(joyx+joyxoffs+3-turning/80, + joyy+joyyoffs+2-stplyr->cmd.throwdir/80, + 10, 10, joyflags|31); + V_DrawFill(joyx+joyxoffs+3-turning/64, + joyy+joyyoffs+1-stplyr->cmd.throwdir/64, + 10, 10, joyflags|accent1); + } + else + { + V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+11, 10, 1, joyflags|accent2); + V_DrawFill(joyx+joyxoffs+3, + joyy+joyyoffs+1, + 10, 10,joyflags|accent1); + } } - - if (pn != target) - { - if (abs(pn - target) == 1) - pn = target; - else if (pn < target) - pn += 2; - else //if (pn > target) - pn -= 2; - } - - if (pn < 0) - { - splitflags |= V_FLIP; // right turn - x -= FRACUNIT; - } - - target = abs(pn); - if (target > 4) - target = 4; - - if (!stplyr->skincolor) - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], NULL); else { - UINT8 *colormap; - colormap = R_GetTranslationColormap(0, stplyr->skincolor, GTC_CACHE); - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], colormap); + if (!stplyr->cmd.turning) // no turn + target = 0; + else // turning of multiple strengths! + { + target = ((abs(stplyr->cmd.turning) - 1)/125)+1; + if (target > 4) + target = 4; + if (stplyr->cmd.turning < 0) + target = -target; + } + + if (pn != target) + { + if (abs(pn - target) == 1) + pn = target; + else if (pn < target) + pn += 2; + else //if (pn > target) + pn -= 2; + } + + if (pn < 0) + { + splitflags |= V_FLIP; // right turn + x -= FRACUNIT; + } + + target = abs(pn); + if (target > 4) + target = 4; + + if (!stplyr->skincolor) + V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], NULL); + else + { + UINT8 *colormap; + colormap = R_GetTranslationColormap(0, stplyr->skincolor, GTC_CACHE); + V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], colormap); + } } } @@ -4450,7 +4487,7 @@ void K_drawKartHUD(void) K_drawRingMeter(); } - if (cv_showinput.value || (modeattacking && !bossinfo.boss)) + if ((cv_showinput.value > 0) || (modeattacking && !bossinfo.boss)) { // Draw the input UI if (LUA_HudEnabled(hud_position))