summaryrefslogtreecommitdiff
path: root/game/client/tf2/minimap_resourcezone.cpp
blob: 56bbdc96269457be3e3ca0e1e6bb48a372ef8347 (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
95
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "hud.h"
#include "c_func_resource.h"
#include "vgui_bitmapimage.h"
#include <KeyValues.h>
#include "minimap_trace.h"
#include "techtree.h"
#include "shareddefs.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

class CMinimapResourceZonePanel : public CMinimapTracePanel
{
	DECLARE_CLASS( CMinimapResourceZonePanel, CMinimapTracePanel );

public:
	CMinimapResourceZonePanel( vgui::Panel *parent, const char *panelName );
	virtual ~CMinimapResourceZonePanel();

	virtual bool Init( KeyValues* pKeyValues, MinimapInitData_t* pInitData );
	virtual void Paint( );

private:
	BitmapImage *m_ppImage;
};

DECLARE_MINIMAP_FACTORY( CMinimapResourceZonePanel, "minimap_resource_zone_panel" );


CMinimapResourceZonePanel::CMinimapResourceZonePanel( vgui::Panel *parent, const char *panelName )
: BaseClass( parent, "CMinimapResourceZonePanel" )
{
	m_ppImage = NULL;
}

CMinimapResourceZonePanel::~CMinimapResourceZonePanel()
{
	if ( m_ppImage )
	{
		delete m_ppImage;
		m_ppImage = NULL;
	}
}

bool CMinimapResourceZonePanel::Init( KeyValues* pKeyValues, MinimapInitData_t* pInitData )
{
	// Can only be applied to resource zones...
	C_ResourceZone* pResource = dynamic_cast<C_ResourceZone*>( pInitData->m_pEntity );
	if (!pResource)
		return false;

	if (!BaseClass::Init(pKeyValues, pInitData))
		return false;

	// Read in the images for the resource zone...
	// Default to null
	m_ppImage = NULL;

	char const* pMaterialName = pKeyValues->GetString( "material" );
	if ( !pMaterialName || !pMaterialName[ 0 ] )
		return false;

	// modulation color
	Color color;
	if (!ParseRGBA( pKeyValues, "color", color ))
		color.SetColor( 255, 255, 255, 255 );

	// hook in the bitmap
	m_ppImage = new BitmapImage( GetVPanel(), pMaterialName );
	m_ppImage->SetColor( color );

	return true;
}

void CMinimapResourceZonePanel::Paint( )
{
	if ( gHUD.IsHidden( HIDEHUD_MISCSTATUS ) )
		return;

	// Paint the image for the zone type
	if ( m_ppImage )
	{
		m_ppImage->Paint();
	}
}