Team Fortress 2 Source Code as on 22/4/2020
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.

783 lines
23 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdio.h>
  8. #include "hlfaceposer.h"
  9. #include "choreoeventwidget.h"
  10. #include "choreochannelwidget.h"
  11. #include "choreowidgetdrawhelper.h"
  12. #include "choreoview.h"
  13. #include "choreoevent.h"
  14. #include "choreochannel.h"
  15. #include "choreoscene.h"
  16. #include "choreoviewcolors.h"
  17. #include "ifaceposersound.h"
  18. #include "snd_audio_source.h"
  19. #include "RampTool.h"
  20. // Static members
  21. mxbitmapdata_t CChoreoEventWidget::m_Bitmaps[ FP_NUM_BITMAPS ];
  22. mxbitmapdata_t CChoreoEventWidget::m_ResumeConditionBitmap;
  23. mxbitmapdata_t CChoreoEventWidget::m_LockBodyFacingBitmap;
  24. //-----------------------------------------------------------------------------
  25. // Purpose:
  26. // Input : *parent -
  27. //-----------------------------------------------------------------------------
  28. CChoreoEventWidget::CChoreoEventWidget( CChoreoWidget *parent )
  29. : CChoreoWidget( parent )
  30. {
  31. m_pEvent = NULL;
  32. m_pParent = parent;
  33. m_pWaveFile = NULL;
  34. m_nDurationRightEdge= 0;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. //-----------------------------------------------------------------------------
  39. CChoreoEventWidget::~CChoreoEventWidget( void )
  40. {
  41. delete m_pWaveFile;
  42. m_pWaveFile = NULL;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. void CChoreoEventWidget::Create( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. // Output : const char
  53. //-----------------------------------------------------------------------------
  54. const char *CChoreoEventWidget::GetLabelText( void )
  55. {
  56. static char label[ 256 ];
  57. if ( GetEvent()->GetType() == CChoreoEvent::EXPRESSION )
  58. {
  59. sprintf( label, "%s : %s", GetEvent()->GetParameters(), GetEvent()->GetParameters2() );
  60. }
  61. else
  62. {
  63. V_strcpy_safe( label, GetEvent()->GetParameters() );
  64. }
  65. return label;
  66. }
  67. //-----------------------------------------------------------------------------
  68. // Purpose:
  69. //-----------------------------------------------------------------------------
  70. int CChoreoEventWidget::GetDurationRightEdge( void )
  71. {
  72. return m_nDurationRightEdge;
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Purpose:
  76. // Input : rc -
  77. //-----------------------------------------------------------------------------
  78. void CChoreoEventWidget::Layout( RECT& rc )
  79. {
  80. int requestedW = rc.right - rc.left;
  81. m_nDurationRightEdge = requestedW;
  82. setBounds( rc.left, rc.top, requestedW, rc.bottom - rc.top );
  83. }
  84. //-----------------------------------------------------------------------------
  85. // Purpose:
  86. // Input : drawHelper -
  87. // &rcWAV -
  88. //-----------------------------------------------------------------------------
  89. void CChoreoEventWidget::DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event )
  90. {
  91. for ( int i = 0; i < event->GetNumRelativeTags(); i++ )
  92. {
  93. CEventRelativeTag *tag = event->GetRelativeTag( i );
  94. if ( !tag )
  95. continue;
  96. //
  97. int left = rcWAV.left + (int)( tag->GetPercentage() * ( float )( rcWAV.right - rcWAV.left ) + 0.5f );
  98. RECT rcMark;
  99. rcMark = rcWAV;
  100. rcMark.top -= 2;
  101. rcMark.bottom = rcMark.top + 6;
  102. rcMark.left = left - 3;
  103. rcMark.right = left + 3;
  104. drawHelper.DrawTriangleMarker( rcMark, RGB( 0, 100, 250 ) );
  105. RECT rcText;
  106. rcText = rcMark;
  107. rcText.top -= 12;
  108. int len = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, tag->GetName() );
  109. rcText.left = left - len / 2;
  110. rcText.right = rcText.left + len + 2;
  111. rcText.bottom = rcText.top + 10;
  112. drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, RGB( 0, 100, 200 ), rcText, tag->GetName() );
  113. }
  114. }
  115. //-----------------------------------------------------------------------------
  116. // Purpose:
  117. // Input : drawHelper -
  118. // &rcWAV -
  119. //-----------------------------------------------------------------------------
  120. void CChoreoEventWidget::DrawAbsoluteTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event )
  121. {
  122. for ( int i = 0; i < event->GetNumAbsoluteTags( CChoreoEvent::PLAYBACK ); i++ )
  123. {
  124. CEventAbsoluteTag *tag = event->GetAbsoluteTag( CChoreoEvent::PLAYBACK, i );
  125. if ( !tag )
  126. continue;
  127. //
  128. int left = rcWAV.left + (int)( tag->GetPercentage() * ( float )( rcWAV.right - rcWAV.left ) + 0.5f );
  129. RECT rcMark;
  130. rcMark = rcWAV;
  131. rcMark.top -= 2;
  132. rcMark.bottom = rcMark.top + 6;
  133. rcMark.left = left - 3;
  134. rcMark.right = left + 3;
  135. drawHelper.DrawTriangleMarker( rcMark, RGB( 0, 100, 250 ) );
  136. RECT rcText;
  137. rcText = rcMark;
  138. rcText.top -= 12;
  139. int len = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, tag->GetName() );
  140. rcText.left = left - len / 2;
  141. rcText.right = rcText.left + len + 2;
  142. rcText.bottom = rcText.top + 10;
  143. drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, RGB( 0, 100, 200 ), rcText, tag->GetName() );
  144. }
  145. }
  146. //-----------------------------------------------------------------------------
  147. // Purpose:
  148. // Input : drawHelper -
  149. // rcBounds -
  150. //-----------------------------------------------------------------------------
  151. void CChoreoEventWidget::redrawStatus( CChoreoWidgetDrawHelper& drawHelper, RECT& rcClient )
  152. {
  153. if ( !getVisible() )
  154. return;
  155. CChoreoEvent *event = GetEvent();
  156. if ( !event )
  157. return;
  158. int deflateborder = 1;
  159. int fontsize = 9;
  160. HDC dc = drawHelper.GrabDC();
  161. // Now draw the label
  162. RECT rcEventLabel;
  163. rcEventLabel = rcClient;
  164. InflateRect( &rcEventLabel, 0, -deflateborder );
  165. // rcEventLabel.top += 2;
  166. rcEventLabel.left += 2;
  167. //rcEventLabel.top = rcEventLabel.bottom - 2 * ( fontsize + 2 ) - 1;
  168. //rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
  169. int leftAdd = 16;
  170. if ( CChoreoEventWidget::GetImage( event->GetType() ) )
  171. {
  172. mxbitmapdata_t *image = CChoreoEventWidget::GetImage( event->GetType() );
  173. if ( image )
  174. {
  175. RECT rcFixed = rcEventLabel;
  176. drawHelper.OffsetSubRect( rcFixed );
  177. DrawBitmapToDC( dc, rcFixed.left, rcFixed.top, leftAdd, leftAdd,
  178. *image );
  179. }
  180. }
  181. OffsetRect( &rcEventLabel, leftAdd, 0 );
  182. if ( event->IsResumeCondition() )
  183. {
  184. RECT rc = rcEventLabel;
  185. OffsetRect( &rcEventLabel, 16, 0 );
  186. rc.right = rc.left + leftAdd;
  187. rc.bottom = rc.top + leftAdd;
  188. RECT rcFixed = rc;
  189. drawHelper.OffsetSubRect( rcFixed );
  190. DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
  191. rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
  192. *CChoreoEventWidget::GetPauseImage() );
  193. }
  194. if ( event->IsLockBodyFacing() )
  195. {
  196. RECT rc = rcEventLabel;
  197. OffsetRect( &rcEventLabel, 16, 0 );
  198. rc.right = rc.left + leftAdd;
  199. rc.bottom = rc.top + leftAdd;
  200. RECT rcFixed = rc;
  201. drawHelper.OffsetSubRect( rcFixed );
  202. DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
  203. rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
  204. *CChoreoEventWidget::GetLockImage() );
  205. }
  206. // Draw Type Name:
  207. OffsetRect( &rcEventLabel, 2, 1 );
  208. rcEventLabel.left = rcClient.left + 32;
  209. rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
  210. // OffsetRect( &rcEventLabel, 0, 2 );
  211. drawHelper.CalcTextWidth( "Arial", fontsize, FW_NORMAL, "%s event \"%s\"", event->NameForType( event->GetType() ), event->GetName() );
  212. drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, COLOR_INFO_TEXT, rcEventLabel, "%s event \"%s\"", event->NameForType( event->GetType() ), event->GetName() );
  213. OffsetRect( &rcEventLabel, 0, fontsize + 2 );
  214. drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, COLOR_INFO_TEXT, rcEventLabel, "parameters \"%s\"", GetLabelText() );
  215. }
  216. COLORREF CChoreoEventWidget::GrayOutColor( COLORREF clr )
  217. {
  218. CChoreoEvent *event = GetEvent();
  219. if ( !event )
  220. return clr;
  221. if ( event->GetActive() )
  222. return clr;
  223. int r, g, b;
  224. r = GetRValue( clr );
  225. g = GetGValue( clr );
  226. b = GetBValue( clr );
  227. int val = ( r + g + b ) / 3;
  228. val += ( 255 - val ) * 0.25f;
  229. clr = RGB( val, val, val );
  230. return clr;
  231. }
  232. void CChoreoEventWidget::DrawSpeakEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
  233. {
  234. if ( !m_pWaveFile )
  235. return;
  236. bool ramponly = m_pView->IsRampOnly();
  237. CChoreoEvent *event = GetEvent();
  238. Assert( event );
  239. HDC dc = drawHelper.GrabDC();
  240. HBRUSH brEvent = CreateSolidBrush( GrayOutColor( COLOR_CHOREO_EVENT ) );
  241. HBRUSH brBackground = CreateSolidBrush( GrayOutColor( COLOR_CHOREO_DARKBACKGROUND ) );
  242. if ( !ramponly )
  243. {
  244. FillRect( dc, &rcEventLine, brBackground );
  245. }
  246. // Only draw wav form here if selected
  247. if ( IsSelected() )
  248. {
  249. sound->RenderWavToDC( dc, rcEventLine, GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT ), 0.0, m_pWaveFile->GetRunningLength(), m_pWaveFile );
  250. }
  251. //FrameRect( dc, &rcEventLine, brEvent );
  252. drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
  253. rcEventLine.left, rcEventLine.top, rcEventLine.left, rcEventLine.bottom );
  254. drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
  255. rcEventLine.right, rcEventLine.top, rcEventLine.right, rcEventLine.bottom );
  256. DeleteObject( brBackground );
  257. DeleteObject( brEvent );
  258. //rcEventLine.top -= 3;
  259. DrawRelativeTags( drawHelper, rcEventLine, m_pWaveFile->GetRunningLength(), event );
  260. }
  261. void CChoreoEventWidget::DrawGestureEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
  262. {
  263. CChoreoEvent *event = GetEvent();
  264. Assert( event );
  265. RECT rcEventLine2 = rcEventLine;
  266. /*
  267. float duration = event->GetDuration();
  268. // Crop eventline2
  269. if ( duration > 0.0f )
  270. {
  271. float attack_frac = 0.3; // ( event->GetAttackTime() ) / duration;
  272. float decay_frac = 0.7; // ( event->GetDecayTime() ) / duration;
  273. float event_line_width = rcEventLine.right - rcEventLine.left;
  274. rcEventLine2.left = rcEventLine.left + attack_frac * event_line_width;
  275. rcEventLine2.right = rcEventLine.left + decay_frac * event_line_width;
  276. }
  277. */
  278. bool ramponly = m_pView->IsRampOnly();
  279. HDC dc = drawHelper.GrabDC();
  280. bool nullevent = false;
  281. COLORREF clrEvent = GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT );
  282. if ( !Q_stricmp( event->GetName(), "NULL" ) )
  283. {
  284. clrEvent = GrayOutColor( RGB( 50, 50, 120 ) );
  285. nullevent = true;
  286. }
  287. HBRUSH brEvent = CreateSolidBrush( clrEvent );
  288. if ( !ramponly )
  289. {
  290. FillRect( dc, &rcEventLine2, brEvent );
  291. }
  292. DeleteObject( brEvent );
  293. if ( ramponly && IsSelected() )
  294. {
  295. drawHelper.DrawOutlinedRect( GrayOutColor( RGB( 150, 180, 250 ) ), PS_SOLID, 1,
  296. rcEventLine2 );
  297. }
  298. else
  299. {
  300. drawHelper.DrawColoredLine( GrayOutColor( RGB( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine2.left, rcEventLine2.bottom,
  301. rcEventLine2.left, rcEventLine2.top );
  302. drawHelper.DrawColoredLine( GrayOutColor( RGB( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine2.left, rcEventLine2.top,
  303. rcEventLine2.right, rcEventLine2.top );
  304. drawHelper.DrawColoredLine( GrayOutColor( RGB( 31, 31, 31 ) ), PS_SOLID, 1, rcEventLine2.right, rcEventLine2.top,
  305. rcEventLine2.right, rcEventLine2.bottom );
  306. drawHelper.DrawColoredLine( GrayOutColor( RGB( 0, 0, 0 ) ), PS_SOLID, 1, rcEventLine2.right, rcEventLine2.bottom,
  307. rcEventLine2.left, rcEventLine2.bottom );
  308. }
  309. int rampstart = m_pView->GetPixelForTimeValue( event->GetStartTime( ) );
  310. int rampend = m_pView->GetPixelForTimeValue( event->GetEndTime( ) );
  311. // COLORREF clrBottom = RGB( 180, 180, 180 );
  312. // drawHelper.DrawColoredLine( clrBottom, PS_SOLID, 1, rampstart, rcEventLine2.bottom,
  313. // rcEventLine2.left, rcEventLine2.bottom );
  314. // drawHelper.DrawColoredLine( clrBottom, PS_SOLID, 1, rcEventLine2.right, rcEventLine2.bottom,
  315. // rampend, rcEventLine2.bottom );
  316. if ( !nullevent )
  317. {
  318. drawHelper.DrawColoredRamp( clrEvent, PS_SOLID, 1,
  319. rampstart,
  320. rcEventLine2.bottom,
  321. rcEventLine2.left,
  322. rcEventLine2.top,
  323. 0.0f,
  324. 1.0f );
  325. drawHelper.DrawColoredRamp( clrEvent, PS_SOLID, 1,
  326. rcEventLine2.right,
  327. rcEventLine2.top,
  328. rampend,
  329. rcEventLine2.bottom,
  330. 0.0f,
  331. 1.0f );
  332. }
  333. g_pRampTool->DrawSamplesSimple( drawHelper, event, false, GrayOutColor( RGB( 63, 63, 63 ) ), rcEventLine );
  334. DrawRelativeTags( drawHelper, rcEventLine, event->GetDuration(), event );
  335. DrawAbsoluteTags( drawHelper, rcEventLine, event->GetDuration(), event );
  336. }
  337. void CChoreoEventWidget::DrawGenericEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
  338. {
  339. bool ramponly = m_pView->IsRampOnly();
  340. CChoreoEvent *event = GetEvent();
  341. Assert( event );
  342. HDC dc = drawHelper.GrabDC();
  343. COLORREF clrEvent = GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT );
  344. if ( event->GetType() == CChoreoEvent::SUBSCENE )
  345. {
  346. clrEvent = GrayOutColor( RGB( 200, 180, 200 ) );
  347. }
  348. HBRUSH brEvent = CreateSolidBrush( clrEvent );
  349. if ( !ramponly )
  350. {
  351. FillRect( dc, &rcEventLine, brEvent );
  352. }
  353. DeleteObject( brEvent );
  354. if ( ramponly && IsSelected() )
  355. {
  356. drawHelper.DrawOutlinedRect( GrayOutColor( RGB( 150, 180, 250 ) ), PS_SOLID, 1,
  357. rcEventLine );
  358. }
  359. else
  360. {
  361. drawHelper.DrawColoredLine( GrayOutColor( RGB( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine.left, rcEventLine.bottom,
  362. rcEventLine.left, rcEventLine.top );
  363. drawHelper.DrawColoredLine( GrayOutColor( RGB( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine.left, rcEventLine.top,
  364. rcEventLine.right, rcEventLine.top );
  365. drawHelper.DrawColoredLine( GrayOutColor( RGB( 31, 31, 31 ) ), PS_SOLID, 1, rcEventLine.right, rcEventLine.top,
  366. rcEventLine.right, rcEventLine.bottom );
  367. drawHelper.DrawColoredLine( GrayOutColor( RGB( 0, 0, 0 ) ), PS_SOLID, 1, rcEventLine.right, rcEventLine.bottom,
  368. rcEventLine.left, rcEventLine.bottom );
  369. }
  370. g_pRampTool->DrawSamplesSimple( drawHelper, event, false, GrayOutColor( RGB( 63, 63, 63 ) ), rcEventLine );
  371. DrawRelativeTags( drawHelper, rcEventLine, event->GetDuration(), event );
  372. DrawAbsoluteTags( drawHelper, rcEventLine, event->GetDuration(), event );
  373. }
  374. //-----------------------------------------------------------------------------
  375. // Purpose: FIXME: This should either be embedded or we should draw the caption
  376. // here
  377. //-----------------------------------------------------------------------------
  378. void CChoreoEventWidget::redraw( CChoreoWidgetDrawHelper& drawHelper )
  379. {
  380. if ( !getVisible() )
  381. return;
  382. CChoreoEvent *event = GetEvent();
  383. if ( !event )
  384. return;
  385. int deflateborder = 1;
  386. int fontsize = 9;
  387. HDC dc = drawHelper.GrabDC();
  388. RECT rcClient = getBounds();
  389. RECT rcDC;
  390. drawHelper.GetClientRect( rcDC );
  391. RECT dummy;
  392. if ( !IntersectRect( &dummy, &rcDC, &rcClient ) )
  393. return;
  394. bool ramponly = m_pView->IsRampOnly();
  395. if ( IsSelected() && !ramponly )
  396. {
  397. InflateRect( &rcClient, 3, 1 );
  398. //rcClient.bottom -= 1;
  399. rcClient.right += 1;
  400. RECT rcFrame = rcClient;
  401. RECT rcBorder = rcClient;
  402. rcFrame.bottom = rcFrame.top + 17;
  403. rcBorder.bottom = rcFrame.top + 17;
  404. COLORREF clrSelection = GrayOutColor( RGB( 0, 63, 63 ) );
  405. COLORREF clrBorder = GrayOutColor( RGB( 100, 200, 255 ) );
  406. HBRUSH brBorder = CreateSolidBrush( clrBorder );
  407. HBRUSH brSelected = CreateHatchBrush( HS_FDIAGONAL, clrSelection );
  408. for ( int i = 0; i < 2; i++ )
  409. {
  410. FrameRect( dc, &rcFrame, brSelected );
  411. InflateRect( &rcFrame, -1, -1 );
  412. }
  413. FrameRect( dc, &rcBorder, brBorder );
  414. FrameRect( dc, &rcFrame, brBorder );
  415. DeleteObject( brSelected );
  416. DeleteObject( brBorder );
  417. rcClient.right -= 1;
  418. //rcClient.bottom += 1;
  419. InflateRect( &rcClient, -3, -1 );
  420. }
  421. RECT rcEvent;
  422. rcEvent = rcClient;
  423. InflateRect( &rcEvent, 0, -deflateborder );
  424. rcEvent.bottom = rcEvent.top + 10;
  425. if ( event->GetType() == CChoreoEvent::SPEAK && m_pWaveFile && !event->HasEndTime() )
  426. {
  427. event->SetEndTime( event->GetStartTime() + m_pWaveFile->GetRunningLength() );
  428. rcEvent.right = ( int )( m_pWaveFile->GetRunningLength() * m_pView->GetPixelsPerSecond() );
  429. }
  430. if ( event->HasEndTime() )
  431. {
  432. RECT rcEventLine = rcEvent;
  433. OffsetRect( &rcEventLine, 0, 1 );
  434. switch ( event->GetType() )
  435. {
  436. case CChoreoEvent::SPEAK:
  437. {
  438. DrawSpeakEvent( drawHelper, rcEventLine );
  439. }
  440. break;
  441. case CChoreoEvent::GESTURE:
  442. {
  443. DrawGestureEvent( drawHelper, rcEventLine );
  444. }
  445. break;
  446. default:
  447. {
  448. DrawGenericEvent( drawHelper, rcEventLine );
  449. }
  450. break;
  451. }
  452. }
  453. else
  454. {
  455. RECT rcEventLine = rcEvent;
  456. OffsetRect( &rcEventLine, 0, 1 );
  457. drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
  458. rcEventLine.left - 1, rcEventLine.top, rcEventLine.left - 1, rcEventLine.bottom );
  459. }
  460. if ( event->IsUsingRelativeTag() )
  461. {
  462. RECT rcTagName;
  463. rcTagName = rcClient;
  464. int length = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, event->GetRelativeTagName() );
  465. rcTagName.right = rcTagName.left;
  466. rcTagName.left = rcTagName.right - length - 4;
  467. rcTagName.top += 3;
  468. rcTagName.bottom = rcTagName.top + 10;
  469. drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, GrayOutColor( RGB( 0, 100, 200 ) ), rcTagName, event->GetRelativeTagName() );
  470. drawHelper.DrawFilledRect( GrayOutColor( RGB( 0, 100, 250 ) ), rcTagName.right-1, rcTagName.top-2,
  471. rcTagName.right+2, rcTagName.bottom + 2 );
  472. }
  473. // Now draw the label
  474. RECT rcEventLabel;
  475. rcEventLabel = rcClient;
  476. InflateRect( &rcEventLabel, 0, -deflateborder );
  477. rcEventLabel.top += 15; // rcEventLabel.bottom - 2 * ( fontsize + 2 ) - 1;
  478. rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
  479. rcEventLabel.left += 1;
  480. //rcEventLabel.left -= 8;
  481. int leftAdd = 16;
  482. if ( CChoreoEventWidget::GetImage( event->GetType() ) )
  483. {
  484. mxbitmapdata_t *image = CChoreoEventWidget::GetImage( event->GetType() );
  485. if ( image )
  486. {
  487. DrawBitmapToDC( dc, rcEventLabel.left, rcEventLabel.top, leftAdd, leftAdd,
  488. *image );
  489. }
  490. }
  491. OffsetRect( &rcEventLabel, leftAdd, 1 );
  492. if ( event->IsResumeCondition() )
  493. {
  494. RECT rc = rcEventLabel;
  495. OffsetRect( &rcEventLabel, leftAdd, 0 );
  496. rc.right = rc.left + leftAdd;
  497. rc.bottom = rc.top + leftAdd;
  498. DrawBitmapToDC( dc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
  499. *CChoreoEventWidget::GetPauseImage() );
  500. }
  501. if ( event->IsLockBodyFacing() )
  502. {
  503. RECT rc = rcEventLabel;
  504. OffsetRect( &rcEventLabel, 16, 0 );
  505. rc.right = rc.left + leftAdd;
  506. rc.bottom = rc.top + leftAdd;
  507. RECT rcFixed = rc;
  508. drawHelper.OffsetSubRect( rcFixed );
  509. DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
  510. rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
  511. *CChoreoEventWidget::GetLockImage() );
  512. }
  513. OffsetRect( &rcEventLabel, 2, 1 );
  514. int len = drawHelper.CalcTextWidth( "Arial", fontsize, FW_NORMAL, event->GetName() );
  515. rcEventLabel.right = rcEventLabel.left + len + 2;
  516. drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, GrayOutColor( RGB( 0, 0, 120 ) ),
  517. rcEventLabel, event->GetName() );
  518. }
  519. //-----------------------------------------------------------------------------
  520. // Purpose:
  521. // Output : CChoreoEvent
  522. //-----------------------------------------------------------------------------
  523. CChoreoEvent *CChoreoEventWidget::GetEvent( void )
  524. {
  525. return m_pEvent;
  526. }
  527. //-----------------------------------------------------------------------------
  528. // Purpose:
  529. // Input : *event -
  530. //-----------------------------------------------------------------------------
  531. void CChoreoEventWidget::SetEvent( CChoreoEvent *event )
  532. {
  533. sound->StopAll();
  534. delete m_pWaveFile;
  535. m_pWaveFile = NULL;
  536. m_pEvent = event;
  537. if ( event->GetType() == CChoreoEvent::SPEAK )
  538. {
  539. m_pWaveFile = sound->LoadSound( va( "sound/%s", FacePoser_TranslateSoundName( event ) ) );
  540. }
  541. }
  542. //-----------------------------------------------------------------------------
  543. // Purpose: If the user changes the association of .mdls to actors, then the gender could change and we could need to access a different .wav file
  544. // Input : -
  545. //-----------------------------------------------------------------------------
  546. void CChoreoEventWidget::RecomputeWave()
  547. {
  548. if ( m_pEvent->GetType() == CChoreoEvent::SPEAK )
  549. {
  550. delete m_pWaveFile;
  551. m_pWaveFile = sound->LoadSound( va( "sound/%s", FacePoser_TranslateSoundName( m_pEvent ) ) );
  552. }
  553. }
  554. //-----------------------------------------------------------------------------
  555. // Purpose:
  556. //-----------------------------------------------------------------------------
  557. void CChoreoEventWidget::LoadImages( void )
  558. {
  559. for ( int i = 0; i < FP_NUM_BITMAPS; i++ )
  560. {
  561. m_Bitmaps[ i ].valid = false;
  562. }
  563. m_ResumeConditionBitmap.valid = false;
  564. m_LockBodyFacingBitmap.valid = false;
  565. LoadBitmapFromFile( "gfx/hlfaceposer/ev_expression.bmp", m_Bitmaps[ CChoreoEvent::EXPRESSION ] );
  566. LoadBitmapFromFile( "gfx/hlfaceposer/ev_lookat.bmp", m_Bitmaps[ CChoreoEvent::LOOKAT ] );
  567. LoadBitmapFromFile( "gfx/hlfaceposer/ev_moveto.bmp", m_Bitmaps[ CChoreoEvent::MOVETO ] );
  568. LoadBitmapFromFile( "gfx/hlfaceposer/ev_speak.bmp", m_Bitmaps[ CChoreoEvent::SPEAK ] );
  569. LoadBitmapFromFile( "gfx/hlfaceposer/ev_gesture.bmp", m_Bitmaps[ CChoreoEvent::GESTURE ] );
  570. LoadBitmapFromFile( "gfx/hlfaceposer/ev_face.bmp", m_Bitmaps[ CChoreoEvent::FACE ] );
  571. LoadBitmapFromFile( "gfx/hlfaceposer/ev_firetrigger.bmp", m_Bitmaps[ CChoreoEvent::FIRETRIGGER ] );
  572. LoadBitmapFromFile( "gfx/hlfaceposer/ev_sequence.bmp", m_Bitmaps[ CChoreoEvent::SEQUENCE ] );
  573. LoadBitmapFromFile( "gfx/hlfaceposer/ev_flexanimation.bmp", m_Bitmaps[ CChoreoEvent::FLEXANIMATION ] );
  574. LoadBitmapFromFile( "gfx/hlfaceposer/ev_subscene.bmp", m_Bitmaps[ CChoreoEvent::SUBSCENE ] );
  575. LoadBitmapFromFile( "gfx/hlfaceposer/ev_loop.bmp", m_Bitmaps[ CChoreoEvent::LOOP ] );
  576. LoadBitmapFromFile( "gfx/hlfaceposer/pause.bmp", m_ResumeConditionBitmap );
  577. LoadBitmapFromFile( "gfx/hlfaceposer/ev_interrupt.bmp", m_Bitmaps[ CChoreoEvent::INTERRUPT ] );
  578. LoadBitmapFromFile( "gfx/hlfaceposer/ev_stoppoint.bmp", m_Bitmaps[ CChoreoEvent::STOPPOINT ] );
  579. LoadBitmapFromFile( "gfx/hlfaceposer/ev_permit_response.bmp", m_Bitmaps[ CChoreoEvent::PERMIT_RESPONSES ] );
  580. LoadBitmapFromFile( "gfx/hlfaceposer/ev_generic.bmp", m_Bitmaps[ CChoreoEvent::GENERIC ] );
  581. LoadBitmapFromFile( "gfx/hlfaceposer/lock.bmp", m_LockBodyFacingBitmap );
  582. }
  583. //-----------------------------------------------------------------------------
  584. // Purpose:
  585. //-----------------------------------------------------------------------------
  586. void CChoreoEventWidget::DestroyImages( void )
  587. {
  588. for ( int i = 0; i < FP_NUM_BITMAPS; i++ )
  589. {
  590. if ( m_Bitmaps[ i ].valid )
  591. {
  592. m_Bitmaps[ i ].valid = false;
  593. DeleteObject( m_Bitmaps[ i ].image );
  594. m_Bitmaps[ i ].image = NULL;
  595. }
  596. }
  597. if ( m_ResumeConditionBitmap.valid )
  598. {
  599. m_ResumeConditionBitmap.valid = false;
  600. DeleteObject( m_ResumeConditionBitmap.image );
  601. m_ResumeConditionBitmap.image = NULL;
  602. }
  603. if ( m_LockBodyFacingBitmap.valid )
  604. {
  605. m_LockBodyFacingBitmap.valid = false;
  606. DeleteObject( m_LockBodyFacingBitmap.image );
  607. m_LockBodyFacingBitmap.image = NULL;
  608. }
  609. }
  610. //-----------------------------------------------------------------------------
  611. // Purpose:
  612. // Input : type -
  613. // Output : mxbitmapdata_t
  614. //-----------------------------------------------------------------------------
  615. mxbitmapdata_t *CChoreoEventWidget::GetImage( int type )
  616. {
  617. return &m_Bitmaps[ type ];
  618. }
  619. //-----------------------------------------------------------------------------
  620. // Purpose:
  621. // Output : mxbitmapdata_t
  622. //-----------------------------------------------------------------------------
  623. mxbitmapdata_t *CChoreoEventWidget::GetPauseImage( void )
  624. {
  625. return &m_ResumeConditionBitmap;
  626. }
  627. //-----------------------------------------------------------------------------
  628. // Purpose:
  629. // Output : mxbitmapdata_t
  630. //-----------------------------------------------------------------------------
  631. mxbitmapdata_t *CChoreoEventWidget::GetLockImage( void )
  632. {
  633. return &m_LockBodyFacingBitmap;
  634. }