From 167e85acf9cb0eac369006d70baff695129fed14 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 08:24:56 -0600 Subject: [PATCH] CLIENT: HUD_PlayerDebugInfo() --- source/client/hud.qc | 34 +++++++++++++++++++++------------- source/client/main.qc | 8 ++++++-- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/source/client/hud.qc b/source/client/hud.qc index 79d7930..ca2fafe 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -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 lastups; - if (!cvar("show_speed")) + if (!cvar("scr_playerdebuginfo")) return; if ((time - lastupstime) >= 1.0 / 20) { - vector vel = [ - getstatf(STAT_VELOCITY_X), - getstatf(STAT_VELOCITY_Y), - getstatf(STAT_VELOCITY_Z) - ]; - - lastups = vlen(vel); + lastups = vlen(player_velocity); lastupstime = time; } - string str = sprintf("%3.1f UPS", lastups); - vector pos = [cvar("show_speed_x"), cvar("show_speed_y")]; + string str = sprintf("speed: %3.1f qu/s", lastups); + vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; 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); - Draw_UPS(); + HUD_PlayerDebugInfo(width, height); if (screenflash_duration > time) HUD_Screenflash(); diff --git a/source/client/main.qc b/source/client/main.qc index fa7e9eb..e4a4b5d 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -175,8 +175,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(in_rumbleenabled, 1); autocvar(in_aimassist, 0); - cvar_set("show_speed_x", ftos(32)); - cvar_set("show_speed_y", ftos(32)); + autocvar(scr_playerdebuginfo, 0); + autocvar(scr_playerdebuginfo_x, 48); + autocvar(scr_playerdebuginfo_y, 48); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") @@ -432,6 +433,9 @@ noref void(float isnew) CSQC_Ent_Update = self.kills = readshort(); self.is_in_menu = readbyte(); + // set for HUD_PlayerDebugInfo + player_velocity = self.velocity; + RegisterPointChange(self.points - old_points, self.playernum); if (self.movetype == MOVETYPE_BOUNCE)