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.

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