Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #if !defined( HUD_MACROS_H )
  8. #define HUD_MACROS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "usermessages.h"
  13. // Macros to hook function calls into the HUD object
  14. #define HOOK_MESSAGE(x) usermessages->HookMessage(#x, __MsgFunc_##x );
  15. #define HOOK_HUD_MESSAGE(y, x) usermessages->HookMessage(#x, __MsgFunc_##y##_##x );
  16. // Message declaration for non-CHudElement classes
  17. #define DECLARE_MESSAGE(y, x) void __MsgFunc_##y##_##x(bf_read &msg) \
  18. { \
  19. y.MsgFunc_##x( msg ); \
  20. }
  21. // Message declaration for CHudElement classes that use the hud element factory for creation
  22. #define DECLARE_HUD_MESSAGE(y, x) void __MsgFunc_##y##_##x(bf_read &msg) \
  23. { \
  24. CHudElement *pElement = gHUD.FindElement( #y ); \
  25. if ( pElement ) \
  26. { \
  27. ((y *)pElement)->MsgFunc_##x( msg ); \
  28. } \
  29. }
  30. #define DECLARE_HUD_MESSAGE_BASECLASS(name, basename, msgname) void __MsgFunc_##msgname(const char *pszName, int iSize, void *pbuf) \
  31. { \
  32. CHudElement *pElement = gHUD.FindElement( #name ); \
  33. if ( pElement ) \
  34. { \
  35. ((basename *)pElement)->MsgFunc_##msgname(pszName, iSize, pbuf ); \
  36. } \
  37. }
  38. // Commands
  39. #define HOOK_COMMAND(x, y) static ConCommand x( #x, __CmdFunc_##y, "", FCVAR_SERVER_CAN_EXECUTE );
  40. // Command declaration for non CHudElement classes
  41. #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
  42. { \
  43. y.UserCmd_##x( ); \
  44. }
  45. // Command declaration for CHudElement classes that use the hud element factory for creation
  46. #define DECLARE_HUD_COMMAND(y, x) void __CmdFunc_##x( void ) \
  47. { \
  48. CHudElement *pElement = gHUD.FindElement( #y ); \
  49. { \
  50. ((y *)pElement)->UserCmd_##x( ); \
  51. } \
  52. }
  53. #define DECLARE_HUD_COMMAND_NAME(y, x, name) void __CmdFunc_##x( void ) \
  54. { \
  55. CHudElement *pElement = gHUD.FindElement( name ); \
  56. { \
  57. ((y *)pElement)->UserCmd_##x( ); \
  58. } \
  59. }
  60. #endif // HUD_MACROS_H