Add dynamic FOV toggle to settings

as above so below
This commit is contained in:
Tyler Young 2022-11-27 12:15:07 -05:00
parent 9218e2ac94
commit 7364508152
4 changed files with 29 additions and 5 deletions

Binary file not shown.

View file

@ -94,6 +94,7 @@ cvar_t scr_clock = {"scr_clock", "0", CVAR_NONE};
cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE}; cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE};
cvar_t scr_fov = {"fov","70",CVAR_NONE}; // 10 - 170 cvar_t scr_fov = {"fov","70",CVAR_NONE}; // 10 - 170
cvar_t scr_fov_adapt = {"fov_adapt","1",CVAR_ARCHIVE}; cvar_t scr_fov_adapt = {"fov_adapt","1",CVAR_ARCHIVE};
cvar_t scr_dynamic_fov = {"scr_dynamic_fov","1",CVAR_ARCHIVE}; //sB add dynamic FOV toggle
cvar_t scr_conspeed = {"scr_conspeed","500",CVAR_ARCHIVE}; cvar_t scr_conspeed = {"scr_conspeed","500",CVAR_ARCHIVE};
cvar_t scr_centertime = {"scr_centertime","2",CVAR_NONE}; cvar_t scr_centertime = {"scr_centertime","2",CVAR_NONE};
cvar_t scr_showram = {"showram","1",CVAR_NONE}; cvar_t scr_showram = {"showram","1",CVAR_NONE};
@ -691,6 +692,7 @@ void SCR_Init (void)
Cvar_SetCallback (&scr_viewsize, SCR_Callback_refdef); Cvar_SetCallback (&scr_viewsize, SCR_Callback_refdef);
Cvar_RegisterVariable (&scr_fov); Cvar_RegisterVariable (&scr_fov);
Cvar_RegisterVariable (&scr_fov_adapt); Cvar_RegisterVariable (&scr_fov_adapt);
Cvar_RegisterVariable (&scr_dynamic_fov); //sB add dynamic FOV toggle
Cvar_RegisterVariable (&scr_viewsize); Cvar_RegisterVariable (&scr_viewsize);
Cvar_RegisterVariable (&scr_conspeed); Cvar_RegisterVariable (&scr_conspeed);
Cvar_RegisterVariable (&scr_showram); Cvar_RegisterVariable (&scr_showram);
@ -1693,9 +1695,17 @@ void SCR_UpdateScreen (void)
if(!original_fov) if(!original_fov)
original_fov = scr_fov.value; original_fov = scr_fov.value;
//original_fov = scr_fov.value; //original_fov = scr_fov.value;
if(scr_dynamic_fov.value == 0) //sB add dynamic FOV toggle
{
original_fov = 0;
}
else
{
scr_fov.value += (original_fov - 10 - scr_fov.value) * 0.3; scr_fov.value += (original_fov - 10 - scr_fov.value) * 0.3;
Cvar_SetValue("fov",scr_fov.value); Cvar_SetValue("fov",scr_fov.value);
} }
}
else if (cl.stats[STAT_ZOOM] == 0 && original_fov != 0) else if (cl.stats[STAT_ZOOM] == 0 && original_fov != 0)
{ {
if(scr_fov.value < (original_fov + 1))//+1 for accounting for floating point inaccuracies if(scr_fov.value < (original_fov + 1))//+1 for accounting for floating point inaccuracies

View file

@ -51,6 +51,7 @@ extern cvar_t in_aimassist;
extern cvar_t joy_invert; extern cvar_t joy_invert;
extern cvar_t crosshair; extern cvar_t crosshair;
extern cvar_t scr_showfps; extern cvar_t scr_showfps;
extern cvar_t scr_dynamic_fov;
extern cvar_t host_maxfps; extern cvar_t host_maxfps;
extern cvar_t r_fullbright; extern cvar_t r_fullbright;
extern cvar_t gl_texturemode; extern cvar_t gl_texturemode;
@ -2143,8 +2144,19 @@ void M_Graphics_Settings_Draw (void)
else else
Draw_ColoredStringScale(300, y + 160, "Enabled", 1, 1, 1, 1, 1.5f); Draw_ColoredStringScale(300, y + 160, "Enabled", 1, 1, 1, 1, 1.5f);
// Back // Toggle Dynamic FOV
if (gsettings_cursor == 8) if (gsettings_cursor == 8)
Draw_ColoredStringScale(10, y + 175, "Dynamic FOV", 1, 0, 0, 1, 1.5f);
else
Draw_ColoredStringScale(10, y + 175, "Dynamic FOV", 1, 1, 1, 1, 1.5f);
if (scr_dynamic_fov.value == 0)
Draw_ColoredStringScale(300, y + 175, "Disabled", 1, 1, 1, 1, 1.5f);
else
Draw_ColoredStringScale(300, y + 175, "Enabled", 1, 1, 1, 1, 1.5f);
// Back
if (gsettings_cursor == 9)
Draw_ColoredStringScale(10, y + 335, "Back", 1, 0, 0, 1, 1.5f); Draw_ColoredStringScale(10, y + 335, "Back", 1, 0, 0, 1, 1.5f);
else else
Draw_ColoredStringScale(10, y + 335, "Back", 1, 1, 1, 1, 1.5f); Draw_ColoredStringScale(10, y + 335, "Back", 1, 1, 1, 1, 1.5f);
@ -2157,6 +2169,7 @@ void M_Graphics_Settings_Draw (void)
case 3: Draw_ColoredStringScale(10, y + 305, "Increase or Decrease Game Brightness.", 1, 1, 1, 1, 1.5f); break; case 3: Draw_ColoredStringScale(10, y + 305, "Increase or Decrease Game Brightness.", 1, 1, 1, 1, 1.5f); break;
case 6: Draw_ColoredStringScale(10, y + 305, "Toggle all non-realtime lights.", 1, 1, 1, 1, 1.5f); break; case 6: Draw_ColoredStringScale(10, y + 305, "Toggle all non-realtime lights.", 1, 1, 1, 1, 1.5f); break;
case 7: Draw_ColoredStringScale(10, y + 305, "Toggle texture filtering.", 1, 1, 1, 1, 1.5f); break; case 7: Draw_ColoredStringScale(10, y + 305, "Toggle texture filtering.", 1, 1, 1, 1, 1.5f); break;
case 8: Draw_ColoredStringScale(10, y + 305, "Toggle Dynamic FOV.", 1, 1, 1, 1, 1.5f); break;
default: break; default: break;
} }
} }
@ -2170,7 +2183,8 @@ void M_Graphics_Settings_Key (int key)
case 0: Cvar_SetValue("scr_showfps", scr_showfps.value ? 0 : 1); break; case 0: Cvar_SetValue("scr_showfps", scr_showfps.value ? 0 : 1); break;
case 6: Cvar_SetValue("r_fullbright", r_fullbright.value ? 0 : 1); break; case 6: Cvar_SetValue("r_fullbright", r_fullbright.value ? 0 : 1); break;
case 7: Cvar_Set("gl_texturemode", strcmp(gl_texturemode.string, "GL_LINEAR") ? "GL_LINEAR" : "GL_NEAREST_MIPMAP_LINEAR" ); break; case 7: Cvar_Set("gl_texturemode", strcmp(gl_texturemode.string, "GL_LINEAR") ? "GL_LINEAR" : "GL_NEAREST_MIPMAP_LINEAR" ); break;
case 8: M_Menu_Options_f (); break; case 8: Cvar_SetValue("scr_dynamic_fov", scr_dynamic_fov.value ? 0 : 1); break;
case 9: M_Menu_Options_f (); break;
default: break; default: break;
} }
break; break;

