Skip to content

Commit

Permalink
Rainbow HUD: Use GetHudStringWidth to get string width
Browse files Browse the repository at this point in the history
Call the engine pfnDrawString function (via GetHudStringWidth) when calculating string width instead of hooked gEngfuncs.pfnDrawString to avoid char-by-char rendering in CRainbowHUD::DrawString.
  • Loading branch information
tmp64 authored and YaLTeR committed Jun 3, 2021
1 parent 93f980a commit 2136446
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cl_dll/rainbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ int CRainbow::DrawString(int x, int y, const char *str, int r, int g, int b)

int CRainbow::DrawStringReverse(int x, int y, const char *str, int r, int g, int b)
{
// Calc string width by drawing outside the screen
int width = gEngfuncs.pfnDrawString(ScreenWidth + 1, y, str, r, g, b);
// Get string width
int width = gHUD.GetHudStringWidth(str);

// Draw it shifted to the left by width pixels
return x + DrawString(x - width, y, str, r, g, b);
Expand Down

0 comments on commit 2136446

Please sign in to comment.