Browse Source

client: add cl_showpos

pull/2/head
Alibek Omarov 4 years ago
parent
commit
a813be7d54
  1. 37
      engine/client/cl_scrn.c
  2. 1
      engine/client/cl_view.c
  3. 1
      engine/client/client.h

37
engine/client/cl_scrn.c

@ -31,6 +31,7 @@ static convar_t *cl_envshot_size;
convar_t *v_dark; convar_t *v_dark;
static convar_t *net_speeds; static convar_t *net_speeds;
static convar_t *cl_showfps; static convar_t *cl_showfps;
static convar_t *cl_showpos;
typedef struct typedef struct
{ {
@ -104,6 +105,41 @@ void SCR_DrawFPS( int height )
Con_DrawString( refState.width - offset - 4, height, fpsstring, color ); Con_DrawString( refState.width - offset - 4, height, fpsstring, color );
} }
/*
==============
SCR_DrawPos
Draw local player position, angles and velocity
==============
*/
void SCR_DrawPos( void )
{
static char msg[MAX_SYSPATH];
float speed;
cl_entity_t *ent;
rgba_t color;
if( cls.state != ca_active || !cl_showpos->value || cl.background )
return;
ent = CL_GetLocalPlayer();
speed = VectorLength( cl.simvel );
Q_snprintf( msg, MAX_SYSPATH,
"pos: %.2f %.2f %.2f\n"
"ang: %.2f %.2f %.2f\n"
"velocity: %.2f",
cl.simorg[0], cl.simorg[1], cl.simorg[2],
// should we use entity angles or viewangles?
// view isn't always bound to player
ent->angles[0], ent->angles[1], ent->angles[2],
speed );
MakeRGBA( color, 255, 255, 255, 255 );
Con_DrawString( refState.width / 2, 4, msg, color );
}
/* /*
============== ==============
SCR_NetSpeeds SCR_NetSpeeds
@ -781,6 +817,7 @@ void SCR_Init( void )
scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" ); scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" );
net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" ); net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" );
cl_showfps = Cvar_Get( "cl_showfps", "1", FCVAR_ARCHIVE, "show client fps" ); cl_showfps = Cvar_Get( "cl_showfps", "1", FCVAR_ARCHIVE, "show client fps" );
cl_showpos = Cvar_Get( "cl_showpos", "0", FCVAR_ARCHIVE, "show local player position and velocity" );
// register our commands // register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );

1
engine/client/cl_view.c

@ -475,6 +475,7 @@ void V_PostRender( void )
{ {
SCR_RSpeeds(); SCR_RSpeeds();
SCR_NetSpeeds(); SCR_NetSpeeds();
SCR_DrawPos();
SCR_DrawNetGraph(); SCR_DrawNetGraph();
SV_DrawOrthoTriangles(); SV_DrawOrthoTriangles();
CL_DrawDemoRecording(); CL_DrawDemoRecording();

1
engine/client/client.h

@ -880,6 +880,7 @@ void SCR_MakeLevelShot( void );
void SCR_NetSpeeds( void ); void SCR_NetSpeeds( void );
void SCR_RSpeeds( void ); void SCR_RSpeeds( void );
void SCR_DrawFPS( int height ); void SCR_DrawFPS( int height );
void SCR_DrawPos( void );
// //
// cl_netgraph.c // cl_netgraph.c

Loading…
Cancel
Save