diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf/tf_hud_waitingforplayers_panel.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/tf/tf_hud_waitingforplayers_panel.cpp')
| -rw-r--r-- | game/client/tf/tf_hud_waitingforplayers_panel.cpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/game/client/tf/tf_hud_waitingforplayers_panel.cpp b/game/client/tf/tf_hud_waitingforplayers_panel.cpp new file mode 100644 index 0000000..3f6d22e --- /dev/null +++ b/game/client/tf/tf_hud_waitingforplayers_panel.cpp @@ -0,0 +1,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() ); +} |