View file

@ -233,11 +233,11 @@ float V_CalcBob (float speed,float which)//0 = regular, 1 = side bobbing
{ {
float bob = 0; float bob = 0;
float sprint = 1; float sprint = 1;
if(cl.stats[STAT_ZOOM] == 3) if(cl.stats[STAT_ZOOM] == 3)
sprint = 1.8 * speed_reduce (cl.stats[STAT_ACTIVEWEAPON]);//this gets sprinting speed in comparison to walk speed per weapon sprint = 1.8 * speed_reduce (cl.stats[STAT_ACTIVEWEAPON]);//this gets sprinting speed in comparison to walk speed per weapon
if(cl.stats[STAT_ZOOM] == 2) if(cl.stats[STAT_ZOOM] == 2)
return 0; return 0;
//12.048 -> 4.3 = 100 -> 36ish, so replace 100 with 36 //12.048 -> 4.3 = 100 -> 36ish, so replace 100 with 36
if(which == 0) if(which == 0)
bob = cl_bobup.value * 24 * speed * (sprint * sprint) * sin((cl.time * 12.5 * sprint));//Pitch Bobbing 10 bob = cl_bobup.value * 24 * speed * (sprint * sprint) * sin((cl.time * 12.5 * sprint));//Pitch Bobbing 10