Skip to content

Commit e124c2e

Browse files
authored
Merge pull request #291 from rtxa/fix-damage-indicators-custom-hud
Fix damage indicators not being draw on custom HUD
2 parents fed5bf1 + 22e5ca9 commit e124c2e

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

gamedir/ui/scripts/HudLayoutBase.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{
1414
"statusbar_ypos" "r45"
1515
"ammohistory_ypos" "r42"
16+
"damage_ypos" "r16"
1617
"weapon_xpos" "150"
1718
}
1819

src/game/client/hud/health.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,18 @@ void CHudHealth::Draw(float flTime)
174174
float a;
175175
int HealthWidth;
176176

177-
if (hud_custom.GetBool())
178-
return;
179-
180177
if ((gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly())
181178
return;
182179

183180
if (!m_hSprite)
184181
m_hSprite = LoadSprite(PAIN_NAME);
182+
183+
if (hud_custom.GetBool())
184+
{
185+
DrawDamage(flTime);
186+
DrawPain(flTime);
187+
return;
188+
}
185189

186190
if (!hud_dim.GetBool())
187191
a = MIN_ALPHA + ALPHA_POINTS_MAX;
@@ -468,7 +472,7 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
468472
{
469473
// put this one at the bottom
470474
pdmg->x = giDmgWidth / 8;
471-
pdmg->y = ScreenHeight - giDmgHeight * 2;
475+
pdmg->y = (hud_custom.GetBool() ? g_pViewport->GetDamageYPos() : ScreenHeight) - giDmgHeight * 2;
472476
pdmg->fExpire = flTime + DMG_IMAGE_LIFE;
473477

474478
// move everyone else up

src/game/client/vgui/client_viewport.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ void CClientViewport::ReloadLayout()
149149
{
150150
const char* szStatusBarY = vanillaKV->GetString("statusbar_ypos", "0");
151151
const char* szAmmoHistoryY = vanillaKV->GetString("ammohistory_ypos", "0");
152+
const char* szDamageY = vanillaKV->GetString("damage_ypos", "0");
152153
const char* szWeaponX = vanillaKV->GetString("weapon_xpos", "0");
153154

154155
ComputePos(szStatusBarY, m_iStatusBarYPos, 0, GetTall(), true);
155156
ComputePos(szAmmoHistoryY, m_iAmmoHistoryYPos, 0, GetTall(), true);
157+
ComputePos(szDamageY, m_iDamageYPos, 0, GetTall(), true);
156158
ComputePos(szWeaponX, m_iWeaponXPos, 0, GetWide(), true);
157159
}
158160

@@ -371,6 +373,11 @@ int CClientViewport::GetStatusBarYPos()
371373
return m_iStatusBarYPos;
372374
}
373375

376+
int CClientViewport::GetDamageYPos()
377+
{
378+
return m_iDamageYPos;
379+
}
380+
374381
int CClientViewport::GetWeaponXPos()
375382
{
376383
return m_iWeaponXPos;

src/game/client/vgui/client_viewport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class CClientViewport : public vgui2::EditablePanel
7676
// Allows to get custom positions to avoid overlapping with other panels
7777
int GetAmmoHistoryYPos();
7878
int GetStatusBarYPos();
79+
int GetDamageYPos();
7980
int GetWeaponXPos();
8081

8182
bool IsScoreBoardVisible();
@@ -153,6 +154,7 @@ class CClientViewport : public vgui2::EditablePanel
153154
// Custom HUD positions
154155
int m_iStatusBarYPos = 0;
155156
int m_iAmmoHistoryYPos = 0;
157+
int m_iDamageYPos = 0;
156158
int m_iWeaponXPos = 0;
157159

158160
Color m_pTeamColors[5] = {

0 commit comments

Comments
 (0)