diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/hud_macros.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/hud_macros.h')
| -rw-r--r-- | game/client/hud_macros.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/game/client/hud_macros.h b/game/client/hud_macros.h new file mode 100644 index 0000000..667ef64 --- /dev/null +++ b/game/client/hud_macros.h @@ -0,0 +1,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 |