summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_hud_flagstatus.h
blob: 5bf815ca071664bd77e217f48f6b7c554349c553 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef TF_HUD_FLAGSTATUS_H
#define TF_HUD_FLAGSTATUS_H
#ifdef _WIN32
#pragma once
#endif

#include "entity_capture_flag.h"
#include "tf_controls.h"
#include "tf_imagepanel.h"
#include "GameEventListener.h"
#include "hudelement.h"

class CCaptureFlag;
class CTFFlagCalloutPanel;

//-----------------------------------------------------------------------------
// Purpose:  Draws the rotated arrow panels
//-----------------------------------------------------------------------------
class CTFArrowPanel : public vgui::Panel
{
public:
	DECLARE_CLASS_SIMPLE( CTFArrowPanel, vgui::Panel );

	CTFArrowPanel( vgui::Panel *parent, const char *name );
	virtual void Paint();
	virtual bool IsVisible( void );
	void SetEntity( EHANDLE hEntity ){ m_hEntity = hEntity; }
	float GetAngleRotation( void );
	void OnTick( void );

private:

	EHANDLE				m_hEntity;	

	CMaterialReference	m_RedMaterial;
	CMaterialReference	m_BlueMaterial;
	CMaterialReference	m_NeutralMaterial;
	CMaterialReference	m_NeutralRedMaterial;

	CMaterialReference	m_RedMaterialNoArrow;
	CMaterialReference	m_BlueMaterialNoArrow;

	bool				m_bUseRed;
	float				m_flNextColorSwitch;
	IMaterial			*m_pMaterial;
};

//-----------------------------------------------------------------------------
// Purpose:  
//-----------------------------------------------------------------------------
class CTFFlagStatus : public vgui::EditablePanel
{
public:
	DECLARE_CLASS_SIMPLE( CTFFlagStatus, vgui::EditablePanel );

	CTFFlagStatus( vgui::Panel *parent, const char *name );

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual bool IsVisible( void );
	void UpdateStatus( void );

	void SetEntity( EHANDLE hEntity )
	{ 
		m_hEntity = hEntity;

		if ( m_pArrow )
		{
			m_pArrow->SetEntity( hEntity );
		}

		UpdateStatus();
	}

	CBaseEntity *GetEntity( void ){ return m_hEntity.Get(); }

private:

	EHANDLE			m_hEntity;

	CTFArrowPanel	*m_pArrow;
	CTFImagePanel	*m_pStatusIcon;
	CTFImagePanel	*m_pBriefcase;
};


//-----------------------------------------------------------------------------
// Purpose:  
//-----------------------------------------------------------------------------
class CTFHudFlagObjectives : public vgui::EditablePanel, public CGameEventListener
{
	DECLARE_CLASS_SIMPLE( CTFHudFlagObjectives, vgui::EditablePanel );

public:

	CTFHudFlagObjectives( vgui::Panel *parent, const char *name );

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual bool IsVisible( void );
	virtual void Reset();
	void OnTick();

public: // IGameEventListener:
	virtual void FireGameEvent( IGameEvent *event );

private:
	
	void UpdateStatus( C_BasePlayer *pNewOwner = NULL, C_BaseEntity *pFlagEntity = NULL );
	void SetPlayingToLabelVisible( bool bVisible );
	void SetCarriedImage( const char *pchIcon );

private:

	vgui::ImagePanel		*m_pCarriedImage;

	CExLabel				*m_pPlayingTo;
	vgui::Panel				*m_pPlayingToBG;

	CTFFlagStatus			*m_pRedFlag;
	CTFFlagStatus			*m_pBlueFlag;
	CTFArrowPanel			*m_pCapturePoint;

	bool					m_bFlagAnimationPlayed;
	bool					m_bCarryingFlag;

	vgui::ImagePanel		*m_pSpecCarriedImage;

	vgui::ImagePanel		*m_pPoisonImage;
	CExLabel				*m_pPoisonTimeLabel;

	bool					m_bPlayingHybrid_CTF_CP;
	bool					m_bPlayingSpecialDeliveryMode;

	int						m_nNumValidFlags;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CTFFlagCalloutPanel : public CHudElement, public vgui::EditablePanel
{
	DECLARE_CLASS_SIMPLE( CTFFlagCalloutPanel, vgui::EditablePanel );
public:
	CTFFlagCalloutPanel( const char *pElementName );
	~CTFFlagCalloutPanel( void );

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual void PerformLayout( void );
	virtual void OnTick( void );
	virtual void PaintBackground( void );
	virtual void Paint( void );
	
	void	GetCalloutPosition( const Vector &vecDelta, float flRadius, float *xpos, float *ypos, float *flRotation );
	void	SetFlag( CCaptureFlag *pFlag, float flDuration, Vector &vecOffset );
	static CTFFlagCalloutPanel *AddFlagCalloutIfNotFound( CCaptureFlag *pFlag, float flDuration, Vector &vecLocation );
	bool	ShouldShowFlagIconToLocalPlayer( void );
	void	ScaleAndPositionCallout( float flScale = 1.f );
	
	CHandle< CCaptureFlag > m_hFlag;

private:
	IMaterial		*m_pArrowMaterial;
	CTFImagePanel	*m_pFlagCalloutPanel;
	vgui::Label		*m_pFlagValueLabel;
	CTFImagePanel	*m_pFlagStatusIcon;

	float			m_flRemoveTime;
	float			m_flFirstDisplayTime;
	Vector			m_vecOffset;
	int				m_iDrawArrow;
	bool			m_bFlagVisible;		// LOS

	float			m_flPrevScale;
	int				m_nPanelWideOrig;
	int				m_nPanelTallOrig;
	int				m_nLabelWideOrig;
	int				m_nLabelTallOrig;
	int				m_nIconWideOrig;
	int				m_nIconTallOrig;

	static CUtlVector< CTFFlagCalloutPanel* > m_FlagCalloutPanels;
};

#endif	// TF_HUD_FLAGSTATUS_H