From 3d39f5038805d3f1e3796a7449e94bdbef8cb4f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:03:10 +0100 Subject: [PATCH 1/5] make function to return button names to use with new rebindable cam controls --- src/st_stuff.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 398dc7dbe..da5628827 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -652,6 +652,20 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } +static const char *ST_GetButtonName(INT32 control, const char *inputtext) +{ + static char buttname[32] = {0}; // Static buffer + const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; + const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + else + snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + + return buttname; +} + // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -780,19 +794,9 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); - - char directortoggle[32] = {0}; - const char *item1 = gamecontrol[gc_director][0] != 0 ? G_KeynumToString(gamecontrol[gc_director][0]) : NULL; - const char *item2 = gamecontrol[gc_director][1] != 0 ? G_KeynumToString(gamecontrol[gc_director][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(directortoggle, 32, "%s/%s - Toggle Director", item1, item2); - else - snprintf(directortoggle, 32, "%s - Toggle Director", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound"); - - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, directortoggle); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); directortextactive = true; } @@ -800,8 +804,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); } } } From 6b9900ad4ed25237bffa1f1f7187d0e76ce741c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:27:18 +0100 Subject: [PATCH 2/5] clean up cam stuff for good --- src/g_game.c | 1 - src/p_local.h | 2 -- src/p_user.c | 78 +++++++++++++++++++++------------------------------ 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2c3e2fa02..f612b813d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7868,7 +7868,6 @@ void G_StopDemo(void) camera[i].freecam = false; camera[i].localangle = 0; camera[i].localaiming = 0; - camera[i].keyboardlook = false; } CV_SetValue(&cv_playbackspeed, 1); diff --git a/src/p_local.h b/src/p_local.h index 13219c429..c2a2ee017 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,8 +84,6 @@ typedef struct camera_s angle_t localangle; INT32 localaiming; - boolean keyboardlook; // keyboard look - angle_t aiming; // Freecam: A button was held since entering from menu, so don't move camera diff --git a/src/p_user.c b/src/p_user.c index 37a5ee0df..1456f1cbf 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,12 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, forward, side, axis; //i + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions boolean turnleft, turnright; - boolean usejoystick, kbl; + boolean usejoystick; angle_t lang; - INT32 screen_invert; const UINT8 forplayer = num+1; ticcmd_t *cmd = D_LocalTiccmd(num); @@ -3170,24 +3170,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; - kbl = cam->keyboardlook; - - switch (num) - { - case 1: - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - break; - case 2: - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - break; - case 3: - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - break; - case 0: - default: - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - break; - } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -3218,15 +3200,27 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) } forward = side = 0; + // use two stage accelerative turning + // on the keyboard and joystick + if (turnleft || turnright) + th += 1; + else + th = 0; + + if (th < SLOWTURNTICS) + tspeed = 2; // slow turn + else + tspeed = 1; + // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); side -= sidemove[1]; } @@ -3251,32 +3245,22 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cmd->buttons |= BT_ATTACK; // spectator aiming shit, ahhhh... - screen_invert = 1; // nope - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; // looking up/down - laim += (mlooky<<19)*screen_invert; + laim += (mlooky<<19); axis = JoyAxis(AXISLOOK, forplayer); if (analogjoystickmove && axis != 0 && lookaxis) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis) - laim = 0; + laim += (axis<<16); if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; + laim += KB_LOOKSPEED; } else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; + laim -= KB_LOOKSPEED; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V @@ -3306,7 +3290,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cam->localangle = lang; cam->localaiming = laim; - cam->keyboardlook = kbl; return cmd; } @@ -3341,16 +3324,19 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; + int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); - if (InputDown(gc_camfloat, forplayer)) + switch (dir) { - cam->z += spd; - moving = true; - } - else if (InputDown(gc_camsink, forplayer)) - { - cam->z -= spd; - moving = true; + case 1: + cam->z += spd; + moving = true; + break; + + case -1: + cam->z -= spd; + moving = true; + break; } } From 4110130ca7dc96980df6ad6b437cc393ce741057 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:36:36 +0100 Subject: [PATCH 3/5] block freecam toggling when player is in spec --- src/p_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 1456f1cbf..31f2820bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3141,13 +3141,17 @@ void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; + // dont let freecam be toggled when in spec lel + if (players[displayplayers[viewnum]].spectator) + return; + if (!cam->freecam) // toggle on { cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; } - else // toggle off + else // toggle off { cam->freecam = false; } From 11546cd9060622bd858fb7b2ea750c399aa157da Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:37:10 +0100 Subject: [PATCH 4/5] fix centerview --- src/p_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 31f2820bb..22ea6454c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3315,6 +3315,10 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // first off we need to get button input cmd = P_CameraCmd(cam, num); + // let centerview work proper + if (InputDown(gc_centerview, forplayer)) + cam->aiming = 0; + if (cmd->aiming != 0) { cam->aiming = cmd->aiming << FRACBITS; From ca09a5dd465267d68c6a01b8982ac0c380dc6037 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:40:13 +0100 Subject: [PATCH 5/5] dont need to do this twice --- src/p_user.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 22ea6454c..7a9e1f67c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3390,24 +3390,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } } - if (rendermode == render_soft -#ifdef HWRENDER - || (rendermode == render_opengl && (cv_glshearing.value == 1)) -#endif - ) - { - // Extra restriction on this so it's not possible to - // distort the view too much. - if ((INT32)cam->aiming > ANGLE_45) - cam->aiming = ANGLE_45; - else if ((INT32)cam->aiming < -ANGLE_45) - cam->aiming = -ANGLE_45; - } - else - { - G_ClipAimingPitch((INT32 *)&cam->aiming); - } - cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) {