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.

86 lines
1.8 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. //===================================================================================//
  4. #ifndef _SUBTITLEPANEL_H_
  5. #define _SUBTITLEPANEL_H_
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. #include <vgui_controls/Panel.h>
  10. #include <vgui_controls/ImagePanel.h>
  11. #include <vgui_controls/EditablePanel.h>
  12. #include <vgui_controls/Label.h>
  13. namespace vgui
  14. {
  15. class IScheme;
  16. };
  17. #define MAX_CAPTION_LENGTH 256
  18. class CCaptionSequencer
  19. {
  20. public:
  21. CCaptionSequencer();
  22. void Reset();
  23. bool Init( const char *pFilename );
  24. void SetStartTime( float flStarTtime );
  25. bool GetCaptionToken( char *token, int tokenLen );
  26. bool GetNextCaption();
  27. const char *GetCurrentCaption( int *pColorOut );
  28. void Pause( bool bPause );
  29. float GetAlpha();
  30. private:
  31. float GetElapsedTime();
  32. bool m_bCaptions;
  33. bool m_bShowingCaption;
  34. bool m_bCaptionStale;
  35. bool m_bPaused;
  36. float m_CaptionStartTime;
  37. float m_CurCaptionStartTime;
  38. float m_CurCaptionEndTime;
  39. float m_flPauseTime;
  40. float m_flTotalPauseTime;
  41. vgui::HScheme m_hCaptionFont;
  42. CUtlBuffer m_CaptionBuf;
  43. char m_CurCaptionString[MAX_CAPTION_LENGTH];
  44. unsigned int m_CurCaptionColor;
  45. };
  46. // Panel for drawing subtitles
  47. class CSubtitlePanel : public vgui::Panel
  48. {
  49. DECLARE_CLASS_SIMPLE( CSubtitlePanel, vgui::Panel );
  50. public:
  51. CSubtitlePanel( vgui::Panel *pParent, const char *pMovieName, int nPlaybackHeight );
  52. bool StartCaptions();
  53. bool HasCaptions();
  54. void Pause( bool bPause );
  55. protected:
  56. virtual void OnThink();
  57. virtual void PaintBackground();
  58. private:
  59. CCaptionSequencer m_Captions;
  60. vgui::HFont m_hFont;
  61. vgui::Label *m_pSubtitleLabel;
  62. int m_nFontTall;
  63. bool m_bHasCaptions;
  64. };
  65. extern bool ShouldUseCaptioning();
  66. #endif // _SUBTITLEPANEL_H_