blob: 28ba950562d77dc4b81bd90096d026345f5bbc78 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include <KeyValues.h>
#include <vgui/IScheme.h>
#include <vgui/ISurface.h>
#include <vgui/ISystem.h>
#include <vgui_controls/AnimationController.h>
#include <vgui_controls/EditablePanel.h>
#include <vgui/ISurface.h>
#include <vgui/IImage.h>
#include <vgui_controls/Label.h>
#include "tf_imagepanel.h"
#include "c_tf_player.h"
using namespace vgui;
DECLARE_BUILD_FACTORY( CTFImagePanel );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFImagePanel::CTFImagePanel( Panel *parent, const char *name ) : ScalableImagePanel( parent, name )
{
for ( int i = 0; i < TF_TEAM_COUNT; i++ )
{
m_szTeamBG[i][0] = '\0';
}
C_TFPlayer *pPlayer = ToTFPlayer( C_BasePlayer::GetLocalPlayer() );
m_iBGTeam = pPlayer ? pPlayer->GetTeamNumber() : TEAM_UNASSIGNED;
ListenForGameEvent( "localplayer_changeteam" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFImagePanel::ApplySettings( KeyValues *inResourceData )
{
for ( int i = 0; i < TF_TEAM_COUNT; i++ )
{
Q_strncpy( m_szTeamBG[i], inResourceData->GetString( VarArgs("teambg_%d", i), "" ), sizeof( m_szTeamBG[i] ) );
if ( m_szTeamBG[i] && m_szTeamBG[i][0] )
{
PrecacheMaterial( VarArgs( "vgui/%s", m_szTeamBG[i] ) );
}
}
BaseClass::ApplySettings( inResourceData );
UpdateBGImage();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFImagePanel::UpdateBGImage( void )
{
if ( m_iBGTeam >= 0 && m_iBGTeam < TF_TEAM_COUNT )
{
if ( m_szTeamBG[m_iBGTeam] && m_szTeamBG[m_iBGTeam][0] )
{
SetImage( m_szTeamBG[m_iBGTeam] );
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFImagePanel::FireGameEvent( IGameEvent * event )
{
if ( FStrEq( "localplayer_changeteam", event->GetName() ) )
{
C_TFPlayer *pPlayer = ToTFPlayer( C_BasePlayer::GetLocalPlayer() );
m_iBGTeam = pPlayer ? pPlayer->GetTeamNumber() : TEAM_UNASSIGNED;
UpdateBGImage();
}
}
|