Skip to content

Commit

Permalink
Add hud_weapon
Browse files Browse the repository at this point in the history
Resolves YaLTeR#28
  • Loading branch information
YaLTeR authored and SmileyAG committed Dec 28, 2017
1 parent f3700c4 commit 4223ae2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ int CHudAmmo::Init(void)
CVAR_CREATE( "hud_drawhistory_time", HISTORY_DRAW_TIME, 0 );
CVAR_CREATE( "hud_fastswitch", "0", FCVAR_ARCHIVE ); // controls whether or not weapons can be selected in one keypress

hud_weapon = CVAR_CREATE("hud_weapon", 0, FCVAR_ARCHIVE);

m_iFlags |= HUD_ACTIVE; //!!!

gWR.Init();
Expand Down Expand Up @@ -874,6 +876,26 @@ int CHudAmmo::Draw(float flTime)
// Does this weapon have a clip?
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;

if (hud_weapon->value != 0.0f)
{
int r, g, b;

if (gWR.HasAmmo(m_pWeapon))
{
UnpackRGB(r, g, b, gHUD.m_iDefaultHUDColor);
ScaleColors(r, g, b, 192);
}
else
{
UnpackRGB(r, g, b, RGB_REDISH);
ScaleColors(r, g, b, 128);
}

SPR_Set(m_pWeapon->hInactive, r, g, b);
int offset = (m_pWeapon->rcInactive.bottom - m_pWeapon->rcInactive.top) / 8;
SPR_DrawAdditive(0, ScreenWidth / 1.73, y - offset, &m_pWeapon->rcInactive);
}

// Does weapon have any ammo at all?
if (m_pWeapon->iAmmoType > 0)
{
Expand Down
1 change: 1 addition & 0 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CHudAmmo: public CHudBase
int m_HUD_bucket0;
int m_HUD_selection;

cvar_t* hud_weapon;
};

//
Expand Down

0 comments on commit 4223ae2

Please sign in to comment.