summaryrefslogtreecommitdiff
path: root/game/client/tf2/clientmode_tfbase.cpp
blob: e70212936025b2225a10ec29898f9485f408c827 (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//===========================================================================//
#include "cbase.h"
#include "clientmode_tfbase.h"
#include "hud.h"
#include "c_tf_basecombatweapon.h"
#include "keydefs.h"
#include "c_tf_hintmanager.h"
#include <vgui_controls/Controls.h>
#include <vgui/IScheme.h>
#include "filesystem.h"

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


CMinimapPanel *ClientModeTFBase::m_pMinimap = NULL;
vgui::HScheme g_hVGuiObjectScheme = 0;

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
ClientModeTFBase::ClientModeTFBase( void )
{
	m_bInitialized = false;

	m_pCVDrawFullSkybox = NULL;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
ClientModeTFBase::~ClientModeTFBase( void )
{
}

//-----------------------------------------------------------------------------
// Purpose: 
// Output : CMinimapPanel
//-----------------------------------------------------------------------------
CMinimapPanel *ClientModeTFBase::GetMinimap( void )
{
	return m_pMinimap;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------

// FIXME: Remove if this ever becomes true for HL2 (I expect it will)
ConVar 	r_radiosity		( "r_radiosity", "2" );		// do full radiosity calc?
// FIXME: Remove when we reactivate detail props
extern ConVar r_DrawDetailProps;

void ClientModeTFBase::Init()
{
	BaseClass::Init();
	C_BaseTFCombatWeapon::CreateCrosshairPanels();

	// FIXME: For playtests, turn off detail props. They're causing perf problems
	r_DrawDetailProps.SetValue("0");

	// Turn lighting into a mode where we use better computation for the ambient
	// cube on static props, and a cheap one for dynamic entities.
 	r_radiosity.SetValue("3");

	if ( !m_pMinimap )
	{
		m_pMinimap = GET_HUDELEMENT( CMinimapPanel );
	}

	// Load up the object control panel scheme
	g_hVGuiObjectScheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ObjectControlPanelScheme.res", "TFBase" );
	if (!g_hVGuiObjectScheme)
	{
		Warning( "Couldn't load control panel scheme!\n" );
	}

	// Load the objects.txt file.
	LoadObjectInfos( ::filesystem );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::Shutdown()
{
	C_BaseTFCombatWeapon::DestroyCrosshairPanels();
	BaseClass::Shutdown();
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::Enable( void )
{
	BaseClass::Enable();

	// Hook the minimap traces into the minimap
	if ( GetMinimap() )
	{
		GetMinimap()->Activate();
	}
}

void ClientModeTFBase::LevelInit( const char *newmap )
{
	BaseClass::LevelInit( newmap );

	// Tell the radar to load the radar's overlay map
	//g_Radar.LoadMap( newmap );
	if ( GetMinimap() )
	{
		GetMinimap()->LevelInit( newmap );
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::LevelShutdown( void )
{
	BaseClass::LevelShutdown();

	if ( GetMinimap() )
	{
		GetMinimap()->LevelShutdown();
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pSetup - 
//-----------------------------------------------------------------------------
void ClientModeTFBase::PreRender( CViewSetup *pSetup )
{
	Initialize();

	if ( !m_pCVDrawFullSkybox )
	{
		assert( 0 );
		return;
	}

	m_flOldDrawFullSkybox = m_pCVDrawFullSkybox->GetFloat();

	m_pCVDrawFullSkybox->SetValue( 1 );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::PostRender( void )
{
	C_BaseTFPlayer *pl = C_BaseTFPlayer::GetLocalPlayer();
	if ( pl )
	{
		pl->UpdateTargetReticles();
	}

	if ( !m_pCVDrawFullSkybox )
	{
		assert( 0 );
		return;
	}

	m_pCVDrawFullSkybox->SetValue( m_flOldDrawFullSkybox );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::Initialize( void )
{
	if ( m_bInitialized )
		return;
	m_bInitialized = true;

	m_pCVDrawFullSkybox = (ConVar *)cvar->FindVar( "r_drawfullskybox" );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFBase::Update( void )
{
	BaseClass::Update();
	
	MapData().Update();
}

//-----------------------------------------------------------------------------
// Purpose: We've received a keypress from the engine. Return 1 if the engine is allowed to handle it.
//-----------------------------------------------------------------------------
int	ClientModeTFBase::KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding )
{
	if ( engine->Con_IsVisible() == false )
	{
		// Let hint system snag first escape key release
		if ( down && ( keynum == KEY_ENTER ) && HintSystemEscapeKey() )
		{
			return 0;
		}

		// Has the player hit one of his Order keys?
		if ( pszCurrentBinding && strncmp( pszCurrentBinding, "order", 5 ) == 0 )
		{
			if ( down )
			{
				//int iOrderNumber = (pszCurrentBinding[6] - '0') - 1;
				//GetHudOrderList()->SelectOrder( iOrderNumber );
			}
			return 0;
		}
	}

	return BaseClass::KeyInput( down, keynum, pszCurrentBinding );
}