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.

74 lines
2.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef CLOSECAPTIONTOOL_H
  7. #define CLOSECAPTIONTOOL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <mxtk/mx.h>
  12. #include "UtlVector.h"
  13. #include "faceposertoolwindow.h"
  14. #include "iclosecaptionmanager.h"
  15. class CCloseCaptionItem;
  16. struct WorkUnitParams;
  17. class CloseCaptionTool : public mxWindow, public IFacePoserToolWindow, public ICloseCaptionManager
  18. {
  19. public:
  20. // Construction
  21. CloseCaptionTool( mxWindow *parent );
  22. ~CloseCaptionTool( void );
  23. // ICloseCaptionManager
  24. virtual void Reset( void );
  25. virtual void Process( char const *tokenname, float duration, int languageid );
  26. virtual bool LookupUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );
  27. virtual bool LookupStrippedUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );
  28. // End ICloseCaptionManager
  29. virtual void Think( float dt );
  30. virtual int handleEvent( mxEvent *event );
  31. virtual void redraw( void );
  32. virtual bool PaintBackground();
  33. enum
  34. {
  35. CCFONT_NORMAL = 0,
  36. CCFONT_ITALIC,
  37. CCFONT_BOLD,
  38. CCFONT_ITALICBOLD
  39. };
  40. static int GetFontNumber( bool bold, bool italic );
  41. private:
  42. void ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item );
  43. void DrawStream( CChoreoWidgetDrawHelper &helper, RECT &rcText, CCloseCaptionItem *item );
  44. bool SplitCommand( const wchar_t **in, wchar_t *cmd, wchar_t *args ) const;
  45. void ParseCloseCaptionStream( const wchar_t *in, int available_width );
  46. void DumpWork( CCloseCaptionItem *item );
  47. void AddWorkUnit(
  48. CCloseCaptionItem *item,
  49. WorkUnitParams& params );
  50. CUtlVector< CCloseCaptionItem * > m_Items;
  51. HFONT m_hFonts[ 4 ]; // normal, italic, bold, bold + italic
  52. int m_nLastItemCount;
  53. };
  54. extern CloseCaptionTool *g_pCloseCaptionTool;
  55. #endif // CLOSECAPTIONTOOL_H