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.

233 lines
6.0 KiB

  1. //========= Copyright 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 CEventPropertiesFaceDialog : 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 CEventPropertiesFaceDialog::SetTitle()
  25. {
  26. SetDialogTitle( &g_Params, "Face", "Face Actor" );
  27. }
  28. void CEventPropertiesFaceDialog::InitControlData( CEventParams *params )
  29. {
  30. BaseClass::InitControlData( params );
  31. HWND choices1 = GetControl( IDC_EVENTCHOICES );
  32. SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
  33. SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
  34. PopulateNamedActorList( choices1, params );
  35. SendMessage( GetControl( IDC_CHECK_LOCKBODYFACING ), BM_SETCHECK,
  36. ( WPARAM ) params->m_bLockBodyFacing ? BST_CHECKED : BST_UNCHECKED,
  37. ( LPARAM )0 );
  38. }
  39. void CEventPropertiesFaceDialog::InitDialog( HWND hwndDlg )
  40. {
  41. m_hDialog = hwndDlg;
  42. g_Params.PositionSelf( m_hDialog );
  43. // Set working title for dialog, etc.
  44. SetTitle();
  45. // Show/Hide dialog controls
  46. ShowControlsForEventType( &g_Params );
  47. InitControlData( &g_Params );
  48. UpdateTagRadioButtons( &g_Params );
  49. SetFocus( GetControl( IDC_EVENTNAME ) );
  50. }
  51. static CEventPropertiesFaceDialog g_EventPropertiesFaceDialog;
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. // Input : wnd -
  55. // *params -
  56. // Output : static
  57. //-----------------------------------------------------------------------------
  58. void CEventPropertiesFaceDialog::ShowControlsForEventType( CEventParams *params )
  59. {
  60. BaseClass::ShowControlsForEventType( params );
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. // Input : hwndDlg -
  65. // uMsg -
  66. // wParam -
  67. // lParam -
  68. // Output : static BOOL CALLBACK
  69. //-----------------------------------------------------------------------------
  70. static BOOL CALLBACK EventPropertiesFaceDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  71. {
  72. return g_EventPropertiesFaceDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
  73. };
  74. BOOL CEventPropertiesFaceDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  75. {
  76. m_hDialog = hwndDlg;
  77. bool handled = false;
  78. BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
  79. if ( handled )
  80. return bret;
  81. switch(uMsg)
  82. {
  83. case WM_PAINT:
  84. {
  85. PAINTSTRUCT ps;
  86. HDC hdc;
  87. hdc = BeginPaint(hwndDlg, &ps);
  88. DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
  89. EndPaint(hwndDlg, &ps);
  90. return FALSE;
  91. }
  92. break;
  93. case WM_VSCROLL:
  94. {
  95. RECT rcOut;
  96. GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
  97. InvalidateRect( hwndDlg, &rcOut, TRUE );
  98. UpdateWindow( hwndDlg );
  99. return FALSE;
  100. }
  101. break;
  102. case WM_INITDIALOG:
  103. {
  104. InitDialog( hwndDlg );
  105. }
  106. return FALSE;
  107. case WM_COMMAND:
  108. switch (LOWORD(wParam))
  109. {
  110. case IDOK:
  111. {
  112. HWND control = GetControl( IDC_EVENTCHOICES );
  113. if ( control )
  114. {
  115. SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
  116. }
  117. GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
  118. if ( !g_Params.m_szName[ 0 ] )
  119. {
  120. Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Face %s", g_Params.m_szParameters );
  121. }
  122. char szTime[ 32 ];
  123. GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
  124. g_Params.m_flStartTime = atof( szTime );
  125. GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
  126. g_Params.m_flEndTime = atof( szTime );
  127. // Parse tokens from tags
  128. ParseTags( &g_Params );
  129. EndDialog( hwndDlg, 1 );
  130. }
  131. break;
  132. case IDCANCEL:
  133. EndDialog( hwndDlg, 0 );
  134. break;
  135. case IDC_CHECK_ENDTIME:
  136. {
  137. g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  138. if ( !g_Params.m_bHasEndTime )
  139. {
  140. ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
  141. }
  142. else
  143. {
  144. ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
  145. }
  146. }
  147. break;
  148. case IDC_CHECK_RESUMECONDITION:
  149. {
  150. g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  151. }
  152. break;
  153. case IDC_CHECK_LOCKBODYFACING:
  154. {
  155. g_Params.m_bLockBodyFacing = SendMessage( GetControl( IDC_CHECK_LOCKBODYFACING ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  156. }
  157. break;
  158. case IDC_EVENTCHOICES:
  159. {
  160. HWND control = (HWND)lParam;
  161. if ( control )
  162. {
  163. SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
  164. }
  165. }
  166. break;
  167. case IDC_ABSOLUTESTART:
  168. {
  169. g_Params.m_bUsesTag = false;
  170. UpdateTagRadioButtons( &g_Params );
  171. }
  172. break;
  173. case IDC_RELATIVESTART:
  174. {
  175. g_Params.m_bUsesTag = true;
  176. UpdateTagRadioButtons( &g_Params );
  177. }
  178. break;
  179. }
  180. return TRUE;
  181. }
  182. return FALSE;
  183. }
  184. //-----------------------------------------------------------------------------
  185. // Purpose:
  186. // Input : *view -
  187. // *actor -
  188. // Output : int
  189. //-----------------------------------------------------------------------------
  190. int EventProperties_Face( CEventParams *params )
  191. {
  192. g_Params = *params;
  193. int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
  194. MAKEINTRESOURCE( IDD_EVENTPROPERTIES_FACE ),
  195. (HWND)g_MDLViewer->getHandle(),
  196. (DLGPROC)EventPropertiesFaceDialogProc );
  197. *params = g_Params;
  198. return retval;
  199. }