summaryrefslogtreecommitdiff
path: root/game/client/tf2/clientmode_commander.h
blob: 871dd0c22e378aac9488a1df3358d6db262d08b0 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $Workfile:     $
// $Date:         $
// $NoKeywords: $
//=============================================================================//
#if !defined( CLIENTMODE_COMMANDER_H )
#define CLIENTMODE_COMMANDER_H
#ifdef _WIN32
#pragma once
#endif

#include "clientmode_tfbase.h"
#include <vgui/Cursor.h>
#include "hud_minimap.h"
#include <vgui_controls/Panel.h>

class IMaterial;
class CCommanderViewportPanel;
class Vector;
class CCommanderOverlayPanel;
namespace vgui
{
	class Panel;
	class AnimationController;
}

class CClientModeCommander : public ClientModeTFBase, public IMinimapClient
{
	DECLARE_CLASS( CClientModeCommander, ClientModeTFBase );

// IClientMode overrides.
public:
	
					CClientModeCommander();
	virtual			~CClientModeCommander();

	virtual void	Init( void );

	virtual void	Enable();
	virtual void	Disable();
	
	virtual void	Update();
	virtual void	Layout();

	virtual bool	ShouldDrawFog( void );
	virtual void	OverrideView( CViewSetup *pSetup );
	virtual void	CreateMove( float flInputSampleTime, CUserCmd *cmd );
	virtual void	LevelInit( const char *newmap );
	virtual void	LevelShutdown( void );
	virtual bool	ShouldDrawEntity(C_BaseEntity *pEnt);
	virtual bool	ShouldDrawDetailObjects( );
	virtual bool	ShouldDrawLocalPlayer( C_BasePlayer *pPlayer );
	virtual bool	ShouldDrawViewModel( void );
	virtual bool	ShouldDrawCrosshair( void );
	virtual bool	ShouldDrawParticles( );

	virtual void	AdjustEngineViewport( int& x, int& y, int& width, int& height );
	virtual void	PreRender( CViewSetup *pSetup );
	virtual void	PostRenderWorld();
	virtual void	PostRender( void );
	virtual vgui::Panel		*GetViewport();
	virtual vgui::AnimationController *GetViewportAnimationController() { return NULL; }

	// Input
	virtual int		KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );

	// Makes the mouse sit over a particular world location
	void	MoveMouse( Vector& worldPos );

	// Inherited from IMinimapClient
	virtual void MinimapClicked( const Vector& clickWorldPos );

	CCommanderOverlayPanel	*GetCommanderOverlayPanel( void );

	virtual vgui::Panel *GetMinimapParent( void );

private:
	float	GetScaledSlueSpeed( void );
	void	ResetCommand( CUserCmd *cmd );
	float	Commander_ResampleMove( float in );
	void	IsometricMove( CUserCmd *cmd );
	float	GetHeightForMap( float zoom );

	// Fills in ortho parameters (and near/far Z) in pSetup for how the commander mode renders the world.
	bool			GetOrthoParameters(CViewSetup *pSetup);

	CCommanderViewportPanel *GetCommanderViewport();

private:

	ConVar*	m_pClear;
	ConVar*	m_pSkyBox;
	float	m_fOldClear;
	float	m_fOldSkybox;

	int		m_LastMouseX;
	int		m_LastMouseY;

	float	m_ScaledMouseSpeed;
	float	m_ScaledSlueSpeed;
	float	m_Log_BaseEto2;	// scales logarithms from base E to base 2.
};


//-----------------------------------------------------------------------------
// The panel responsible for rendering the 3D view in orthographic mode
//-----------------------------------------------------------------------------
class CCommanderViewportPanel : public CBaseViewport
{
	typedef CBaseViewport BaseClass;

// Panel overrides.
public:
					CCommanderViewportPanel( void );
	virtual			~CCommanderViewportPanel( void );

	void			Enable( void );
	void			Disable( void );
	void			SetCommanderView( CClientModeCommander *commander );
	void			MinimapClicked( const Vector& clickWorldPos );

	CCommanderOverlayPanel	*GetCommanderOverlayPanel( void );

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
	{
		BaseClass::ApplySchemeSettings( pScheme );

		gHUD.InitColors( pScheme );
	}

private:

	CCommanderOverlayPanel	*m_pOverlayPanel;
	CClientModeCommander	*m_pCommanderView;

	vgui::HCursor	m_CursorCommander;
	vgui::HCursor	m_CursorRightMouseMove;

};

IClientMode *ClientModeCommander();

#endif // CLIENTMODE_COMMANDER_H