summaryrefslogtreecommitdiff
path: root/game/client/cstrike/hud_shopping_cart.cpp
blob: f35fd1204e4b7741159523cd1139a03c24e6a5a1 (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
//========= 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 );
	}
}