summaryrefslogtreecommitdiff
path: root/utils/hlfaceposer/CloseCaptionTool.h
blob: d16f23dba6292114f78ba6f5bb3e93c1f4dbc60c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef CLOSECAPTIONTOOL_H
#define CLOSECAPTIONTOOL_H
#ifdef _WIN32
#pragma once
#endif

#include <mxtk/mx.h>
#include "utlvector.h"
#include "faceposertoolwindow.h"
#include "iclosecaptionmanager.h"

class CCloseCaptionItem;
struct WorkUnitParams;

class CloseCaptionTool : public mxWindow, public IFacePoserToolWindow, public ICloseCaptionManager
{
public:
	// Construction
						CloseCaptionTool( mxWindow *parent );
						~CloseCaptionTool( void );

	// ICloseCaptionManager
	virtual void Reset( void );
	virtual void Process( char const *tokenname, float duration, int languageid );
	virtual bool LookupUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );
	virtual bool LookupStrippedUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );

	// End ICloseCaptionManager

	virtual void		Think( float dt );

	virtual int			handleEvent( mxEvent *event );
	virtual void		redraw( void );
	virtual bool		PaintBackground();

	enum
	{
		CCFONT_NORMAL = 0,
		CCFONT_ITALIC,
		CCFONT_BOLD,
		CCFONT_ITALICBOLD
	};

	static int GetFontNumber( bool bold, bool italic );

private:
	void	ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item );
	void	DrawStream( CChoreoWidgetDrawHelper &helper, RECT &rcText, CCloseCaptionItem *item );
	bool	SplitCommand( const wchar_t **in, wchar_t *cmd, wchar_t *args ) const;

	void	ParseCloseCaptionStream( const wchar_t *in, int available_width );

	void	DumpWork( CCloseCaptionItem *item );

	void AddWorkUnit( 
		CCloseCaptionItem *item,	
		WorkUnitParams& params );

	CUtlVector< CCloseCaptionItem * > m_Items;

	HFONT m_hFonts[ 4 ];  // normal, italic, bold, bold + italic

	int									m_nLastItemCount;
};

extern CloseCaptionTool	*g_pCloseCaptionTool;

#endif // CLOSECAPTIONTOOL_H