aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/game_controls/NavProgress.cpp
blob: 8aef8c4e204b628776141ec949b512b819dc6476 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "NavProgress.h"

#include <vgui/IScheme.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <filesystem.h>
#include <KeyValues.h>
#include <convar.h>

#include <vgui_controls/Label.h>

#include <game/client/iviewport.h>

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

using namespace vgui;

//--------------------------------------------------------------------------------------------------------------
CNavProgress::CNavProgress( IViewPort *pViewPort ) : Frame( NULL, PANEL_NAV_PROGRESS )
{
	// initialize dialog
	m_pViewPort = pViewPort;

	// load the new scheme early!!
	SetScheme("ClientScheme");
	SetMoveable(false);
	SetSizeable(false);
	SetProportional(true);

	// hide the system buttons
	SetTitleBarVisible( false );

	m_pTitle = new Label( this, "TitleLabel", "" );
	m_pText = new Label( this, "TextLabel", "" );

	m_pProgressBarBorder = new Panel( this, "ProgressBarBorder" );
	m_pProgressBar = new Panel( this, "ProgressBar" );
	m_pProgressBarSizer = new Panel( this, "ProgressBarSizer" );

	LoadControlSettings("Resource/UI/NavProgress.res");

	Reset();
}

//--------------------------------------------------------------------------------------------------------------
CNavProgress::~CNavProgress()
{
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::ApplySchemeSettings(IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings( pScheme );

	SetPaintBackgroundType( 2 );

	m_pProgressBarSizer->SetVisible( false );

	m_pProgressBarBorder->SetBorder( pScheme->GetBorder( "ButtonDepressedBorder" ) );
	m_pProgressBarBorder->SetBgColor( Color( 0, 0, 0, 0 ) );

	m_pProgressBar->SetBorder( pScheme->GetBorder( "ButtonBorder" ) );
	m_pProgressBar->SetBgColor( pScheme->GetColor( "ProgressBar.FgColor", Color( 0, 0, 0, 0 ) ) );
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::PerformLayout()
{
	BaseClass::PerformLayout();

	if ( m_numTicks )
	{
		int w = m_pProgressBarSizer->GetWide();
		w = w * m_currentTick / m_numTicks;
		m_pProgressBar->SetWide( w );
	}
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::Init( const char *title, int numTicks, int startTick )
{
	m_pText->SetText( title );

	m_numTicks = MAX( 1, numTicks ); // non-zero, since we'll divide by this
	m_currentTick = MAX( 0, MIN( m_numTicks, startTick ) );

	InvalidateLayout();
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::SetData(KeyValues *data)
{
	Init( data->GetString( "msg" ),
		data->GetInt( "total" ),
		data->GetInt( "current" ) );
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::ShowPanel( bool bShow )
{
	if ( BaseClass::IsVisible() == bShow )
		return;

	m_pViewPort->ShowBackGround( bShow );

	if ( bShow )
	{
		Activate();
		SetMouseInputEnabled( true );
	}
	else
	{
		SetVisible( false );
		SetMouseInputEnabled( false );
	}
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::Reset( void )
{
}

//--------------------------------------------------------------------------------------------------------------
void CNavProgress::Update( void )
{
}

//--------------------------------------------------------------------------------------------------------------