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.

70 lines
1.6 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef CLOSEDCAPTIONS_H
  7. #define CLOSEDCAPTIONS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "captioncompiler.h"
  12. #include "tier1/utlsymbol.h"
  13. #include "tier1/utlsortvector.h"
  14. FORWARD_DECLARE_HANDLE( memhandle_t );
  15. typedef CUtlSortVector< CaptionLookup_t, CCaptionLookupLess > CaptionDictionary_t;
  16. struct AsyncCaption_t
  17. {
  18. AsyncCaption_t() :
  19. m_DataBaseFile( UTL_INVAL_SYMBOL ),
  20. m_RequestedBlocks( 0, 0, BlockInfo_t::Less )
  21. {
  22. Q_memset( &m_Header, 0, sizeof( m_Header ) );
  23. }
  24. struct BlockInfo_t
  25. {
  26. int fileindex;
  27. int blocknum;
  28. memhandle_t handle;
  29. static bool Less( const BlockInfo_t& lhs, const BlockInfo_t& rhs )
  30. {
  31. if ( lhs.fileindex != rhs.fileindex )
  32. return lhs.fileindex < rhs.fileindex;
  33. return lhs.blocknum < rhs.blocknum;
  34. }
  35. };
  36. AsyncCaption_t& operator =( const AsyncCaption_t& rhs )
  37. {
  38. if ( this == &rhs )
  39. return *this;
  40. m_CaptionDirectory = rhs.m_CaptionDirectory;
  41. m_Header = rhs.m_Header;
  42. m_DataBaseFile = rhs.m_DataBaseFile;
  43. for ( int i = rhs.m_RequestedBlocks.FirstInorder(); i != rhs.m_RequestedBlocks.InvalidIndex(); i = rhs.m_RequestedBlocks.NextInorder( i ) )
  44. {
  45. m_RequestedBlocks.Insert( rhs.m_RequestedBlocks[ i ] );
  46. }
  47. return *this;
  48. }
  49. bool LoadFromFile( char const *pchFullPath );
  50. CUtlRBTree< BlockInfo_t, unsigned short > m_RequestedBlocks;
  51. CaptionDictionary_t m_CaptionDirectory;
  52. CompiledCaptionHeader_t m_Header;
  53. CUtlSymbol m_DataBaseFile;
  54. };
  55. #endif // CLOSEDCAPTIONS_H