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/cstrike/hud_shopping_cart.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/cstrike/hud_shopping_cart.cpp')
| -rw-r--r-- | game/client/cstrike/hud_shopping_cart.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/game/client/cstrike/hud_shopping_cart.cpp b/game/client/cstrike/hud_shopping_cart.cpp new file mode 100644 index 0000000..f35fd12 --- /dev/null +++ b/game/client/cstrike/hud_shopping_cart.cpp @@ -0,0 +1,94 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "hudelement.h" +#include <vgui_controls/Panel.h> +#include <vgui/ISurface.h> +#include "clientmode_csnormal.h" +#include "cs_gamerules.h" +#include "hud_numericdisplay.h" +#include <vgui_controls/AnimationController.h> + + +class CHudShoppingCart : public CHudElement, public vgui::Panel +{ +public: + DECLARE_CLASS_SIMPLE( CHudShoppingCart, vgui::Panel ); + + CHudShoppingCart( const char *name ); + + virtual bool ShouldDraw(); + virtual void Paint(); + virtual void Init(); + + +private: + CPanelAnimationVar( Color, m_clrIcon, "IconColor", "IconColor" ); + + CHudTexture *m_pCartIcon; + bool m_bPrevState; +}; + + +DECLARE_HUDELEMENT( CHudShoppingCart ); + + +CHudShoppingCart::CHudShoppingCart( const char *pName ) : + vgui::Panel( NULL, "HudShoppingCart" ), CHudElement( pName ) +{ + SetParent( g_pClientMode->GetViewport() ); + m_pCartIcon = NULL; + + SetHiddenBits( HIDEHUD_PLAYERDEAD ); + + //============================================================================= + // HPE_BEGIN: + // [tj] Add this to the render group that disappears when the scoreboard is up + //============================================================================= + RegisterForRenderGroup( "hide_for_scoreboard" ); + //============================================================================= + // HPE_END + //============================================================================= +} + + +void CHudShoppingCart::Init() +{ +} + + +bool CHudShoppingCart::ShouldDraw() +{ + C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer(); + + //============================================================================= + // HPE_BEGIN: + // [tj] Added base class call + //============================================================================= + return ( pPlayer && pPlayer->IsInBuyZone() && !CSGameRules()->IsBuyTimeElapsed() && CHudElement::ShouldDraw() ); + //============================================================================= + // HPE_END + //============================================================================= +} + + +void CHudShoppingCart::Paint() +{ + if ( !m_pCartIcon ) + { + m_pCartIcon = gHUD.GetIcon( "shopping_cart" ); + } + + if ( m_pCartIcon ) + { + int x, y, w, h; + GetBounds( x, y, w, h ); + + m_pCartIcon->DrawSelf( 0, 0, w, h, m_clrIcon ); + } +} + |