aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/toolframework/itoolsystem.h
blob: 84c91db7a2823bf9ea0a6050dc515b7d114a93df (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: 
//
//=============================================================================

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

#include "itoolentity.h"
#include "interface.h"
#include "materialsystem/imaterialproxy.h"
#include "inputsystem/iinputsystem.h"

class KeyValues;
struct SpatializationInfo_t;
struct AudioState_t;

//-----------------------------------------------------------------------------
// Purpose: All tools expose this interface, which includes both client and server
//  related hooks
//-----------------------------------------------------------------------------
class IToolSystem
{
public:
	// Name describing the tool
	virtual char const *GetToolName() = 0;

	// Called at the end of engine startup (after client .dll and server .dll have been loaded)
	virtual bool	Init() = 0;

	// Called during RemoveTool or when engine is shutting down
	virtual void	Shutdown() = 0;

	// Called after server.dll is loaded
	virtual bool	ServerInit( CreateInterfaceFn serverFactory ) = 0; 
	// Called after client.dll is loaded
	virtual bool	ClientInit( CreateInterfaceFn clientFactory ) = 0; 

	virtual void	ServerShutdown() = 0;
	virtual void	ClientShutdown() = 0;

	// Allow tool to override quitting, called before Shutdown(), return no to abort quitting
	virtual bool	CanQuit() = 0; 

	// Called when another system wiches to post a message to the tool and/or a specific entity
	// FIXME:  Are KeyValues too inefficient here?
    virtual void	PostMessage( HTOOLHANDLE hEntity, KeyValues *message ) = 0;

	// Called oncer per frame even when no level is loaded... (call ProcessMessages())
	virtual void	Think( bool finalTick ) = 0;

// Server calls:

	// Level init, shutdown
	virtual void	ServerLevelInitPreEntity() = 0;
	// entities are created / spawned / precached here
	virtual void	ServerLevelInitPostEntity() = 0;

	virtual void	ServerLevelShutdownPreEntity() = 0;
	// Entities are deleted / released here...
	virtual void	ServerLevelShutdownPostEntity() = 0;
	// end of level shutdown

	// Called each frame before entities think
	virtual void	ServerFrameUpdatePreEntityThink() = 0;
	// called after entities think
	virtual void	ServerFrameUpdatePostEntityThink() = 0;
	virtual void	ServerPreClientUpdate() = 0;
	virtual void	ServerPreSetupVisibility() = 0;

	// Used to allow the tool to spawn different entities when it's active
	virtual const char* GetEntityData( const char *pActualEntityData ) = 0;

// Client calls:
	// Level init, shutdown
	virtual void	ClientLevelInitPreEntity() = 0;
	// entities are created / spawned / precached here
	virtual void	ClientLevelInitPostEntity() = 0;

	virtual void	ClientLevelShutdownPreEntity() = 0;
	// Entities are deleted / released here...
	virtual void	ClientLevelShutdownPostEntity() = 0;
	// end of level shutdown
	// Called before rendering
	virtual void	ClientPreRender() = 0;
	virtual void	ClientPostRender() = 0;

	// Let tool override viewport for engine
	virtual void	AdjustEngineViewport( int& x, int& y, int& width, int& height ) = 0;

	// let tool override view/camera
	virtual bool	SetupEngineView( Vector &origin, QAngle &angles, float &fov ) = 0;

	// let tool override microphone
	virtual bool	SetupAudioState( AudioState_t &audioState ) = 0;

	// Should the client be allowed to render the view normally?
	virtual bool	ShouldGameRenderView() = 0;
	virtual bool	IsThirdPersonCamera() = 0;

	// is the current tool recording?
	virtual bool	IsToolRecording() = 0;

	virtual IMaterialProxy *LookupProxy( const char *proxyName ) = 0;

	// Possible hooks for rendering
	// virtual void	Think( float curtime, float frametime ) = 0;
	// virtual void Prerender() = 0;
	// virtual void Render3D() = 0;
	// virtual void Render2D() = 0;
// Tool activation/deactivation

	// This tool is being activated
	virtual void	OnToolActivate() = 0;
	// Another tool is being activated
	virtual void	OnToolDeactivate() = 0;

	virtual bool	TrapKey( ButtonCode_t key, bool down ) = 0;

	virtual bool	GetSoundSpatialization( int iUserData, int guid, SpatializationInfo_t& info ) = 0;

	// Unlike the client .dll pre/post render stuff, these get called no matter whether a map is loaded and they only get called once per frame!!!
	virtual void		RenderFrameBegin() = 0;
	virtual void		RenderFrameEnd() = 0;

	// wraps the entire frame - surrounding all other begin/end and pre/post calls
	virtual void		HostRunFrameBegin() = 0;
	virtual void		HostRunFrameEnd() = 0;

	// See enginevgui.h for paintmode_t enum definitions
	virtual void		VGui_PreRender( int paintMode ) = 0;
	virtual void		VGui_PostRender( int paintMode ) = 0;

	virtual void		VGui_PreSimulate() = 0;
	virtual void		VGui_PostSimulate() = 0;
};

// Pointer to a member method of IGameSystem
typedef void (IToolSystem::*ToolSystemFunc_t)();
typedef void (IToolSystem::*ToolSystemFunc_Int_t)( int arg );

#endif // ITOOLSYSTEM_H