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.

115 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "hl2mp_hud_chat.h"
  8. #include "hud_macros.h"
  9. #include "text_message.h"
  10. #include "vguicenterprint.h"
  11. #include "vgui/ILocalize.h"
  12. #include "c_team.h"
  13. #include "c_playerresource.h"
  14. #include "c_hl2mp_player.h"
  15. #include "hl2mp_gamerules.h"
  16. #include "ihudlcd.h"
  17. DECLARE_HUDELEMENT( CHudChat );
  18. DECLARE_HUD_MESSAGE( CHudChat, SayText );
  19. DECLARE_HUD_MESSAGE( CHudChat, SayText2 );
  20. DECLARE_HUD_MESSAGE( CHudChat, TextMsg );
  21. //=====================
  22. //CHudChatLine
  23. //=====================
  24. void CHudChatLine::ApplySchemeSettings(vgui::IScheme *pScheme)
  25. {
  26. BaseClass::ApplySchemeSettings( pScheme );
  27. }
  28. //=====================
  29. //CHudChatInputLine
  30. //=====================
  31. void CHudChatInputLine::ApplySchemeSettings(vgui::IScheme *pScheme)
  32. {
  33. BaseClass::ApplySchemeSettings(pScheme);
  34. }
  35. //=====================
  36. //CHudChat
  37. //=====================
  38. CHudChat::CHudChat( const char *pElementName ) : BaseClass( pElementName )
  39. {
  40. }
  41. void CHudChat::CreateChatInputLine( void )
  42. {
  43. m_pChatInput = new CHudChatInputLine( this, "ChatInputLine" );
  44. m_pChatInput->SetVisible( false );
  45. }
  46. void CHudChat::CreateChatLines( void )
  47. {
  48. m_ChatLine = new CHudChatLine( this, "ChatLine1" );
  49. m_ChatLine->SetVisible( false );
  50. }
  51. void CHudChat::ApplySchemeSettings( vgui::IScheme *pScheme )
  52. {
  53. BaseClass::ApplySchemeSettings( pScheme );
  54. }
  55. void CHudChat::Init( void )
  56. {
  57. BaseClass::Init();
  58. HOOK_HUD_MESSAGE( CHudChat, SayText );
  59. HOOK_HUD_MESSAGE( CHudChat, SayText2 );
  60. HOOK_HUD_MESSAGE( CHudChat, TextMsg );
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose: Overrides base reset to not cancel chat at round restart
  64. //-----------------------------------------------------------------------------
  65. void CHudChat::Reset( void )
  66. {
  67. }
  68. int CHudChat::GetChatInputOffset( void )
  69. {
  70. if ( m_pChatInput->IsVisible() )
  71. {
  72. return m_iFontHeight;
  73. }
  74. else
  75. return 0;
  76. }
  77. Color CHudChat::GetClientColor( int clientIndex )
  78. {
  79. if ( clientIndex == 0 ) // console msg
  80. {
  81. return g_ColorYellow;
  82. }
  83. else if( g_PR )
  84. {
  85. switch ( g_PR->GetTeam( clientIndex ) )
  86. {
  87. case TEAM_COMBINE : return g_ColorBlue;
  88. case TEAM_REBELS : return g_ColorRed;
  89. default : return g_ColorYellow;
  90. }
  91. }
  92. return g_ColorYellow;
  93. }