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.

124 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implements visual effects entities: sprites, beams, bubbles, etc.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "engine/IEngineSound.h"
  9. #include "baseentity.h"
  10. #include "entityoutput.h"
  11. #include "recipientfilter.h"
  12. #include "usermessages.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. //-----------------------------------------------------------------------------
  16. // Purpose:
  17. //-----------------------------------------------------------------------------
  18. class CEnvHudHint : public CPointEntity
  19. {
  20. public:
  21. DECLARE_CLASS( CEnvHudHint, CPointEntity );
  22. void Spawn( void );
  23. void Precache( void );
  24. private:
  25. void InputShowHudHint( inputdata_t &inputdata );
  26. void InputHideHudHint( inputdata_t &inputdata );
  27. string_t m_iszMessage;
  28. DECLARE_DATADESC();
  29. };
  30. LINK_ENTITY_TO_CLASS( env_hudhint, CEnvHudHint );
  31. BEGIN_DATADESC( CEnvHudHint )
  32. DEFINE_KEYFIELD( m_iszMessage, FIELD_STRING, "message" ),
  33. DEFINE_INPUTFUNC( FIELD_VOID, "ShowHudHint", InputShowHudHint ),
  34. DEFINE_INPUTFUNC( FIELD_VOID, "HideHudHint", InputHideHudHint ),
  35. END_DATADESC()
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. //-----------------------------------------------------------------------------
  39. void CEnvHudHint::Spawn( void )
  40. {
  41. Precache();
  42. SetSolid( SOLID_NONE );
  43. SetMoveType( MOVETYPE_NONE );
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. //-----------------------------------------------------------------------------
  48. void CEnvHudHint::Precache( void )
  49. {
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: Input handler for showing the message and/or playing the sound.
  53. //-----------------------------------------------------------------------------
  54. void CEnvHudHint::InputShowHudHint( inputdata_t &inputdata )
  55. {
  56. CBaseEntity *pPlayer = NULL;
  57. if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() )
  58. {
  59. pPlayer = inputdata.pActivator;
  60. }
  61. else
  62. {
  63. pPlayer = UTIL_GetLocalPlayer();
  64. }
  65. if ( pPlayer )
  66. {
  67. if ( !pPlayer || !pPlayer->IsNetClient() )
  68. return;
  69. CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer );
  70. user.MakeReliable();
  71. CCSUsrMsg_KeyHintText msg;
  72. msg.add_hints( STRING(m_iszMessage) );
  73. SendUserMessage( user, CS_UM_KeyHintText, msg );
  74. }
  75. }
  76. //-----------------------------------------------------------------------------
  77. //-----------------------------------------------------------------------------
  78. void CEnvHudHint::InputHideHudHint( inputdata_t &inputdata )
  79. {
  80. CBaseEntity *pPlayer = NULL;
  81. if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() )
  82. {
  83. pPlayer = inputdata.pActivator;
  84. }
  85. else
  86. {
  87. pPlayer = UTIL_GetLocalPlayer();
  88. }
  89. if ( pPlayer )
  90. {
  91. if ( !pPlayer || !pPlayer->IsNetClient() )
  92. return;
  93. CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer );
  94. user.MakeReliable();
  95. CCSUsrMsg_KeyHintText msg;
  96. msg.add_hints( STRING(NULL_STRING) );
  97. SendUserMessage( user, CS_UM_KeyHintText, msg );
  98. }
  99. }