aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/hud_macros.h
blob: 667ef64338bfafcc10dcf5b76bbf904e0b478372 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//
#if !defined( HUD_MACROS_H )
#define HUD_MACROS_H
#ifdef _WIN32
#pragma once
#endif

#include "usermessages.h"

// Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) usermessages->HookMessage(#x, __MsgFunc_##x );
#define HOOK_HUD_MESSAGE(y, x) usermessages->HookMessage(#x, __MsgFunc_##y##_##x );
// Message declaration for non-CHudElement classes
#define DECLARE_MESSAGE(y, x) void __MsgFunc_##y##_##x(bf_read &msg) \
	{											\
		y.MsgFunc_##x( msg );	\
	}
// Message declaration for CHudElement classes that use the hud element factory for creation
#define DECLARE_HUD_MESSAGE(y, x) void __MsgFunc_##y##_##x(bf_read &msg) \
	{																\
		CHudElement *pElement = gHUD.FindElement( #y );				\
		if ( pElement )												\
		{															\
			((y *)pElement)->MsgFunc_##x( msg );	\
		}															\
	}

#define DECLARE_HUD_MESSAGE_BASECLASS(name, basename, msgname) void __MsgFunc_##msgname(const char *pszName, int iSize, void *pbuf) \
	{																\
		CHudElement *pElement = gHUD.FindElement( #name );				\
		if ( pElement )												\
		{															\
			((basename *)pElement)->MsgFunc_##msgname(pszName, iSize, pbuf );	\
		}															\
	}

// Commands
#define HOOK_COMMAND(x, y) static ConCommand x( #x, __CmdFunc_##y, "", FCVAR_SERVER_CAN_EXECUTE );
// Command declaration for non CHudElement classes
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
	{							\
		y.UserCmd_##x( );		\
	}
// Command declaration for CHudElement classes that use the hud element factory for creation
#define DECLARE_HUD_COMMAND(y, x) void __CmdFunc_##x( void )									\
	{																\
		CHudElement *pElement = gHUD.FindElement( #y );				\
		{															\
			((y *)pElement)->UserCmd_##x( );						\
		}															\
	}

#define DECLARE_HUD_COMMAND_NAME(y, x, name) void __CmdFunc_##x( void )									\
	{																\
		CHudElement *pElement = gHUD.FindElement( name );			\
		{															\
			((y *)pElement)->UserCmd_##x( );						\
		}															\
	}


#endif // HUD_MACROS_H