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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hudelement.h"
#include "hud_macros.h"
#include "iclientmode.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/imaterial.h"
#include "materialsystem/imaterialvar.h"
#include "hl1_hud_numbers.h"
#include <vgui_controls/Controls.h>
#include <vgui_controls/Panel.h>
#include <vgui/ISurface.h>
using namespace vgui;
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
class CHudTrain: public CHudElement, public CHL1HudNumbers
{
DECLARE_CLASS_SIMPLE( CHudTrain, CHL1HudNumbers );
public:
CHudTrain( const char *pElementName );
void Init( void );
void VidInit( void );
bool ShouldDraw( void );
void MsgFunc_Train(bf_read &msg);
private:
void Paint( void );
void ApplySchemeSettings( vgui::IScheme *scheme );
private:
int m_iPos;
CHudTexture *icon_train;
};
//
//-----------------------------------------------------
//
DECLARE_HUDELEMENT( CHudTrain );
DECLARE_HUD_MESSAGE( CHudTrain, Train )
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CHudTrain::CHudTrain( const char *pElementName ) : CHudElement( pElementName ), BaseClass(NULL, "HudTrain")
{
SetHiddenBits( HIDEHUD_MISCSTATUS );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *scheme -
//-----------------------------------------------------------------------------
void CHudTrain::ApplySchemeSettings( IScheme *scheme )
{
BaseClass::ApplySchemeSettings( scheme );
SetPaintBackgroundEnabled( false );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrain::Init(void)
{
HOOK_HUD_MESSAGE( CHudTrain, Train );
m_iPos = 0;
}
void CHudTrain::VidInit(void)
{
BaseClass::VidInit();
m_iPos = 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudTrain::ShouldDraw( void )
{
return ( CHudElement::ShouldDraw() && m_iPos );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrain::Paint()
{
if ( !icon_train )
{
icon_train = gHUD.GetIcon( "train" );
}
if ( !icon_train )
{
return;
}
int r, g, b, a;
int x, y;
Color clrTrain;
(gHUD.m_clrYellowish).GetColor( r, g, b, a );
clrTrain.SetColor( r, g, b, a );
int nHudElemWidth, nHudElemHeight;
GetSize( nHudElemWidth, nHudElemHeight );
// This should show up to the right and part way up the armor number
y = nHudElemHeight - icon_train->Height() - GetNumberFontHeight();
x = nHudElemWidth / 3 + icon_train->Width() / 4;
IMaterial *material = materials->FindMaterial( icon_train->szTextureFile, TEXTURE_GROUP_VGUI );
if ( material )
{
bool found;
IMaterialVar* pFrameVar = material->FindVar( "$frame", &found, false );
if ( found )
{
pFrameVar->SetFloatValue( m_iPos - 1 );
}
}
icon_train->DrawSelf( x, y, clrTrain );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrain::MsgFunc_Train( bf_read &msg )
{
m_iPos = msg.ReadByte();
}
|