1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hudelement.h"
#include <vgui_controls/Panel.h>
#include <vgui/ISurface.h>
#include "c_dod_player.h"
#include "iclientmode.h"
#include "c_dod_playerresource.h"
#include "weapon_mg42.h"
class CHudMGHeatIcon : public CHudElement, public vgui::Panel
{
public:
DECLARE_CLASS_SIMPLE( CHudMGHeatIcon, vgui::Panel );
CHudMGHeatIcon( const char *name );
virtual void Paint();
virtual void Init();
virtual bool ShouldDraw();
private:
CHudTexture *m_pBarrel;
CHudTexture *m_pHotBarrel;
Color m_clrIcon;
};
DECLARE_HUDELEMENT( CHudMGHeatIcon );
CHudMGHeatIcon::CHudMGHeatIcon( const char *pName ) :
vgui::Panel( NULL, "HudMGHeatIcon" ), CHudElement( pName )
{
SetParent( g_pClientMode->GetViewport() );
m_clrIcon = Color(255,255,255,255);
SetHiddenBits( HIDEHUD_PLAYERDEAD );
}
void CHudMGHeatIcon::Init()
{
if( !m_pBarrel )
{
m_pBarrel = gHUD.GetIcon( "hud_barrel" );
}
if( !m_pHotBarrel )
{
m_pHotBarrel = gHUD.GetIcon( "hud_barrelo" );
}
}
bool CHudMGHeatIcon::ShouldDraw()
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if( !pPlayer )
return false;
//is their active weapon an mg42 ?
CWeaponDODBase *pWeapon = pPlayer->GetActiveDODWeapon();
if( pWeapon && pWeapon->IsA( WEAPON_MG42 ) )
return true;
return false;
}
void CHudMGHeatIcon::Paint()
{
int x,y,w,h;
GetBounds( x,y,w,h );
if( !m_pBarrel )
{
m_pBarrel = gHUD.GetIcon( "hud_barrel" );
}
if( !m_pHotBarrel )
{
m_pHotBarrel = gHUD.GetIcon( "hud_barrelo" );
}
//draw the base
m_pBarrel->DrawSelf( 0, 0, m_clrIcon );
float flPercentHotness = 0.0f;
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if( !pPlayer )
return;
CWeaponDODBase *pWeapon = pPlayer->GetActiveDODWeapon();
if( pWeapon && pWeapon->IsA( WEAPON_MG42 ) )
{
CWeaponMG42 *pMG42 = (CWeaponMG42 *)pWeapon;
if( pMG42 )
{
flPercentHotness = (float)pMG42->GetWeaponHeat() / 100.0;
}
}
int nOffset = m_pHotBarrel->Height() * ( 1.0 - flPercentHotness );
if ( nOffset < m_pHotBarrel->Height() )
{
m_pHotBarrel->DrawSelfCropped( 0, nOffset, 0, nOffset, m_pHotBarrel->Width(), m_pHotBarrel->Height() - nOffset, m_clrIcon );
}
}
|