blob: 3f6d22e7226342ed6b06577cbacef5be00e342da (
plain) (
blame)
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "iclientmode.h"
#include "hud.h"
#include "hudelement.h"
#include <vgui/IScheme.h>
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/Label.h>
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CTFWaitingForPlayersPanel : public EditablePanel, public CHudElement
{
private:
DECLARE_CLASS_SIMPLE( CTFWaitingForPlayersPanel, EditablePanel );
public:
CTFWaitingForPlayersPanel( const char *pElementName );
virtual void LevelInit();
virtual void Init();
virtual void FireGameEvent( IGameEvent * event );
virtual void ApplySchemeSettings( IScheme *pScheme );
virtual bool ShouldDraw( void );
private:
Label *m_pWaitingForPlayersLabel;
Label *m_pWaitingForPlayersEndingLabel;
};
DECLARE_HUDELEMENT_DEPTH( CTFWaitingForPlayersPanel, 1 );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFWaitingForPlayersPanel::CTFWaitingForPlayersPanel( const char *pElementName )
: EditablePanel( NULL, "WaitingForPlayersPanel" ), CHudElement( pElementName )
{
Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );
SetScheme( "ClientScheme" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWaitingForPlayersPanel::LevelInit()
{
SetVisible( false );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWaitingForPlayersPanel::Init()
{
// listen for events
ListenForGameEvent( "teamplay_waiting_begins" );
ListenForGameEvent( "teamplay_waiting_ends" );
ListenForGameEvent( "teamplay_waiting_abouttoend" );
SetVisible( false );
CHudElement::Init();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWaitingForPlayersPanel::ApplySchemeSettings( IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
LoadControlSettings( "resource/UI/WaitingForPlayersPanel.res" );
m_pWaitingForPlayersLabel = dynamic_cast<Label *>(FindChildByName( "WaitingForPlayersLabel" ));
m_pWaitingForPlayersEndingLabel = dynamic_cast<Label *>(FindChildByName( "WaitingForPlayersEndingLabel" ));
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWaitingForPlayersPanel::FireGameEvent( IGameEvent * event )
{
const char *pEventName = event->GetName();
if ( Q_strcmp( "teamplay_waiting_ends", pEventName ) == 0 )
{
SetVisible( false );
}
else if ( Q_strcmp( "teamplay_waiting_begins", pEventName ) == 0 )
{
SetVisible( true );
m_pWaitingForPlayersLabel->SetVisible( true );
m_pWaitingForPlayersEndingLabel->SetVisible( false );
}
else if ( Q_strcmp( "teamplay_waiting_abouttoend", pEventName ) == 0 )
{
SetVisible( true );
m_pWaitingForPlayersLabel->SetVisible( false );
m_pWaitingForPlayersEndingLabel->SetVisible( true );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFWaitingForPlayersPanel::ShouldDraw( void )
{
return ( IsVisible() );
}
|