Skip to content

Commit

Permalink
Add r_showfields_align cvar
Browse files Browse the repository at this point in the history
controlling where r_showfields info is drawn:
0 = entity position
1 = bottom-right screen corner (default)

Note: entity-centered output was previously achievable with r_showfields -1, but having a separate cvar is more discoverable.
  • Loading branch information
andrei-drexler committed Nov 10, 2024
1 parent 414b0fe commit e0b2397
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ cvar_t r_showbboxes_health = {"r_showbboxes_health", "0", CVAR_NONE}; // 0=show
cvar_t r_showbboxes_links = {"r_showbboxes_links", "3", CVAR_NONE}; // 0=off; 1=outgoing only; 2=incoming only; 3=incoming+outgoing
cvar_t r_showbboxes_targets = {"r_showbboxes_targets", "1", CVAR_NONE};
cvar_t r_showfields = {"r_showfields", "0", CVAR_NONE};
cvar_t r_showfields_align = {"r_showfields_align", "1", CVAR_ARCHIVE}; // 0=entity pos; 1=bottom-right
cvar_t r_lerpmodels = {"r_lerpmodels", "1", CVAR_ARCHIVE};
cvar_t r_lerpmove = {"r_lerpmove", "1", CVAR_ARCHIVE};
cvar_t r_nolerp_list = {"r_nolerp_list", "progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", CVAR_NONE};
Expand Down
2 changes: 2 additions & 0 deletions Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern cvar_t r_showbboxes_health;
extern cvar_t r_showbboxes_links;
extern cvar_t r_showbboxes_targets;
extern cvar_t r_showfields;
extern cvar_t r_showfields_align;
extern cvar_t r_lerpmodels;
extern cvar_t r_lerpmove;
extern cvar_t r_nolerp_list;
Expand Down Expand Up @@ -335,6 +336,7 @@ void R_Init (void)
Cvar_RegisterVariable (&r_showbboxes_links);
Cvar_RegisterVariable (&r_showbboxes_targets);
Cvar_RegisterVariable (&r_showfields);
Cvar_RegisterVariable (&r_showfields_align);
Cvar_RegisterVariable (&gl_farclip);
Cvar_RegisterVariable (&gl_fullbrights);
Cvar_SetCallback (&gl_fullbrights, GL_Fullbrights_f);
Expand Down
9 changes: 5 additions & 4 deletions Quake/gl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ extern cvar_t con_notifyfadetime;

extern edict_t **bbox_linked;
extern cvar_t r_showfields;
extern cvar_t r_showfields_align;

qboolean scr_initialized; // ready to draw

Expand Down Expand Up @@ -1369,9 +1370,9 @@ void SCR_DrawEdictInfo (void)
// Compute anchor point
if (i == 0)
{
// With r_showfields < 0 the field overlay tracks the focused entity,
// With r_showfields_align 0 the field overlay tracks the focused entity,
// so we disable the simple one (number + classname) to avoid overlap.
if (r_showfields.value < 0.f)
if (!r_showfields_align.value)
continue;
//SCR_GetEntityBottom (ed, anchor);
SCR_GetEntityCenter (ed, anchor);
Expand Down Expand Up @@ -1418,8 +1419,8 @@ void SCR_DrawEdictInfo (void)
ProjectVector (anchor, r_matviewproj, proj);
SCR_ProjToCanvas (proj, &proj2canvas, &x, &y);

// r_showfields > 0 locks the overlay to the bottom-right
if (r_showfields.value > 0.f)
// r_showfields_align 1 locks the overlay to the bottom-right
if (r_showfields_align.value)
{
x = glcanvas.right;
y = glcanvas.bottom;
Expand Down

0 comments on commit e0b2397

Please sign in to comment.