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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "cbase.h"
#include "c_vguiscreen.h"
#include <vgui/IVGui.h>
#include "ienginevgui.h"
#include "vgui_bitmapimage.h"
#include "vgui_bitmappanel.h"
#include "vgui_controls/Label.h"
#include "tf_weapon_pda.h"
#include "vgui/ISurface.h"
#include "tf_controls.h"
#include "c_tf_player.h"
#include "tf_weapon_invis.h"
#include <vgui_controls/RadioButton.h>
#include "clientmode.h"
#include <vgui_controls/ProgressBar.h>
#include <vgui_controls/CircularProgressBar.h>
using namespace vgui;
//-----------------------------------------------------------------------------
// Control screen
//-----------------------------------------------------------------------------
class CPDAPanel : public CVGuiScreenPanel
{
DECLARE_CLASS( CPDAPanel, CVGuiScreenPanel );
public:
CPDAPanel( vgui::Panel *parent, const char *panelName );
~CPDAPanel();
virtual bool Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData );
virtual void OnTick();
protected:
C_BaseCombatWeapon *GetOwningWeapon();
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel, "pda_panel" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel::CPDAPanel( vgui::Panel *parent, const char *panelName )
: BaseClass( parent, "CPDAPanel", vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/PDAControlPanelScheme.res", "TFBase" ) )
{
}
CPDAPanel::~CPDAPanel()
{
}
//-----------------------------------------------------------------------------
// Initialization
//-----------------------------------------------------------------------------
bool CPDAPanel::Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData )
{
// Make sure we get ticked...
vgui::ivgui()->AddTickSignal( GetVPanel() );
if (!BaseClass::Init(pKeyValues, pInitData))
return false;
return true;
}
//-----------------------------------------------------------------------------
// Returns the object it's attached to
//-----------------------------------------------------------------------------
C_BaseCombatWeapon *CPDAPanel::GetOwningWeapon()
{
C_BaseEntity *pScreenEnt = GetEntity();
if (!pScreenEnt)
return NULL;
C_BaseEntity *pOwner = pScreenEnt->GetOwnerEntity();
if (!pOwner)
return NULL;
C_BaseViewModel *pViewModel = dynamic_cast< C_BaseViewModel * >( pOwner );
if ( !pViewModel )
return NULL;
return pViewModel->GetOwningWeapon();
}
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CPDAPanel::OnTick()
{
BaseClass::OnTick();
SetVisible( true );
}
//-----------------------------------------------------------------------------
// Engineer Destroy PDA
//-----------------------------------------------------------------------------
class CPDAPanel_Engineer_Destroy : public CPDAPanel
{
DECLARE_CLASS( CPDAPanel_Engineer_Destroy, CPDAPanel );
public:
CPDAPanel_Engineer_Destroy( vgui::Panel *parent, const char *panelName );
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Engineer_Destroy, "pda_panel_engineer_destroy" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Engineer_Destroy::CPDAPanel_Engineer_Destroy( vgui::Panel *parent, const char *panelName )
: CPDAPanel( parent, "CPDAPanel_Engineer_Destroy" )
{
}
//-----------------------------------------------------------------------------
// Engineer Build PDA
//-----------------------------------------------------------------------------
class CPDAPanel_Engineer_Build : public CPDAPanel
{
DECLARE_CLASS( CPDAPanel_Engineer_Build, CPDAPanel );
public:
CPDAPanel_Engineer_Build( vgui::Panel *parent, const char *panelName );
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Engineer_Build, "pda_panel_engineer_build" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Engineer_Build::CPDAPanel_Engineer_Build( vgui::Panel *parent, const char *panelName )
: CPDAPanel( parent, "CPDAPanel_Engineer" )
{
}
//-----------------------------------------------------------------------------
// Spy PDA
//-----------------------------------------------------------------------------
class CPDAPanel_Spy : public CPDAPanel
{
DECLARE_CLASS( CPDAPanel_Spy, CPDAPanel );
public:
CPDAPanel_Spy( vgui::Panel *parent, const char *panelName );
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Spy, "pda_panel_spy" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Spy::CPDAPanel_Spy( vgui::Panel *parent, const char *panelName )
: CPDAPanel( parent, "CPDAPanel_Spy" )
{
}
//-----------------------------------------------------------------------------
// Spy Invis PDA
//-----------------------------------------------------------------------------
class CPDAPanel_Spy_Invis : public CPDAPanel
{
DECLARE_CLASS( CPDAPanel_Spy_Invis, CPDAPanel );
public:
CPDAPanel_Spy_Invis( vgui::Panel *parent, const char *panelName );
virtual void OnTick();
private:
ProgressBar *m_pInvisProgress;
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Spy_Invis, "pda_panel_spy_invis" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Spy_Invis::CPDAPanel_Spy_Invis( vgui::Panel *parent, const char *panelName )
: CPDAPanel( parent, "CPDAPanel_Spy_Invis" )
{
vgui::ivgui()->AddTickSignal( GetVPanel() );
m_pInvisProgress = new ProgressBar( this, "InvisProgress" );
}
//-----------------------------------------------------------------------------
// Update the progress bar with how much invis we have left
//-----------------------------------------------------------------------------
void CPDAPanel_Spy_Invis::OnTick( void )
{
C_BaseCombatWeapon *pInvisWeapon = GetOwningWeapon();
if ( !pInvisWeapon )
return;
C_TFPlayer *pPlayer = ToTFPlayer( pInvisWeapon->GetOwner() );
if ( pPlayer && !pPlayer->IsDormant() )
{
if ( m_pInvisProgress )
{
float flMeter = pPlayer->m_Shared.GetSpyCloakMeter();
m_pInvisProgress->SetProgress( flMeter / 100.0f );
}
}
}
//-----------------------------------------------------------------------------
// Spy Invis PDA panel for the pocketwatch
//-----------------------------------------------------------------------------
class CPDAPanel_Spy_Invis_Pocket : public CPDAPanel
{
DECLARE_CLASS( CPDAPanel_Spy_Invis_Pocket, CPDAPanel );
public:
CPDAPanel_Spy_Invis_Pocket( vgui::Panel *parent, const char *panelName );
virtual void OnTick();
protected:
ProgressBar *m_pInvisProgress;
float m_flPrevProgress;
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Spy_Invis_Pocket, "pda_panel_spy_invis_pocket" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Spy_Invis_Pocket::CPDAPanel_Spy_Invis_Pocket( vgui::Panel *parent, const char *panelName )
: CPDAPanel( parent, "CPDAPanel_Spy_Invis_Pocket" )
{
vgui::ivgui()->AddTickSignal( GetVPanel() );
CircularProgressBar* pCircularProgressBar = new CircularProgressBar( this, "InvisProgress" );
pCircularProgressBar->SetReverseProgress( true );
m_pInvisProgress = pCircularProgressBar;
m_flPrevProgress = -1;
}
//-----------------------------------------------------------------------------
// Update the progress bar with how much invis we have left
//-----------------------------------------------------------------------------
void CPDAPanel_Spy_Invis_Pocket::OnTick( void )
{
C_BaseCombatWeapon *pInvisWeapon = GetOwningWeapon();
if ( !pInvisWeapon )
return;
C_TFPlayer *pPlayer = ToTFPlayer( pInvisWeapon->GetOwner() );
if ( pPlayer && !pPlayer->IsDormant() )
{
if ( m_pInvisProgress )
{
float flMeter = pPlayer->m_Shared.GetSpyCloakMeter();
if ( m_flPrevProgress != flMeter )
{
m_flPrevProgress = flMeter;
if ( flMeter == 100.f )
{
m_pInvisProgress->SetFgColor( COLOR_GREEN );
}
else if ( flMeter < 40.f )
{
m_pInvisProgress->SetFgColor( COLOR_RED );
}
else
{
m_pInvisProgress->SetFgColor( COLOR_YELLOW );
}
m_pInvisProgress->SetProgress( flMeter / 100.0f );
}
}
}
}
//-----------------------------------------------------------------------------
// Spy Invis PDA panel for the TTG pocketwatch
//-----------------------------------------------------------------------------
class CPDAPanel_Spy_Invis_Pocket_TTG : public CPDAPanel_Spy_Invis_Pocket
{
DECLARE_CLASS( CPDAPanel_Spy_Invis_Pocket_TTG, CPDAPanel_Spy_Invis_Pocket );
public:
CPDAPanel_Spy_Invis_Pocket_TTG( vgui::Panel *parent, const char *panelName );
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Spy_Invis_Pocket_TTG, "pda_panel_spy_invis_pocket_ttg" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Spy_Invis_Pocket_TTG::CPDAPanel_Spy_Invis_Pocket_TTG( vgui::Panel *parent, const char *panelName )
: CPDAPanel_Spy_Invis_Pocket( parent, "CPDAPanel_Spy_Invis_Pocket_TTG" )
{
dynamic_cast<CircularProgressBar*>(m_pInvisProgress)->SetStartSegment( 7 ); // Do the pellet first.
}
//-----------------------------------------------------------------------------
// Spy Invis PDA panel for the Hitman pocketwatch
//-----------------------------------------------------------------------------
class CPDAPanel_Spy_Invis_Pocket_HM : public CPDAPanel_Spy_Invis_Pocket
{
DECLARE_CLASS( CPDAPanel_Spy_Invis_Pocket_HM, CPDAPanel_Spy_Invis_Pocket );
public:
CPDAPanel_Spy_Invis_Pocket_HM( vgui::Panel *parent, const char *panelName );
};
DECLARE_VGUI_SCREEN_FACTORY( CPDAPanel_Spy_Invis_Pocket_HM, "pda_panel_spy_invis_pocket_hm" );
//-----------------------------------------------------------------------------
// Constructor:
//-----------------------------------------------------------------------------
CPDAPanel_Spy_Invis_Pocket_HM::CPDAPanel_Spy_Invis_Pocket_HM( vgui::Panel *parent, const char *panelName )
: CPDAPanel_Spy_Invis_Pocket( parent, "CPDAPanel_Spy_Invis_Pocket_HM" )
{
}
|