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.

136 lines
3.0 KiB

  1. //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef MESSAGE_H
  9. #define MESSAGE_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "hudelement.h"
  14. #include "vgui_controls/Panel.h"
  15. #include "itextmessage.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. using namespace vgui;
  19. struct client_textmessage_t;
  20. const int maxHUDMessages = 16;
  21. struct message_parms_t
  22. {
  23. client_textmessage_t *pMessage;
  24. float time;
  25. int x, y;
  26. int totalWidth, totalHeight;
  27. int width;
  28. int lines;
  29. int lineLength;
  30. int length;
  31. int r, g, b;
  32. int text;
  33. int fadeBlend;
  34. float charTime;
  35. float fadeTime;
  36. const char *vguiFontName;
  37. vgui::HFont font;
  38. };
  39. //
  40. //-----------------------------------------------------
  41. //
  42. class CHudMessage: public CHudElement, public vgui::Panel, public ITextMessage
  43. {
  44. DECLARE_CLASS_SIMPLE( CHudMessage, vgui::Panel );
  45. public:
  46. enum
  47. {
  48. TYPE_UNKNOWN = 0,
  49. TYPE_POSITION,
  50. TYPE_CHARACTER,
  51. TYPE_FONT,
  52. };
  53. struct message_t
  54. {
  55. vgui::HFont font;
  56. short x, y;
  57. wchar_t ch;
  58. byte type;
  59. byte r, g, b, a;
  60. };
  61. explicit CHudMessage( const char *pElementName );
  62. ~CHudMessage();
  63. void Init( void );
  64. void VidInit( void );
  65. bool ShouldDraw( void );
  66. virtual void Paint();
  67. bool MsgFunc_HudText(const CCSUsrMsg_HudText &msg);
  68. bool MsgFunc_GameTitle(const CCSUsrMsg_GameTitle &msg);
  69. bool MsgFunc_HudMsg(const CCSUsrMsg_HudMsg &msg);
  70. float FadeBlend( float fadein, float fadeout, float hold, float localTime );
  71. int XPosition( float x, int width, int lineWidth );
  72. int YPosition( float y, int height );
  73. void MessageAdd( const char *pName );
  74. void MessageDrawScan( client_textmessage_t *pMessage, float time );
  75. void MessageScanStart( void );
  76. void MessageScanNextChar( void );
  77. void Reset( void );
  78. virtual void ApplySchemeSettings( IScheme *scheme );
  79. void SetFont( HScheme scheme, const char *pFontName );
  80. CUserMessageBinder m_UMCMsgHudText;
  81. CUserMessageBinder m_UMCMsgGameTitle;
  82. CUserMessageBinder m_UMCMsgHudMsg;
  83. public: // ITextMessage
  84. virtual void SetPosition( int x, int y );
  85. virtual void AddChar( int r, int g, int b, int a, wchar_t ch );
  86. virtual void GetLength( int *wide, int *tall, const char *string );
  87. virtual int GetFontInfo( FONTABC *pABCs, vgui::HFont hFont );
  88. virtual void SetFont( vgui::HFont hCustomFont );
  89. virtual void SetDefaultFont( void );
  90. private:
  91. message_t *AllocMessage( void );
  92. void ResetCharacters( void );
  93. void PaintCharacters();
  94. virtual void GetTextExtents( int *wide, int *tall, const char *string );
  95. client_textmessage_t *m_pMessages[maxHUDMessages];
  96. float m_startTime[maxHUDMessages];
  97. message_parms_t m_parms;
  98. float m_gameTitleTime;
  99. client_textmessage_t *m_pGameTitle;
  100. bool m_bHaveMessage;
  101. CHudTexture *m_iconTitleLife;
  102. CHudTexture *m_iconTitleHalf;
  103. vgui::HFont m_hFont;
  104. vgui::HFont m_hDefaultFont;
  105. CUtlVector< message_t > m_Messages;
  106. };
  107. #endif //#ifndef MESSAGE_H