Skip to content

Commit

Permalink
Merge pull request #257 from ScriptedSnark/extended_hud
Browse files Browse the repository at this point in the history
Client: HUD: Support 4+ digits for health/armor HUD elements
  • Loading branch information
tmp64 authored Dec 31, 2024
2 parents b06b59d + 0318a7f commit 3b4cdcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/game/client/hud/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ int CHudBattery::MsgFunc_Battery(const char *pszName, int iSize, void *pbuf)

BEGIN_READ(pbuf, iSize);
int battery = READ_SHORT();
battery = clamp(battery, 0, 999);

if (battery != m_iBat)
{
Expand Down Expand Up @@ -121,5 +120,9 @@ void CHudBattery::Draw(float flTime)
}

x += m_rc1.GetWidth();
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);

if (m_iBat < 1000)
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
else
x = gHUD.DrawHudNumber(x, y, m_iBat, r, g, b);
}
7 changes: 5 additions & 2 deletions src/game/client/hud/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void CHudHealth::Draw(float flTime)
// Apply wider range health from client_state_t structure, if available
cl_entity_t *player = gEngfuncs.GetLocalPlayer();
int health = player->curstate.health;
health = clamp(health, 0, 999);

if (m_iHealth != health && health > 255)
{
m_fFade = FADE_TIME;
Expand Down Expand Up @@ -221,7 +221,10 @@ void CHudHealth::Draw(float flTime)

x = CrossWidth + HealthWidth / 2;

x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
if (m_iHealth < 1000)
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
else
x = gHUD.DrawHudNumber(x, y, m_iHealth, r, g, b);

x += HealthWidth / 2;

Expand Down

0 comments on commit 3b4cdcf

Please sign in to comment.