summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_time_panel.h
blob: 7714c10457cf84fb221a556606ccc8a022acf5ab (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

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

#include "GameEventListener.h"
#include "hudelement.h"
#include <vgui_controls/ImagePanel.h>

using namespace vgui;

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CTFProgressBar : public vgui::ImagePanel
{
public:
	DECLARE_CLASS_SIMPLE( CTFProgressBar, vgui::ImagePanel );

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

	virtual void Paint();
	void SetPercentage( float flPercentage ){ m_flPercent = flPercentage; }

private:

	float	m_flPercent;
	int		m_iTexture;

	CPanelAnimationVar( Color, m_clrActive, "color_active", "TimerProgress.Active" );
	CPanelAnimationVar( Color, m_clrInActive, "color_inactive", "TimerProgress.InActive" );
	CPanelAnimationVar( Color, m_clrWarning, "color_warning", "TimerProgress.Active" );
	CPanelAnimationVar( float, m_flPercentWarning, "percent_warning", "0.75" );
};


// Floating delta text items, float off the top of the frame to 
// show changes to the timer value
typedef struct 
{
	// amount of delta
	int m_nAmount;

	// die time
	float m_flDieTime;

} timer_delta_t;

#define NUM_TIMER_DELTA_ITEMS 10

class CExLabel;

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

public:

	CTFHudTimeStatus( Panel *parent, const char *name );

	virtual void Paint( void );
	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual void Reset();

	int GetTimerIndex( void ){ return m_iTimerIndex; }
	void SetTimerIndex( int index ){ m_iTimerIndex = ( index >= 0 ) ? index : 0; SetExtraTimePanels(); }
	
	virtual void FireGameEvent( IGameEvent *event );

	void SetTeam( int nTeam ){ m_nTeam = nTeam; }

protected:

	virtual void OnThink();

private:

	void SetExtraTimePanels();
	void SetTimeAdded( int iIndex, int nSeconds );
	void CheckClockLabelLength( CExLabel *pLabel, vgui::Panel *pBG );
	void SetTeamBackground( void );

private:

	float				m_flNextThink;
	int					m_iTimerIndex;
	bool				m_bSuddenDeath;
	bool				m_bOvertime;

	CExLabel			*m_pTimeValue;
	CTFProgressBar		*m_pProgressBar;

	vgui::ScalableImagePanel	*m_pTimerBG;

	CExLabel			*m_pWaitingForPlayersLabel;
	vgui::Panel			*m_pWaitingForPlayersBG;

	CExLabel			*m_pOvertimeLabel;
	vgui::Panel			*m_pOvertimeBG;

	CExLabel			*m_pSetupLabel;
	vgui::Panel			*m_pSetupBG;

	CExLabel			*m_pServerTimeLabel;
	vgui::Panel			*m_pServerTimeLabelBG;

	// we'll have a second label/bg set for the SuddenDeath panel in case we want to change the look from the Overtime label
	CExLabel			*m_pSuddenDeathLabel;
	vgui::Panel			*m_pSuddenDeathBG;

	// delta stuff
	int m_iTimerDeltaHead;
	timer_delta_t m_TimerDeltaItems[NUM_TIMER_DELTA_ITEMS];
	CPanelAnimationVarAliasType( float, m_flDeltaItemStartPos, "delta_item_start_y", "100", "proportional_float" );
	CPanelAnimationVarAliasType( float, m_flDeltaItemEndPos, "delta_item_end_y", "0", "proportional_float" );

	CPanelAnimationVarAliasType( float, m_flDeltaItemX, "delta_item_x", "0", "proportional_float" );

	CPanelAnimationVar( Color, m_DeltaPositiveColor, "PositiveColor", "0 255 0 255" );
	CPanelAnimationVar( Color, m_DeltaNegativeColor, "NegativeColor", "255 0 0 255" );

	CPanelAnimationVar( float, m_flDeltaLifetime, "delta_lifetime", "2.0" );

	CPanelAnimationVar( vgui::HFont, m_hDeltaItemFont, "delta_item_font", "Default" );

	int m_nTeam;
	bool m_bKothMode;
	bool m_bCachedOvertime;
};


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

public:
	CTFHudKothTimeStatus( const char *pElementName );
	~CTFHudKothTimeStatus();

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual void Reset();
	virtual void Think();
	virtual bool ShouldDraw();
	virtual void SetVisible( bool bVisible ) OVERRIDE;

	virtual int GetRenderGroupPriority( void ) { return 80; }	// higher than build menus

private:
	void UpdateActiveTeam( void );

private:
	CTFHudTimeStatus	*m_pBluePanel;
	CTFHudTimeStatus	*m_pRedPanel;
	Panel				*m_pActiveTimerBG;

	int					m_nActiveTeam;

	CPanelAnimationVarAliasType( int, m_nBlueActiveXPos, "blue_active_xpos", "0", "proportional_int" );
	CPanelAnimationVarAliasType( int, m_nRedActiveXPos, "red_active_xpos", "0", "proportional_int" );
};


#endif	// TF_TIME_PANEL_H