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.

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