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.

290 lines
8.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 "choreoevent.h"
  14. static CEventParams g_Params;
  15. class CEventPropertiesCameraDialog : public CBaseEventPropertiesDialog
  16. {
  17. typedef CBaseEventPropertiesDialog BaseClass;
  18. public:
  19. virtual void InitDialog( HWND hwndDlg );
  20. virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  21. virtual void SetTitle();
  22. virtual void ShowControlsForEventType( CEventParams *params );
  23. virtual void InitControlData( CEventParams *params );
  24. private:
  25. void PopulateCamera( HWND control, CEventParams *params );
  26. };
  27. void CEventPropertiesCameraDialog::SetTitle()
  28. {
  29. SetDialogTitle( &g_Params, "Camera", "Camera AI Event (text)" );
  30. }
  31. void CEventPropertiesCameraDialog::InitControlData( CEventParams *params )
  32. {
  33. BaseClass::InitControlData( params );
  34. HWND choices1 = GetControl( IDC_EVENTCHOICES );
  35. SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
  36. SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
  37. HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
  38. SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
  39. SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
  40. HWND choices3 = GetControl( IDC_EVENTCHOICES3 );
  41. SendMessage( choices3, CB_RESETCONTENT, 0, 0 );
  42. SendMessage( choices3, WM_SETTEXT , 0, (LPARAM)params->m_szParameters3 );
  43. SendMessage( GetControl( IDC_FILENAME ), WM_SETTEXT, sizeof( params->m_szParameters ), (LPARAM)params->m_szParameters );
  44. PopulateCamera( choices1, params );
  45. PopulateNamedActorList( choices2, params );
  46. PopulateNamedActorList( choices3, params );
  47. }
  48. void CEventPropertiesCameraDialog::InitDialog( HWND hwndDlg )
  49. {
  50. m_hDialog = hwndDlg;
  51. g_Params.PositionSelf( m_hDialog );
  52. // Set working title for dialog, etc.
  53. SetTitle();
  54. // Show/Hide dialog controls
  55. ShowControlsForEventType( &g_Params );
  56. InitControlData( &g_Params );
  57. UpdateTagRadioButtons( &g_Params );
  58. SetFocus( GetControl( IDC_EVENTNAME ) );
  59. }
  60. static CEventPropertiesCameraDialog g_EventPropertiesCameraDialog;
  61. void CEventPropertiesCameraDialog::PopulateCamera( HWND control, CEventParams *params )
  62. {
  63. // FIXME: this should load from a config file
  64. /*
  65. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_BLINK" );
  66. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_HOLSTER" );
  67. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_UNHOLSTER" );
  68. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_AIM" );
  69. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMLOOK" );
  70. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMFACEFLEX" );
  71. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMHEADFLEX" );
  72. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_IGNORECOLLISION" );
  73. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_DISABLEAI" );
  74. SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
  75. */
  76. }
  77. //-----------------------------------------------------------------------------
  78. // Purpose:
  79. // Input : wnd -
  80. // *params -
  81. // Output : static
  82. //-----------------------------------------------------------------------------
  83. void CEventPropertiesCameraDialog::ShowControlsForEventType( CEventParams *params )
  84. {
  85. BaseClass::ShowControlsForEventType( params );
  86. }
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. // Input : hwndDlg -
  90. // uMsg -
  91. // wParam -
  92. // lParam -
  93. // Output : static BOOL CALLBACK
  94. //-----------------------------------------------------------------------------
  95. static BOOL CALLBACK EventPropertiesCameraDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  96. {
  97. return g_EventPropertiesCameraDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
  98. };
  99. BOOL CEventPropertiesCameraDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  100. {
  101. m_hDialog = hwndDlg;
  102. bool handled = false;
  103. BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
  104. if ( handled )
  105. return bret;
  106. switch(uMsg)
  107. {
  108. case WM_PAINT:
  109. {
  110. PAINTSTRUCT ps;
  111. HDC hdc;
  112. hdc = BeginPaint(hwndDlg, &ps);
  113. DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
  114. EndPaint(hwndDlg, &ps);
  115. return FALSE;
  116. }
  117. break;
  118. case WM_VSCROLL:
  119. {
  120. RECT rcOut;
  121. GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
  122. InvalidateRect( hwndDlg, &rcOut, TRUE );
  123. UpdateWindow( hwndDlg );
  124. return FALSE;
  125. }
  126. break;
  127. case WM_INITDIALOG:
  128. {
  129. InitDialog( hwndDlg );
  130. }
  131. return FALSE;
  132. case WM_COMMAND:
  133. switch (LOWORD(wParam))
  134. {
  135. case IDOK:
  136. {
  137. HWND control = GetControl( IDC_EVENTCHOICES );
  138. if ( control )
  139. {
  140. SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
  141. }
  142. GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
  143. if ( !g_Params.m_szName[ 0 ] )
  144. {
  145. Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "%s", g_Params.m_szParameters );
  146. if ( g_Params.m_szParameters2[ 0 ] )
  147. {
  148. char szAdd[ 512 ];
  149. Q_snprintf( szAdd, sizeof( szAdd ), " to %s", g_Params.m_szParameters2 );
  150. Q_strncat( g_Params.m_szName, szAdd, sizeof( g_Params.m_szName ), COPY_ALL_CHARACTERS );
  151. }
  152. }
  153. char szTime[ 32 ];
  154. GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
  155. g_Params.m_flStartTime = atof( szTime );
  156. GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
  157. g_Params.m_flEndTime = atof( szTime );
  158. // Parse tokens from tags
  159. ParseTags( &g_Params );
  160. EndDialog( hwndDlg, 1 );
  161. }
  162. break;
  163. case IDCANCEL:
  164. EndDialog( hwndDlg, 0 );
  165. break;
  166. case IDC_CHECK_ENDTIME:
  167. {
  168. g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  169. if ( !g_Params.m_bHasEndTime )
  170. {
  171. ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
  172. }
  173. else
  174. {
  175. ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
  176. }
  177. }
  178. break;
  179. case IDC_CHECK_RESUMECONDITION:
  180. {
  181. g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
  182. }
  183. break;
  184. case IDC_EVENTCHOICES:
  185. {
  186. HWND control = (HWND)lParam;
  187. if ( control )
  188. {
  189. SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
  190. }
  191. }
  192. break;
  193. case IDC_EVENTCHOICES2:
  194. {
  195. HWND control = (HWND)lParam;
  196. if ( control )
  197. {
  198. char buf1[ 256 ];
  199. SendMessage( GetControl( IDC_EVENTCHOICES2 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
  200. Q_snprintf( g_Params.m_szParameters2, sizeof( g_Params.m_szParameters2 ), "%s", buf1 );
  201. }
  202. }
  203. break;
  204. case IDC_EVENTCHOICES3:
  205. {
  206. HWND control = (HWND)lParam;
  207. if ( control )
  208. {
  209. char buf1[ 256 ];
  210. SendMessage( GetControl( IDC_EVENTCHOICES3 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
  211. Q_snprintf( g_Params.m_szParameters3, sizeof( g_Params.m_szParameters3 ), "%s", buf1 );
  212. }
  213. }
  214. break;
  215. case IDC_ABSOLUTESTART:
  216. {
  217. g_Params.m_bUsesTag = false;
  218. UpdateTagRadioButtons( &g_Params );
  219. }
  220. break;
  221. case IDC_RELATIVESTART:
  222. {
  223. g_Params.m_bUsesTag = true;
  224. UpdateTagRadioButtons( &g_Params );
  225. }
  226. break;
  227. }
  228. return TRUE;
  229. }
  230. return FALSE;
  231. }
  232. //-----------------------------------------------------------------------------
  233. // Purpose:
  234. // Input : *view -
  235. // *actor -
  236. // Output : int
  237. //-----------------------------------------------------------------------------
  238. int EventProperties_Camera( CEventParams *params )
  239. {
  240. g_Params = *params;
  241. int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
  242. MAKEINTRESOURCE( IDD_EVENTPROPERTIES_CAMERA ),
  243. (HWND)g_MDLViewer->getHandle(),
  244. (DLGPROC)EventPropertiesCameraDialogProc );
  245. *params = g_Params;
  246. return retval;
  247. }