Skip to content

Commit

Permalink
Client: HUD: Replace m_iTextSize with iCharHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Dec 17, 2023
1 parent 63af97e commit 0dc650b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
19 changes: 0 additions & 19 deletions src/game/client/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ void CHud::VidInit(void)
if (m_iRes == -1)
m_iRes = GetHudSize(m_scrinfo, GetMaxHudScale());

m_iTextSize = GetTextSize();

// Only load this once
if (!m_pSpriteList)
{
Expand Down Expand Up @@ -839,23 +837,6 @@ EHudScale CHud::DetectMaxHudScale()
return pMaxScaleInfo->nScale;
}

int CHud::GetTextSize()
{
vgui2::HScheme hScheme = g_pVGuiSchemeManager->GetDefaultScheme();
if (!hScheme)
return 0;

vgui2::IScheme *pScheme = g_pVGuiSchemeManager->GetIScheme(hScheme);
if (!pScheme)
return 0;

vgui2::HFont hFont = pScheme->GetFont("CreditsFont", true);
if (!hFont)
return 0;

return g_pVGuiSurface->GetFontTall(hFont);
}

CON_COMMAND(append, "Puts a command into the end of the command buffer")
{
if (gEngfuncs.Cmd_Argc() != 2)
Expand Down
7 changes: 3 additions & 4 deletions src/game/client/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class CHud
int m_Teamplay;
int m_iRes = -1;
int m_iFontHeight; //!< Sprite font height
int m_iTextSize = 0; //!< Text font height
int m_iWeaponBits;
int m_fPlayerDead;
int m_iIntermission;
Expand Down Expand Up @@ -177,6 +176,9 @@ class CHud
int GetHudCharWidth(int c);
int CalculateCharWidth(int c);

//! @returns The font height for string render functions.
int GetHudFontSize() { return m_scrinfo.iCharHeight; }

//-----------------------------------------------------
// Sprite functions
//-----------------------------------------------------
Expand Down Expand Up @@ -306,9 +308,6 @@ class CHud
//! Detects the maximum supported HUD scale.
EHudScale DetectMaxHudScale();

//! @returns The font size used by engine text draw functions.
int GetTextSize();

template <typename T>
inline T *RegisterHudElem()
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/hud/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int HistoryResource::DrawAmmoHistory(float flTime)
}

// Draw the number
int yposText = ypos + rcPic.GetHeight() / 2 - gHUD.m_iTextSize / 2;
int yposText = ypos + rcPic.GetHeight() / 2 - gHUD.GetHudFontSize() / 2;
gHUD.DrawHudNumberString(xpos - itemWidth, yposText, xpos - 100, rgAmmoHistory[i].iCount, r, g, b);
}
else if (rgAmmoHistory[i].type == HISTSLOT_WEAP)
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/hud/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void CHudMenu::Draw(float flTime)
return;

// draw the menu, along the left-hand side of the screen
const int lineHeight = gHUD.m_iTextSize;
const int lineHeight = gHUD.GetHudFontSize();

// count the number of newlines
int nlc = 0;
Expand Down

0 comments on commit 0dc650b

Please sign in to comment.