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.

202 lines
5.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include <mxtk/mx.h>
  9. #include <stdio.h>
  10. #include "resource.h"
  11. #include "EventProperties.h"
  12. #include "mdlviewer.h"
  13. static CEventParams g_Params;
  14. class CEventPropertiesFlexAnimationDialog : public CBaseEventPropertiesDialog
  15. {
  16. typedef CBaseEventPropertiesDialog BaseClass;
  17. public:
  18. virtual void InitDialog( HWND hwndDlg );
  19. virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  20. virtual void SetTitle();
  21. virtual void ShowControlsForEventType( CEventParams *params );
  22. virtual void InitControlData( CEventParams *params );
  23. };
  24. void CEventPropertiesFlexAnimationDialog::SetTitle()
  25. {
  26. SetDialogTitle( &g_Params, "FlexAnimation", "Flex Controller Animation" );
  27. }
  28. void CEventPropertiesFlexAnimationDialog::InitControlData( CEventParams *params )
  29. {
  30. BaseClass::InitControlData( params );
  31. }
  32. void CEventPropertiesFlexAnimationDialog::InitDialog( HWND hwndDlg )
  33. {
  34. m_hDialog = hwndDlg;
  35. g_Params.PositionSelf( m_hDialog );
  36. // Set working title for dialog, etc.
  37. SetTitle();
  38. // Show/Hide dialog controls
  39. ShowControlsForEventType( &g_Params );
  40. InitControlData( &g_Params );
  41. UpdateTagRadioButtons( &g_Params );
  42. SetFocus( GetControl( IDC_EVENTNAME ) );
  43. }
  44. static CEventPropertiesFlexAnimationDialog g_EventPropertiesFlexAnimationDialog;
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. // Input : wnd -
  48. // *params -
  49. // Output : static
  50. //-----------------------------------------------------------------------------
  51. void CEventPropertiesFlexAnimationDialog::ShowControlsForEventType( CEventParams *params )
  52. {
  53. BaseClass::ShowControlsForEventType( params );
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. // Input : hwndDlg -
  58. // uMsg -
  59. // wParam -
  60. // lParam -
  61. // Output : static BOOL CALLBACK
  62. //-----------------------------------------------------------------------------
  63. static BOOL CALLBACK EventPropertiesFlexAnimationDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  64. {
  65. return g_EventPropertiesFlexAnimationDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
  66. };
  67. BOOL CEventPropertiesFlexAnimationDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  68. {
  69. m_hDialog = hwndDlg;
  70. bool handled = false;
  71. BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
  72. if ( handled )
  73. return bret;
  74. switch(uMsg)
  75. {
  76. case WM_PAINT:
  77. {
  78. PAINTSTRUCT ps;
  79. HDC hdc;
  80. hdc = BeginPaint(hwndDlg, &ps);
  81. DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
  82. EndPaint(hwndDlg, &ps);
  83. return FALSE;
  84. }
  85. break;
  86. case WM_VSCROLL:
  87. {
  88. RECT rcOut;
  89. GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
  90. InvalidateRect( hwndDlg, &rcOut, TRUE );
  91. UpdateWindow( hwndDlg );
  92. return FALSE;
  93. }
  94. break;
  95. case WM_INITDIALOG:
  96. {
  97. InitDialog( hwndDlg );
  98. }
  99. return FALSE;
  100. case WM_COMMAND:
  101. switch (LOWORD(wParam))
  102. {
  103. case IDOK:
  104. {
  105. GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
  106. if ( !g_Params.m_szName[ 0 ] )
  107. {
  108. Q_strncpy( g_Params.m_szName, "Facial Animation", sizeof( g_Params.m_szName ) );
  109. }
  110. char szTime[ 32 ];
  111. GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
  112. g_Params.m_flStartTime = atof( szTime );
  113. GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
  114. g_Params.m_flEndTime = atof( szTime );
  115. // Parse tokens from tags
  116. ParseTags( &g_Params );
  117. EndDialog( hwndDlg, 1 );
  118. }
  119. break;
  120. case IDCANCEL:
  121. EndDialog( hwndDlg, 0 );
  122. break;
  123. case IDC_CHECK_ENDTIME:
  124. {
  125. g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  126. if ( !g_Params.m_bHasEndTime )
  127. {
  128. ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
  129. }
  130. else
  131. {
  132. ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
  133. }
  134. }
  135. break;
  136. case IDC_CHECK_RESUMECONDITION:
  137. {
  138. g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  139. }
  140. break;
  141. case IDC_ABSOLUTESTART:
  142. {
  143. g_Params.m_bUsesTag = false;
  144. UpdateTagRadioButtons( &g_Params );
  145. }
  146. break;
  147. case IDC_RELATIVESTART:
  148. {
  149. g_Params.m_bUsesTag = true;
  150. UpdateTagRadioButtons( &g_Params );
  151. }
  152. break;
  153. }
  154. return TRUE;
  155. }
  156. return FALSE;
  157. }
  158. //-----------------------------------------------------------------------------
  159. // Purpose:
  160. // Input : *view -
  161. // *actor -
  162. // Output : int
  163. //-----------------------------------------------------------------------------
  164. int EventProperties_FlexAnimation( CEventParams *params )
  165. {
  166. g_Params = *params;
  167. int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
  168. MAKEINTRESOURCE( IDD_EVENTPROPERTIES_FLEXANIMATION ),
  169. (HWND)g_MDLViewer->getHandle(),
  170. (DLGPROC)EventPropertiesFlexAnimationDialogProc );
  171. *params = g_Params;
  172. return retval;
  173. }