mirror of
https://github.com/nzp-team/quakec.git
synced 2025-02-07 17:11:02 +00:00
Merge pull request #95 from erysdren/show_speed
CLIENT: player debug info display cvar
This commit is contained in:
commit
317da95764
3 changed files with 59 additions and 1 deletions
|
@ -91,4 +91,18 @@ void(vector position, string text, vector size, vector rgb, float alpha, float d
|
|||
else
|
||||
x += (font_kerningamount[(chr - 33)] + 1) * (size_x/8);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void(vector pos, string label, vector v) Draw_FancyVector =
|
||||
{
|
||||
Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0);
|
||||
Draw_String(pos + [32, 16], sprintf("X: %d", v.x), [12, 12], [1, 1, 1], 1, 0);
|
||||
Draw_String(pos + [32, 32], sprintf("Y: %d", v.y), [12, 12], [1, 1, 1], 1, 0);
|
||||
Draw_String(pos + [32, 48], sprintf("Z: %d", v.z), [12, 12], [1, 1, 1], 1, 0);
|
||||
};
|
||||
|
||||
void(vector pos, string label, float f, string suffix) Draw_FancyFloat =
|
||||
{
|
||||
Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0);
|
||||
Draw_String(pos + [32, 16], sprintf("%d %s", f, suffix), [12, 12], [1, 1, 1], 1, 0);
|
||||
};
|
||||
|
|
|
@ -1934,6 +1934,41 @@ void(float width, float height) HUD_RoundStopWatch =
|
|||
Draw_String([width - (getTextWidth(stopwatch, 12)) - 2, 16], stopwatch, [12, 12], [1, 1, 1], 1, 0);
|
||||
}
|
||||
|
||||
/*******************
|
||||
* HUD Debug Info *
|
||||
*******************/
|
||||
|
||||
// set from CSQC_Ent_Update
|
||||
vector player_velocity;
|
||||
|
||||
void(float width, float height) HUD_PlayerDebugInfo =
|
||||
{
|
||||
static float lastupstime;
|
||||
static float lastups;
|
||||
|
||||
if (!cvar("scr_playerdebuginfo"))
|
||||
return;
|
||||
|
||||
if ((time - lastupstime) >= 1.0 / 20)
|
||||
{
|
||||
lastups = vlen(player_velocity);
|
||||
lastupstime = time;
|
||||
}
|
||||
|
||||
vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")];
|
||||
pos.x += GetUltraWideOffset();
|
||||
|
||||
drawfill(pos - [8, 8], [128, 192], [0, 0, 0], 0.75, 0);
|
||||
|
||||
Draw_FancyFloat(pos, "Speed:", lastups, "qu/s");
|
||||
|
||||
if (cvar("scr_playerdebuginfo") >= 2)
|
||||
{
|
||||
Draw_FancyVector(pos + [0, 36], "Angles:", getproperty(VF_ANGLES));
|
||||
Draw_FancyVector(pos + [0, 106], "Origin:", getproperty(VF_ORIGIN));
|
||||
}
|
||||
};
|
||||
|
||||
/*******************
|
||||
* HUD Draw *
|
||||
*******************/
|
||||
|
@ -2014,6 +2049,8 @@ void(float width, float height) HUD_Draw =
|
|||
HUD_Scores();
|
||||
|
||||
HUD_Achievements(width, height);
|
||||
|
||||
HUD_PlayerDebugInfo(width, height);
|
||||
|
||||
if (screenflash_duration > time)
|
||||
HUD_Screenflash();
|
||||
|
|
|
@ -175,6 +175,10 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
|
|||
autocvar(in_rumbleenabled, 1);
|
||||
autocvar(in_aimassist, 0);
|
||||
|
||||
autocvar(scr_playerdebuginfo, 0);
|
||||
autocvar(scr_playerdebuginfo_x, 64);
|
||||
autocvar(scr_playerdebuginfo_y, 6);
|
||||
|
||||
// Runtime check if we're running this in WebASM/WebGL.
|
||||
if (cvar_string("sys_platform") == "Web")
|
||||
platform_is_web = true;
|
||||
|
@ -430,6 +434,9 @@ noref void(float isnew) CSQC_Ent_Update =
|
|||
self.is_in_menu = readbyte();
|
||||
self.is_spectator = readbyte();
|
||||
|
||||
// set for HUD_PlayerDebugInfo
|
||||
player_velocity = self.velocity;
|
||||
|
||||
setmodelindex(self, self.modelindex);
|
||||
|
||||
if (self.is_spectator)
|
||||
|
|
Loading…
Reference in a new issue