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
122
123
124
125
126
127
128
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hudelement.h"
#include <vgui_controls/Panel.h>
#include <vgui/ISurface.h>
#include "clientmode_csnormal.h"
#include "cs_gamerules.h"
#include "hud_numericdisplay.h"
class CHudC4 : public CHudElement, public vgui::Panel
{
public:
DECLARE_CLASS_SIMPLE( CHudC4, vgui::Panel );
CHudC4( const char *name );
virtual bool ShouldDraw();
virtual void Paint();
virtual void Init();
private:
CPanelAnimationVar( Color, m_clrIcon, "IconColor", "IconColor" );
CPanelAnimationVar( Color, m_clrFlash, "FlashColor", "FlashColor" );
CHudTexture *m_pIcon;
float m_flNextFlashTime;
bool m_bFlash;
};
DECLARE_HUDELEMENT( CHudC4 );
CHudC4::CHudC4( const char *pName ) :
vgui::Panel( NULL, "HudC4" ), CHudElement( pName )
{
SetParent( g_pClientMode->GetViewport() );
m_pIcon = NULL;
SetHiddenBits( HIDEHUD_PLAYERDEAD );
//=============================================================================
// HPE_BEGIN:
// [tj] Add this to the render group that disappears when the scoreboard is up
//=============================================================================
RegisterForRenderGroup( "hide_for_scoreboard" );
//=============================================================================
// HPE_END
//=============================================================================
}
void CHudC4::Init()
{
m_flNextFlashTime = 0;
m_bFlash = false;
}
bool CHudC4::ShouldDraw()
{
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
// if we are spectating another player first person, check this player
if ( pPlayer && (pPlayer->GetObserverMode() == OBS_MODE_IN_EYE) )
{
pPlayer = ToCSPlayer( pPlayer->GetObserverTarget() );
}
//=============================================================================
// HPE_BEGIN:
// [tj] Added base class call
//=============================================================================
return pPlayer && pPlayer->HasC4() && CHudElement::ShouldDraw();
//=============================================================================
// HPE_END
//=============================================================================
}
void CHudC4::Paint()
{
if ( !m_pIcon )
{
m_pIcon = gHUD.GetIcon( "c4" );
}
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
if ( !pPlayer )
return;
if( pPlayer->m_bInBombZone )
{
if( m_flNextFlashTime < gpGlobals->curtime )
{
m_bFlash = !m_bFlash;
m_flNextFlashTime = gpGlobals->curtime + 0.15;
}
}
else
{
m_bFlash = false;
}
int x, y, w, h;
GetBounds( x, y, w, h );
if ( m_pIcon )
{
if( m_bFlash )
{
m_pIcon->DrawSelf( 0, 0, w, h, m_clrFlash );
}
else
{
m_pIcon->DrawSelf( 0, 0, w, h, m_clrIcon );
}
}
}
|