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.

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