summaryrefslogtreecommitdiff
path: root/game/client/tf/vgui/tf_imagepanel.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf/vgui/tf_imagepanel.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/tf/vgui/tf_imagepanel.cpp')
-rw-r--r--game/client/tf/vgui/tf_imagepanel.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/game/client/tf/vgui/tf_imagepanel.cpp b/game/client/tf/vgui/tf_imagepanel.cpp
new file mode 100644
index 0000000..28ba950
--- /dev/null
+++ b/game/client/tf/vgui/tf_imagepanel.cpp
@@ -0,0 +1,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();
+ }
+} \ No newline at end of file