CLIENT: HUD_PlayerDebugInfo()

This commit is contained in:
erysdren 2024-12-08 08:24:56 -06:00
parent 81b033318d
commit 167e85acf9
2 changed files with 27 additions and 15 deletions

View file

@ -1926,32 +1926,40 @@ void(float width, float height) HUD_RoundStopWatch =
} }
/******************* /*******************
* HUD UPS * * HUD Debug Info *
*******************/ *******************/
void() Draw_UPS = // set from CSQC_Ent_Update
vector player_velocity;
void(float width, float height) HUD_PlayerDebugInfo =
{ {
static float lastupstime; static float lastupstime;
static float lastups; static float lastups;
if (!cvar("show_speed")) if (!cvar("scr_playerdebuginfo"))
return; return;
if ((time - lastupstime) >= 1.0 / 20) if ((time - lastupstime) >= 1.0 / 20)
{ {
vector vel = [ lastups = vlen(player_velocity);
getstatf(STAT_VELOCITY_X),
getstatf(STAT_VELOCITY_Y),
getstatf(STAT_VELOCITY_Z)
];
lastups = vlen(vel);
lastupstime = time; lastupstime = time;
} }
string str = sprintf("%3.1f UPS", lastups); string str = sprintf("speed: %3.1f qu/s", lastups);
vector pos = [cvar("show_speed_x"), cvar("show_speed_y")]; vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")];
Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0);
if (cvar("scr_playerdebuginfo") >= 2)
{
pos.y += 16;
str = sprintf("angles: %v", getproperty(VF_ANGLES));
Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0);
pos.y += 16;
str = sprintf("origin: %v", getproperty(VF_ORIGIN));
Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0);
}
}; };
/******************* /*******************
@ -2029,7 +2037,7 @@ void(float width, float height) HUD_Draw =
HUD_Achievements(width, height); HUD_Achievements(width, height);
Draw_UPS(); HUD_PlayerDebugInfo(width, height);
if (screenflash_duration > time) if (screenflash_duration > time)
HUD_Screenflash(); HUD_Screenflash();

View file

@ -175,8 +175,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
autocvar(in_rumbleenabled, 1); autocvar(in_rumbleenabled, 1);
autocvar(in_aimassist, 0); autocvar(in_aimassist, 0);
cvar_set("show_speed_x", ftos(32)); autocvar(scr_playerdebuginfo, 0);
cvar_set("show_speed_y", ftos(32)); autocvar(scr_playerdebuginfo_x, 48);
autocvar(scr_playerdebuginfo_y, 48);
// Runtime check if we're running this in WebASM/WebGL. // Runtime check if we're running this in WebASM/WebGL.
if (cvar_string("sys_platform") == "Web") if (cvar_string("sys_platform") == "Web")
@ -432,6 +433,9 @@ noref void(float isnew) CSQC_Ent_Update =
self.kills = readshort(); self.kills = readshort();
self.is_in_menu = readbyte(); self.is_in_menu = readbyte();
// set for HUD_PlayerDebugInfo
player_velocity = self.velocity;
RegisterPointChange(self.points - old_points, self.playernum); RegisterPointChange(self.points - old_points, self.playernum);
if (self.movetype == MOVETYPE_BOUNCE) if (self.movetype == MOVETYPE_BOUNCE)