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:
//
// $NoKeywords: $
//=============================================================================
#include "cbase.h"
#include "hud.h"
#include "hudelement.h"
#include "hud_macros.h"
#include "c_tf_player.h"
#include "iclientmode.h"
#include "ienginevgui.h"
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui/IVGui.h>
#include <vgui_controls/Label.h>
#include <vgui_controls/EditablePanel.h>
#include "tf_imagepanel.h"
#include "tf_gamerules.h"
#include "c_tf_team.h"
#include "tf_controls.h"
#include "hud_basechat.h"
#include "c_team_objectiveresource.h"
#include "tf_hud_training.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CHudTrainingInfoMsg : public CHudElement, public EditablePanel
{
DECLARE_CLASS_SIMPLE( CHudTrainingInfoMsg, EditablePanel );
public:
CHudTrainingInfoMsg( const char *pElementName );
virtual void Init( void );
virtual void Reset( void );
virtual void ApplySchemeSettings( IScheme *scheme );
virtual bool ShouldDraw( void );
void MsgFunc_TrainingInfoMsg( bf_read &msg );
void LocalizeAndDisplay( const char *szRawString );
private:
Label *m_pGoalLabel;
//Color m_cRegularColor;
};
DECLARE_HUDELEMENT( CHudTrainingInfoMsg );
DECLARE_HUD_MESSAGE( CHudTrainingInfoMsg, TrainingInfoMsg );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CHudTrainingInfoMsg::CHudTrainingInfoMsg( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudTrainingInfoMsg" )
{
Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );
SetHiddenBits( HIDEHUD_MISCSTATUS );
RegisterForRenderGroup( "commentary" );
SetVisible( false );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrainingInfoMsg::Reset()
{
SetVisible( false );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrainingInfoMsg::Init()
{
HOOK_HUD_MESSAGE( CHudTrainingInfoMsg, TrainingInfoMsg );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudTrainingInfoMsg::ApplySchemeSettings( IScheme *pScheme )
{
// load control settings...
LoadControlSettings( "resource/UI/HudTrainingInfoMsg.res" );
BaseClass::ApplySchemeSettings( pScheme );
m_pGoalLabel = dynamic_cast<Label *>( FindChildByName("GoalLabel") );
//m_cRegularColor = pScheme->GetColor( "TanLight", Color( 0, 0, 0 ) );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudTrainingInfoMsg::ShouldDraw( void )
{
return IsVisible();
}
//-----------------------------------------------------------------------------
// Purpose: Activates the hint display
//-----------------------------------------------------------------------------
void CHudTrainingInfoMsg::MsgFunc_TrainingInfoMsg( bf_read &msg )
{
// Read the string(s)
char szString[255];
msg.ReadString( szString, sizeof(szString) );
if ( !szString[0] )
{
SetVisible( false );
return;
}
//Localize and display the string.
wchar_t outputText[MAX_TRAINING_MSG_LENGTH];
CTFHudTraining::FormatTrainingText(szString , outputText);
SetVisible( true );
m_pGoalLabel->SetText( outputText );
//g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "HintMessageShow" );
//g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "HintMessageHide" );
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
if ( pLocalPlayer )
{
pLocalPlayer->EmitSound( "Hud.Hint" );
}
}
|