Counter Strike : Global Offensive Source Code
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.

73 lines
2.2 KiB

  1. //========= Copyright 1996-2005, 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) \
  15. m_UMCMsg##x.Bind< CS_UM_##x, CCSUsrMsg_##x >( UtlMakeDelegate( __MsgFunc_##x ) )
  16. #define HOOK_HUD_MESSAGE(y, x) \
  17. m_UMCMsg##x.Bind< CS_UM_##x, CCSUsrMsg_##x >( UtlMakeDelegate( __MsgFunc_##y##_##x ) )
  18. #define HOOK_HUD_MESSAGE_REALTIME_PASSTHROUGH(y, x) \
  19. m_UMCMsg##x.BindRealtimePassthrough< CS_UM_##x, CCSUsrMsg_##x >( UtlMakeDelegate( __MsgFunc_##y##_##x ) )
  20. // Message declaration for non-CHudElement classes
  21. #define DECLARE_MESSAGE(y, x) bool __MsgFunc_##y##_##x(const CCSUsrMsg_##x &msg) \
  22. { \
  23. return y.MsgFunc_##x( msg ); \
  24. }
  25. // Message declaration for CHudElement classes that use the hud element factory for creation
  26. #define DECLARE_HUD_MESSAGE(y, x) bool __MsgFunc_##y##_##x(const CCSUsrMsg_##x &msg) \
  27. { \
  28. CHudElement *pElement = GetHud().FindElement( #y ); \
  29. if ( pElement ) \
  30. { \
  31. return ((y *)pElement)->MsgFunc_##x( msg ); \
  32. } \
  33. return true; \
  34. }
  35. // Commands
  36. #define HOOK_COMMAND(x, y) static ConCommand x( #x, __CmdFunc_##y, "", FCVAR_SERVER_CAN_EXECUTE );
  37. // Command declaration for non CHudElement classes
  38. #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
  39. { \
  40. y.UserCmd_##x( ); \
  41. }
  42. // Command declaration for CHudElement classes that use the hud element factory for creation
  43. #define DECLARE_HUD_COMMAND(y, x) void __CmdFunc_##x( void ) \
  44. { \
  45. CHudElement *pElement = GetHud().FindElement( #y ); \
  46. if ( pElement ) \
  47. { \
  48. ((y *)pElement)->UserCmd_##x( ); \
  49. } \
  50. }
  51. #define DECLARE_HUD_COMMAND_NAME(y, x, name) void __CmdFunc_##x( void ) \
  52. { \
  53. CHudElement *pElement = GetHud().FindElement( name ); \
  54. if ( pElement ) \
  55. { \
  56. ((y *)pElement)->UserCmd_##x( ); \
  57. } \
  58. }
  59. #endif // HUD_MACROS_H