Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/game/client/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ class CHud
int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b);
int DrawHudStringReverse(int xpos, int ypos, int iMinX, char *szString, int r, int g, int b);
int DrawHudStringColorCodes(int x, int y, int iMaxX, char *string, int _r, int _g, int _b);
int DrawHudStringColorCodesCentered(int x, int y, int iMaxX, char *string, int _r, int _g, int _b);
int DrawHudStringReverseColorCodes(int x, int y, int iMaxX, char *string, int _r, int _g, int _b);
int DrawHudNumberString(int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b);
int GetNumWidth(int iNumber, int iFlags);
int GetHudCharWidth(int c);
int GetHudStringWidthColorCodes(char *string);
int CalculateCharWidth(int c);

//! @returns The font height for string render functions.
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/hud/ag/ag_countdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void AgHudCountdown::Draw(float fTime)
{
// Write arena text.
sprintf(szText, "%s vs %s", m_szPlayer1, m_szPlayer2);
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 7, ScreenWidth, szText, r, g, b);
gHUD.DrawHudStringColorCodesCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 7, ScreenWidth, szText, r, g, b);
}
else
{
Expand All @@ -62,7 +62,7 @@ void AgHudCountdown::Draw(float fTime)
if (strlen(m_szPlayer1) != 0)
{
sprintf(szText, "Last round won by %s", m_szPlayer1);
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 7, ScreenWidth, szText, r, g, b);
gHUD.DrawHudStringColorCodesCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 7, ScreenWidth, szText, r, g, b);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/hud/ag/ag_vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void AgHudVote::Draw(float fTime)
sprintf(szText, "Vote: %s %s", m_szVote, m_szValue);
gHUD.DrawHudString(ScreenWidth / 20, ScreenHeight / 8, 0, szText, r, g, b);
sprintf(szText, "Called by: %s", m_szCalled);
AgDrawHudString(ScreenWidth / 20, ScreenHeight / 8 + gHUD.m_scrinfo.iCharHeight, ScreenWidth, szText, r, g, b);
gHUD.DrawHudStringColorCodes(ScreenWidth / 20, ScreenHeight / 8 + gHUD.m_scrinfo.iCharHeight, ScreenWidth, szText, r, g, b);
if (VoteStatus::Called == m_iVoteStatus)
{
sprintf(szText, "For: %d", m_iFor);
Expand Down
13 changes: 13 additions & 0 deletions src/game/client/hud_redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ int CHud::DrawHudStringReverse(int xpos, int ypos, int iMinX, char *szString, in
return xpos - gEngfuncs.pfnDrawStringReverse(xpos, ypos, szString, r, g, b);
}

int CHud::DrawHudStringColorCodesCentered(int x, int y, int iMaxX, char *string, int _r, int _g, int _b)
{
auto width = GetHudStringWidthColorCodes(string);
return DrawHudStringColorCodes(x - width / 2, y, iMaxX, string, _r, _g, _b);
}

int CHud::GetHudStringWidthColorCodes(char *string)
{
static char buffer[1024];
RemoveColorCodes(string, buffer, sizeof(buffer));
return DrawHudStringColorCodes(0, 0, 0, buffer, 0, 0, 0);
}

int CHud::DrawHudStringColorCodes(int x, int y, int iMaxX, char *string, int _r, int _g, int _b)
{
// How colorcodes work in DrawHudStringColorCodes
Expand Down
Loading