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.

1268 lines
35 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "dme_controls/BaseAnimSetPresetFaderPanel.h"
  7. #include "dme_controls/DmePresetGroupEditorPanel.h"
  8. #include "vgui_controls/InputDialog.h"
  9. #include "vgui_controls/Button.h"
  10. #include "vgui_controls/CheckButton.h"
  11. #include "vgui_controls/ComboBox.h"
  12. #include "vgui_controls/TextImage.h"
  13. #include "vgui_controls/TextEntry.h"
  14. #include "vgui_controls/MessageBox.h"
  15. #include "vgui_controls/Menu.h"
  16. #include "vgui_controls/PanelListPanel.h"
  17. #include "movieobjects/dmeanimationset.h"
  18. #include "tier1/KeyValues.h"
  19. #include "dme_controls/dmecontrols_utils.h"
  20. #include "vstdlib/random.h"
  21. #include "vgui/IVgui.h"
  22. #include "vgui/IInput.h"
  23. #include "vgui/ISurface.h"
  24. #include "dme_controls/BaseAnimSetAttributeSliderPanel.h"
  25. #include "dme_controls/BaseAnimationSetEditor.h"
  26. #include "movieobjects/dmetransform.h"
  27. #include "vstdlib/jobthread.h"
  28. #include "tier1/utlsymbollarge.h"
  29. // memdbgon must be the last include file in a .cpp file!!!
  30. #include "tier0/memdbgon.h"
  31. using namespace vgui;
  32. class CPresetSlider;
  33. const int PRESET_SLIDER_INIT = 400;
  34. //-----------------------------------------------------------------------------
  35. // preset and preset group name collection utilities
  36. //-----------------------------------------------------------------------------
  37. CDmePresetGroup *FindAnyPresetGroup( CDmeFilmClip *pFilmClip, const char *pPresetGroupName )
  38. {
  39. CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
  40. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  41. {
  42. CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( pPresetGroupName );
  43. if ( pPresetGroup )
  44. return pPresetGroup;
  45. }
  46. return NULL;
  47. }
  48. CDmePreset *FindAnyPreset( CDmeFilmClip *pFilmClip, const char *pPresetGroupName, const char *pPresetName )
  49. {
  50. CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
  51. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  52. {
  53. CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( pPresetGroupName );
  54. if ( !pPresetGroup )
  55. continue;
  56. CDmePreset *pPreset = pPresetGroup->FindPreset( pPresetName );
  57. if ( pPreset )
  58. return pPreset;
  59. }
  60. return NULL;
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose: Utility dialog, used to let user type in some text
  64. //-----------------------------------------------------------------------------
  65. class CAddPresetDialog : public vgui::BaseInputDialog
  66. {
  67. DECLARE_CLASS_SIMPLE( CAddPresetDialog, vgui::BaseInputDialog );
  68. public:
  69. CAddPresetDialog( vgui::Panel *parent );
  70. void DoModal( CDmeFilmClip *pFilmClip, const char *pCurrentGroupName, KeyValues *pContextKeyValues = NULL );
  71. protected:
  72. // command buttons
  73. virtual void OnCommand(const char *command);
  74. virtual void OnTick();
  75. private:
  76. vgui::TextEntry *m_pPresetName;
  77. vgui::ComboBox *m_pPresetGroup;
  78. vgui::CheckButton *m_pAnimated;
  79. };
  80. //-----------------------------------------------------------------------------
  81. // Constructor
  82. //-----------------------------------------------------------------------------
  83. CAddPresetDialog::CAddPresetDialog( vgui::Panel *parent ) : BaseClass( parent, "Enter Preset Name" )
  84. {
  85. m_pPresetName = new TextEntry( this, "PresetName" );
  86. m_pPresetGroup = new vgui::ComboBox( this, "PresetGroup", 8, true );
  87. m_pAnimated = new vgui::CheckButton( this, "Animated", "Animated" );
  88. SetDeleteSelfOnClose( false );
  89. vgui::ivgui()->AddTickSignal( GetVPanel(), 0 );
  90. LoadControlSettings( "resource/addpresetdialog.res" );
  91. }
  92. void CAddPresetDialog::DoModal( CDmeFilmClip *pFilmClip, const char *pCurrentGroupName, KeyValues *pContextKeyValues )
  93. {
  94. m_pPresetGroup->DeleteAllItems();
  95. CUtlVector< PresetGroupInfo_t > presetGroupInfo;
  96. CollectPresetGroupInfo( pFilmClip, presetGroupInfo, true );
  97. int nPresetGroups = presetGroupInfo.Count();
  98. for ( int i = 0; i < nPresetGroups; ++i )
  99. {
  100. const char *pPresetGroupName = presetGroupInfo[ i ].presetGroupSym.String();
  101. KeyValues *kv = new KeyValues( "entry" );
  102. kv->SetString( "presetGroupName", pPresetGroupName );
  103. int nItemID = m_pPresetGroup->AddItem( pPresetGroupName, kv );
  104. if ( pCurrentGroupName && !Q_stricmp( pPresetGroupName, pCurrentGroupName ) )
  105. {
  106. m_pPresetGroup->ActivateItem( nItemID );
  107. }
  108. }
  109. BaseClass::DoModal( pContextKeyValues );
  110. m_pPresetName->SetText( "" );
  111. m_pPresetName->RequestFocus();
  112. PlaceUnderCursor( );
  113. }
  114. //-----------------------------------------------------------------------------
  115. // command handler
  116. //-----------------------------------------------------------------------------
  117. void CAddPresetDialog::OnCommand( const char *command )
  118. {
  119. if ( !Q_stricmp( command, "OK" ) )
  120. {
  121. int nTextLength = m_pPresetName->GetTextLength() + 1;
  122. char* txt = (char*)_alloca( nTextLength * sizeof(char) );
  123. m_pPresetName->GetText( txt, nTextLength );
  124. nTextLength = m_pPresetGroup->GetTextLength() + 1;
  125. char* pPresetGroupName = (char*)_alloca( nTextLength * sizeof(char) );
  126. m_pPresetGroup->GetText( pPresetGroupName, nTextLength );
  127. bool bAnimated = m_pAnimated->IsSelected();
  128. KeyValues *kv = new KeyValues( "PresetNameSelected", "text", txt );
  129. kv->SetString( "presetGroupName", pPresetGroupName );
  130. kv->SetBool( "animated", bAnimated );
  131. if ( m_pContextKeyValues )
  132. {
  133. kv->AddSubKey( m_pContextKeyValues );
  134. m_pContextKeyValues = NULL;
  135. }
  136. PostActionSignal( kv );
  137. CloseModal();
  138. return;
  139. }
  140. if ( !Q_stricmp( command, "Cancel") )
  141. {
  142. CloseModal();
  143. return;
  144. }
  145. BaseClass::OnCommand( command );
  146. }
  147. void CAddPresetDialog::OnTick()
  148. {
  149. bool bEnableOkayButton = m_pPresetName->GetTextLength() > 0 && m_pPresetGroup->GetTextLength() > 0;
  150. m_pOKButton->SetEnabled( bEnableOkayButton );
  151. BaseClass::OnTick();
  152. }
  153. //-----------------------------------------------------------------------------
  154. //
  155. // CPresetSlider: The actual preset slider itself!
  156. //
  157. //-----------------------------------------------------------------------------
  158. //-----------------------------------------------------------------------------
  159. // Static members
  160. //-----------------------------------------------------------------------------
  161. bool CPresetSlider::s_bResetMousePosOnMouseUp = false;
  162. int CPresetSlider::s_nMousePosX;
  163. int CPresetSlider::s_nMousePosY;
  164. //-----------------------------------------------------------------------------
  165. // Constructor, destructor
  166. //-----------------------------------------------------------------------------
  167. CPresetSlider::CPresetSlider( Panel *parent, CBaseAnimSetPresetFaderPanel *pFaderPanel ) :
  168. BaseClass( (Panel *)parent, "preset" ),
  169. m_pPresetFaderPanel( pFaderPanel ),
  170. m_AttributeLookup( DefLessFunc( DmElementHandle_t ) ),
  171. m_bIgnoreCursorMovedEvents( false ),
  172. m_presetGroupName( UTL_INVAL_SYMBOL_LARGE ),
  173. m_presetName( UTL_INVAL_SYMBOL_LARGE ),
  174. m_nProceduralType( PROCEDURAL_PRESET_NOT ),
  175. m_bReadOnly( false )
  176. {
  177. SetRange( 0, 1000 );
  178. SetDragOnRepositionNob( true );
  179. SetPaintBackgroundEnabled( true );
  180. m_pName = new TextImage( "" );
  181. m_ZeroColor = Color( 69, 69, 69, 255 );
  182. m_GradientColor = Color( 194, 120, 0, 255 );
  183. m_TextColor = Color( 200, 200, 200, 255 );
  184. m_TextColorFocus = Color( 208, 143, 40, 255 );
  185. }
  186. CPresetSlider::~CPresetSlider()
  187. {
  188. delete m_pName;
  189. }
  190. void CPresetSlider::Clear()
  191. {
  192. m_nProceduralType = PROCEDURAL_PRESET_NOT;
  193. m_bReadOnly = false;
  194. m_presetGroupName = m_presetName = UTL_INVAL_SYMBOL_LARGE;
  195. m_AttributeLookup.RemoveAll();
  196. }
  197. void CPresetSlider::Init( const char *pPresetGroupName, const char *pPresetName )
  198. {
  199. m_nProceduralType = PROCEDURAL_PRESET_NOT;
  200. m_bReadOnly = false;
  201. m_presetGroupName = g_pDataModel->GetSymbol( pPresetGroupName );
  202. m_presetName = g_pDataModel->GetSymbol( pPresetName );
  203. static const CUtlSymbolLarge proceduralPresetGroupNameSym = g_pDataModel->GetSymbol( PROCEDURAL_PRESET_GROUP_NAME );
  204. if ( m_presetGroupName == proceduralPresetGroupNameSym )
  205. {
  206. m_nProceduralType = ProceduralTypeForPresetName( pPresetName );
  207. m_bReadOnly = true;
  208. }
  209. else
  210. {
  211. // HACK - we're assuming here that presets of a given name share their type and readonly values across all animationsets
  212. bool bFound = false;
  213. CAnimSetGroupAnimSetTraversal traversal( m_pPresetFaderPanel->GetController()->GetAnimationSetClip() );
  214. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  215. {
  216. CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( pPresetGroupName );
  217. if ( !pPresetGroup )
  218. continue;
  219. CDmePreset *pPreset = pPresetGroup->FindPreset( pPresetName );
  220. if ( !pPreset )
  221. continue;
  222. m_bReadOnly = pPreset->IsReadOnly();
  223. bFound = true;
  224. break;
  225. }
  226. Assert( bFound );
  227. }
  228. SetName( pPresetName );
  229. m_pName->SetText( pPresetName );
  230. m_pName->ResizeImageToContent();
  231. SetBgColor( Color( 128, 128, 128, 128 ) );
  232. }
  233. const char *CPresetSlider::GetPresetName()
  234. {
  235. return m_presetName.String();
  236. }
  237. const char *CPresetSlider::GetPresetGroupName()
  238. {
  239. return m_presetGroupName.String();
  240. }
  241. //-----------------------------------------------------------------------------
  242. // Reads the sliders, sets control values into the attribute dictionary
  243. //-----------------------------------------------------------------------------
  244. void CPresetSlider::SetControlValues()
  245. {
  246. m_AttributeLookup.RemoveAll();
  247. if ( GetProceduralPresetType() != PROCEDURAL_PRESET_NOT )
  248. return; // this will be taken care of in the application
  249. CAnimSetGroupAnimSetTraversal traversal( m_pPresetFaderPanel->GetController()->GetAnimationSetClip() );
  250. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  251. {
  252. CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( GetPresetGroupName() );
  253. if ( !pPresetGroup )
  254. continue;
  255. CDmePreset *pPreset = pPresetGroup->FindPreset( GetPresetName() );
  256. if ( !pPreset )
  257. continue;
  258. CDmrElementArray< CDmElement > values = pPreset->GetControlValues();
  259. int nControlValueCount = values.Count();
  260. m_AttributeLookup.EnsureCapacity( m_AttributeLookup.Count() + nControlValueCount );
  261. for ( int i = 0; i < nControlValueCount; ++i )
  262. {
  263. CDmElement *v = values[ i ];
  264. if ( !v )
  265. continue;
  266. CDmElement *pControl = pAnimSet->FindControl( v->GetName() );
  267. if ( !pControl )
  268. continue;
  269. DmElementHandle_t handle = pControl->GetHandle();
  270. int idx = m_AttributeLookup.Find( handle );
  271. if ( idx == m_AttributeLookup.InvalidIndex() )
  272. {
  273. idx = m_AttributeLookup.Insert( handle );
  274. }
  275. AnimationControlAttributes_t &val = m_AttributeLookup[ idx ];
  276. // Zero everything out
  277. val.Clear();
  278. CDmAttribute *pValueAttribute = v->GetAttribute( "value" );
  279. if ( pValueAttribute )
  280. {
  281. val.m_pValueAttribute[ANIM_CONTROL_VALUE] = pValueAttribute;
  282. val.m_pValue [ANIM_CONTROL_VALUE] = pValueAttribute->GetValue< float >();
  283. }
  284. else
  285. {
  286. val.m_pValueAttribute[ANIM_CONTROL_VALUE] = v->GetAttribute( AS_VALUES_ATTR );
  287. val.m_pTimesAttribute[ANIM_CONTROL_VALUE] = v->GetAttribute( AS_TIMES_ATTR );
  288. }
  289. CDmAttribute *pLeftValueAttribute = v->GetAttribute( "leftValue" );
  290. if ( pLeftValueAttribute )
  291. {
  292. val.m_pValueAttribute[ANIM_CONTROL_VALUE_LEFT] = pLeftValueAttribute;
  293. val.m_pValue [ANIM_CONTROL_VALUE_LEFT] = pLeftValueAttribute->GetValue< float >();
  294. }
  295. else
  296. {
  297. val.m_pValueAttribute[ANIM_CONTROL_VALUE_LEFT] = v->GetAttribute( AS_VALUES_LEFT_ATTR );
  298. val.m_pTimesAttribute[ANIM_CONTROL_VALUE_LEFT] = v->GetAttribute( AS_TIMES_LEFT_ATTR );
  299. }
  300. CDmAttribute *pRightValueAttribute = v->GetAttribute( "rightValue" );
  301. if ( pRightValueAttribute )
  302. {
  303. val.m_pValueAttribute[ANIM_CONTROL_VALUE_RIGHT] = pRightValueAttribute;
  304. val.m_pValue [ANIM_CONTROL_VALUE_RIGHT] = pRightValueAttribute->GetValue< float >();
  305. }
  306. else
  307. {
  308. val.m_pValueAttribute[ANIM_CONTROL_VALUE_RIGHT] = v->GetAttribute( AS_VALUES_RIGHT_ATTR );
  309. val.m_pTimesAttribute[ANIM_CONTROL_VALUE_RIGHT] = v->GetAttribute( AS_TIMES_RIGHT_ATTR );
  310. }
  311. CDmAttribute *pPositionAttribute = v->GetAttribute( "valuePosition" );
  312. if ( pPositionAttribute )
  313. {
  314. val.m_pValueAttribute[ANIM_CONTROL_TXFORM_POSITION] = pPositionAttribute;
  315. val.m_Vector = pPositionAttribute->GetValue< Vector >();
  316. }
  317. else
  318. {
  319. val.m_pValueAttribute[ANIM_CONTROL_TXFORM_POSITION] = v->GetAttribute( AS_VALUES_POSITION_ATTR );
  320. val.m_pTimesAttribute[ANIM_CONTROL_TXFORM_POSITION] = v->GetAttribute( AS_TIMES_POSITION_ATTR );
  321. }
  322. CDmAttribute *pQuaternionAttribute = v->GetAttribute( "valueOrientation" );
  323. if ( pQuaternionAttribute )
  324. {
  325. val.m_pValueAttribute[ANIM_CONTROL_TXFORM_ORIENTATION] = pQuaternionAttribute;
  326. val.m_Quaternion = pQuaternionAttribute->GetValue< Quaternion >();
  327. }
  328. else
  329. {
  330. val.m_pValueAttribute[ANIM_CONTROL_TXFORM_ORIENTATION] = v->GetAttribute( AS_VALUES_ORIENTATION_ATTR );
  331. val.m_pTimesAttribute[ANIM_CONTROL_TXFORM_ORIENTATION] = v->GetAttribute( AS_TIMES_ORIENTATION_ATTR );
  332. }
  333. }
  334. }
  335. }
  336. AttributeDict_t *CPresetSlider::GetAttributeDict()
  337. {
  338. return &m_AttributeLookup;
  339. }
  340. void CPresetSlider::OnMousePressed(MouseCode code)
  341. {
  342. m_bIgnoreCursorMovedEvents = false; // reset this just in case it was left on
  343. m_pPresetFaderPanel->SetActivePresetSlider( this );
  344. if ( code != MOUSE_LEFT )
  345. return;
  346. if ( _dragging )
  347. {
  348. OnMouseReleased( MOUSE_LEFT );
  349. return;
  350. }
  351. BaseClass::OnMousePressed( code );
  352. if ( !_dragging )
  353. return;
  354. SetCursor( dc_blank );
  355. int mx, my;
  356. input()->GetCursorPos( mx, my );
  357. int tx, ty, tw, th;
  358. GetTrackRect( tx, ty, tw, th );
  359. LocalToScreen( tx, ty );
  360. if ( mx < tx + tw )
  361. {
  362. if ( mx >= tx )
  363. {
  364. Assert( !s_bResetMousePosOnMouseUp );
  365. s_bResetMousePosOnMouseUp = true;
  366. s_nMousePosX = mx;
  367. s_nMousePosY = my;
  368. input()->SetCursorPos( tx, my );
  369. }
  370. SetPos( 0 );
  371. }
  372. }
  373. void CPresetSlider::OnMouseReleased(MouseCode code)
  374. {
  375. m_bIgnoreCursorMovedEvents = false; // reset this just in case it was left on
  376. if ( code == MOUSE_RIGHT )
  377. {
  378. OnShowContextMenu();
  379. return;
  380. }
  381. if ( code != MOUSE_LEFT )
  382. return;
  383. float flLastValue = GetCurrent();
  384. bool bWasDragging = _dragging;
  385. BaseClass::OnMouseReleased( code );
  386. if ( bWasDragging )
  387. {
  388. m_pPresetFaderPanel->GetController()->ApplyPreset( flLastValue, m_AttributeLookup );
  389. SetCursor( dc_arrow );
  390. }
  391. if ( s_bResetMousePosOnMouseUp )
  392. {
  393. s_bResetMousePosOnMouseUp = false;
  394. input()->SetCursorPos( s_nMousePosX, s_nMousePosY );
  395. }
  396. }
  397. void CPresetSlider::OnCursorEntered()
  398. {
  399. if ( _dragging )
  400. return;
  401. m_pPresetFaderPanel->SetActivePresetSlider( this );
  402. }
  403. void CPresetSlider::OnCursorExited()
  404. {
  405. if ( _dragging )
  406. return;
  407. m_pPresetFaderPanel->SetActivePresetSlider( NULL );
  408. }
  409. void CPresetSlider::OnRename()
  410. {
  411. InputDialog *pDialog = new InputDialog( this, "Rename Preset", "Name:", GetName() );
  412. Assert( pDialog );
  413. if ( pDialog )
  414. {
  415. pDialog->SetSmallCaption( true );
  416. pDialog->SetMultiline( false );
  417. pDialog->DoModal( new KeyValues( "RenamePreset" ) );
  418. }
  419. }
  420. void CPresetSlider::OnRenameCompleted( const char *pText, KeyValues *pContextKeyValues )
  421. {
  422. if ( !pText || !*pText )
  423. {
  424. Warning( "Can't rename preset for %s to an empty name\n", GetName() );
  425. return;
  426. }
  427. // No change( case sensitive)
  428. if ( !Q_strcmp( GetName(), pText ) )
  429. return;
  430. CUndoScopeGuard guard( 0, NOTIFY_SETDIRTYFLAG, "Rename Preset" );
  431. SetName( pText );
  432. m_pName->SetText( pText );
  433. m_pName->ResizeImageToContent();
  434. m_presetName = g_pDataModel->GetSymbol( pText );
  435. CAnimSetGroupAnimSetTraversal traversal( m_pPresetFaderPanel->GetController()->GetAnimationSetClip() );
  436. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  437. {
  438. CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( GetPresetGroupName() );
  439. Assert( pPresetGroup );
  440. CDmePreset *pPreset = pPresetGroup->FindPreset( GetPresetName() );
  441. Assert( pPreset );
  442. pPreset->SetName( pText );
  443. }
  444. }
  445. void CPresetSlider::OnInputCompleted( KeyValues *pParams )
  446. {
  447. const char *pText = pParams->GetString( "text", NULL );
  448. KeyValues *pContextKeyValues = pParams->FindKey( "RenamePreset" );
  449. if ( pContextKeyValues )
  450. {
  451. OnRenameCompleted( pText, pContextKeyValues );
  452. return;
  453. }
  454. Assert( 0 );
  455. }
  456. void CPresetSlider::OnDelete()
  457. {
  458. char sz[ 256 ];
  459. Q_snprintf( sz, sizeof( sz ), "Delete '%s'?", GetName() );
  460. MessageBox *pConfirm = new MessageBox( "Delete Preset", sz, this );
  461. Assert( pConfirm );
  462. if ( pConfirm )
  463. {
  464. pConfirm->SetCancelButtonVisible( true );
  465. pConfirm->SetCancelButtonText( "#VGui_Cancel" );
  466. pConfirm->SetCommand( new KeyValues( "OnDeleteConfirmed" ) );
  467. pConfirm->AddActionSignalTarget( this );
  468. pConfirm->DoModal();
  469. }
  470. }
  471. void CPresetSlider::OnDeleteConfirmed()
  472. {
  473. m_pPresetFaderPanel->OnDeletePreset( GetPresetName() );
  474. }
  475. void CPresetSlider::OnShowContextMenu()
  476. {
  477. if ( m_hContextMenu.Get() )
  478. {
  479. delete m_hContextMenu.Get();
  480. m_hContextMenu = NULL;
  481. }
  482. m_hContextMenu = new Menu( this, "ActionMenu" );
  483. if ( !m_bReadOnly )
  484. {
  485. m_hContextMenu->AddMenuItem( "Rename...", new KeyValues( "OnRename" ), this );
  486. if ( Q_stricmp( GetName(), "Default" ) )
  487. {
  488. m_hContextMenu->AddMenuItem( "Delete...", new KeyValues( "OnDelete" ), this );
  489. }
  490. m_hContextMenu->AddSeparator();
  491. }
  492. int nItem = m_hContextMenu->AddMenuItem( "Add...", new KeyValues( "ShowAddPresetDialog" ), m_pPresetFaderPanel );
  493. if ( m_pPresetFaderPanel->GetController()->GetMostRecentlySelectedControl() == NULL )
  494. {
  495. m_hContextMenu->SetItemEnabled( nItem, false );
  496. }
  497. m_hContextMenu->AddMenuItem( "Manage...", new KeyValues( "ManagePresets" ), m_pPresetFaderPanel );
  498. Menu::PlaceContextMenu( this, m_hContextMenu.Get() );
  499. }
  500. void CPresetSlider::UpdateTickPos( int x, int y )
  501. {
  502. if ( m_bIgnoreCursorMovedEvents )
  503. return;
  504. int tx, ty, tw, th;
  505. GetTrackRect( tx, ty, tw, th );
  506. float previewValue = 0.0f;
  507. if ( x > tx )
  508. {
  509. if ( x >= ( tx + tw ) || tw <= 0 )
  510. {
  511. previewValue = 1.0f;
  512. }
  513. else
  514. {
  515. previewValue = (float)( x - tx ) / (float)tw;
  516. }
  517. }
  518. SetPos( previewValue );
  519. }
  520. void CPresetSlider::OnCursorMoved(int x, int y)
  521. {
  522. UpdateTickPos( x, y );
  523. }
  524. bool CPresetSlider::IsDragging()
  525. {
  526. return _dragging;
  527. }
  528. void CPresetSlider::IgnoreCursorMovedEvents( bool bIgnore )
  529. {
  530. m_bIgnoreCursorMovedEvents = bIgnore;
  531. }
  532. void CPresetSlider::Deactivate()
  533. {
  534. if ( m_pPresetFaderPanel->GetActivePresetSlider() == this )
  535. {
  536. m_pPresetFaderPanel->SetActivePresetSlider( NULL );
  537. }
  538. }
  539. float CPresetSlider::GetCurrent()
  540. {
  541. return GetValue() * 0.001f;
  542. }
  543. void CPresetSlider::SetPos( float frac )
  544. {
  545. SetValue( (int)( frac * 1000.0f + 0.5f ), false );
  546. }
  547. void CPresetSlider::ApplySchemeSettings( IScheme *scheme )
  548. {
  549. BaseClass::ApplySchemeSettings( scheme );
  550. m_pName->SetFont( scheme->GetFont( "DefaultBold" ) );
  551. m_pName->SetColor( m_TextColor );
  552. m_pName->ResizeImageToContent();
  553. SetFgColor( Color( 194, 120, 0, 255 ) );
  554. SetThumbWidth( 3 );
  555. }
  556. void CPresetSlider::GetTrackRect( int &x, int &y, int &w, int &h )
  557. {
  558. GetSize( w, h );
  559. x = 2;
  560. y = 2;
  561. w -= 4;
  562. h -= 4;
  563. }
  564. void CPresetSlider::Paint()
  565. {
  566. if ( m_pPresetFaderPanel->GetActivePresetSlider() != this )
  567. return;
  568. bool bIsShiftKeyDown = vgui::input()->IsKeyDown( KEY_LSHIFT ) || vgui::input()->IsKeyDown( KEY_RSHIFT );
  569. if ( !IsDragging() && !bIsShiftKeyDown )
  570. return;
  571. int mx, my;
  572. input()->GetCursorPos( mx, my );
  573. ScreenToLocal( mx, my );
  574. UpdateTickPos( mx, my );
  575. // horizontal nob
  576. int x, y;
  577. int wide,tall;
  578. GetTrackRect( x, y, wide, tall );
  579. Color col = GetFgColor();
  580. surface()->DrawSetColor( col );
  581. surface()->DrawFilledRect( _nobPos[0], 1, _nobPos[1], GetTall() - 1 );
  582. surface()->DrawSetColor( m_ZeroColor );
  583. surface()->DrawFilledRect( _nobPos[0] - 1, y + 1, _nobPos[0], y + tall - 1 );
  584. }
  585. void CPresetSlider::PaintBackground()
  586. {
  587. int w, h;
  588. GetSize( w, h );
  589. bool hasFocus = m_pPresetFaderPanel->GetActivePresetSlider() == this;
  590. bool bIsShiftKeyDown = vgui::input()->IsKeyDown( KEY_LSHIFT ) || vgui::input()->IsKeyDown( KEY_RSHIFT );
  591. bool bIsAltKeyDown = vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT );
  592. if ( hasFocus && ( IsDragging() || bIsShiftKeyDown ) )
  593. {
  594. int tx, ty, tw, th;
  595. GetTrackRect( tx, ty, tw, th );
  596. surface()->DrawSetColor( Color( 0, 0, 0, 255 ) );
  597. surface()->DrawOutlinedRect( tx, ty, tx + tw, ty + th );
  598. surface()->DrawSetColor( m_GradientColor );
  599. ++tx;
  600. ++ty;
  601. tw -= 2;
  602. th -= 2;
  603. // Gradient fill rectangle
  604. int fillw = (int)( (float)tw * GetCurrent() + 0.5f );
  605. int minAlpha = 15;
  606. float alphaTarget = 255.0f;
  607. int curAlpha = MAX( GetCurrent() * alphaTarget, minAlpha );
  608. if ( _dragging )
  609. {
  610. surface()->DrawFilledRectFade( tx, ty, tx + fillw, ty + th, minAlpha, curAlpha, true );
  611. surface()->DrawSetColor( m_ZeroColor );
  612. surface()->DrawFilledRect( tx + fillw + 1, ty, tx + tw, ty + th );
  613. }
  614. else
  615. {
  616. surface()->DrawSetColor( bIsAltKeyDown ? m_GradientColor : m_ZeroColor );
  617. surface()->DrawFilledRect( tx, ty, tx + tw, ty + th );
  618. }
  619. }
  620. int cw, ch;
  621. m_pName->SetColor( hasFocus ? m_TextColorFocus : m_TextColor );
  622. m_pName->GetContentSize( cw, ch );
  623. m_pName->SetPos( ( w - cw ) * 0.5f, ( h - ch ) * 0.5f );
  624. m_pName->Paint();
  625. }
  626. //-----------------------------------------------------------------------------
  627. // Manipulate in/out curve types
  628. //-----------------------------------------------------------------------------
  629. void CPresetSlider::OnCurve1()
  630. {
  631. m_pPresetFaderPanel->DispatchCurve( 1 );
  632. }
  633. void CPresetSlider::OnCurve2()
  634. {
  635. m_pPresetFaderPanel->DispatchCurve( 2 );
  636. }
  637. void CPresetSlider::OnCurve3()
  638. {
  639. m_pPresetFaderPanel->DispatchCurve( 3 );
  640. }
  641. void CPresetSlider::OnCurve4()
  642. {
  643. m_pPresetFaderPanel->DispatchCurve( 4 );
  644. }
  645. //-----------------------------------------------------------------------------
  646. // Slider list panel
  647. //-----------------------------------------------------------------------------
  648. class CSliderListPanel : public PanelListPanel
  649. {
  650. DECLARE_CLASS_SIMPLE( CSliderListPanel, vgui::PanelListPanel );
  651. public:
  652. CSliderListPanel( CBaseAnimSetPresetFaderPanel *parent, vgui::Panel *pParent, const char *panelName );
  653. virtual void OnMouseReleased( vgui::MouseCode code );
  654. virtual void OnMousePressed( vgui::MouseCode code );
  655. private:
  656. MESSAGE_FUNC( OnShowContextMenu, "OnShowContextMenu" );
  657. vgui::DHANDLE< vgui::Menu > m_hContextMenu;
  658. CBaseAnimSetPresetFaderPanel *m_pPresetFaderPanel;
  659. };
  660. //-----------------------------------------------------------------------------
  661. // Constructor
  662. //-----------------------------------------------------------------------------
  663. CSliderListPanel::CSliderListPanel( CBaseAnimSetPresetFaderPanel *pFader, vgui::Panel *pParent, const char *panelName ) :
  664. BaseClass( pParent, panelName )
  665. {
  666. m_pPresetFaderPanel = pFader;
  667. }
  668. //-----------------------------------------------------------------------------
  669. // Context menu!
  670. //-----------------------------------------------------------------------------
  671. void CSliderListPanel::OnMousePressed( MouseCode code )
  672. {
  673. if ( code == MOUSE_RIGHT )
  674. return;
  675. BaseClass::OnMousePressed( code );
  676. }
  677. void CSliderListPanel::OnMouseReleased( MouseCode code )
  678. {
  679. if ( code == MOUSE_RIGHT )
  680. {
  681. OnShowContextMenu();
  682. return;
  683. }
  684. BaseClass::OnMouseReleased( code );
  685. }
  686. //-----------------------------------------------------------------------------
  687. // Shows the slider context menu
  688. //-----------------------------------------------------------------------------
  689. void CSliderListPanel::OnShowContextMenu()
  690. {
  691. if ( m_hContextMenu.Get() )
  692. {
  693. delete m_hContextMenu.Get();
  694. m_hContextMenu = NULL;
  695. }
  696. m_hContextMenu = new Menu( this, "ActionMenu" );
  697. int nItem = m_hContextMenu->AddMenuItem( "Add...", new KeyValues( "ShowAddPresetDialog" ), m_pPresetFaderPanel );
  698. if ( m_pPresetFaderPanel->GetController()->GetMostRecentlySelectedControl() == NULL )
  699. {
  700. m_hContextMenu->SetItemEnabled( nItem, false );
  701. }
  702. m_hContextMenu->AddMenuItem( "Manage...", new KeyValues( "ManagePresets" ), m_pPresetFaderPanel );
  703. Menu::PlaceContextMenu( this, m_hContextMenu.Get() );
  704. }
  705. //-----------------------------------------------------------------------------
  706. // Constructor
  707. //-----------------------------------------------------------------------------
  708. CBaseAnimSetPresetFaderPanel::CBaseAnimSetPresetFaderPanel( vgui::Panel *parent, const char *className, CBaseAnimationSetEditor *editor ) :
  709. BaseClass( parent, className )
  710. {
  711. m_pController = editor->GetController();
  712. m_pSheet = new PropertySheet( this, "presetPropertySheet" );
  713. m_pSheet->SetAutoResize( Panel::PIN_TOPLEFT, Panel::AUTORESIZE_DOWNANDRIGHT, 0, 0, 0, 0 );
  714. m_pSheet->SetSmallTabs( true );
  715. m_pSliders = new CSliderListPanel( this, NULL, "PresetSliders" );
  716. m_pSliders->SetFirstColumnWidth( 0 );
  717. m_pSliders->SetAutoResize( Panel::PIN_TOPLEFT, Panel::AUTORESIZE_DOWNANDRIGHT, 0, 0, 0, 0 );
  718. m_pSliders->SetPos( 0, 0 );
  719. m_pSliders->SetVerticalBufferPixels( 0 );
  720. // Prepopulate it with a few
  721. m_presetSliders.EnsureCapacity( PRESET_SLIDER_INIT );
  722. for ( int i = 0; i < PRESET_SLIDER_INIT; ++i )
  723. {
  724. m_presetSliders.AddToTail( new CPresetSlider( NULL, this ) );
  725. }
  726. }
  727. void CBaseAnimSetPresetFaderPanel::AddPreset( const char *pPresetGroupName, const char *pPresetName, bool bAnimated )
  728. {
  729. if ( !pPresetName || !*pPresetName )
  730. {
  731. vgui::MessageBox *pError = new MessageBox( "Add Preset Error", "Can't add preset with an empty name\n", this );
  732. pError->SetDeleteSelfOnClose( true );
  733. pError->DoModal();
  734. return;
  735. }
  736. CDmeFilmClip *pFilmClip = m_pController->GetAnimationSetClip();
  737. if ( !pFilmClip )
  738. return;
  739. CAnimSetGroupAnimSetTraversal traversal( m_pController->GetAnimationSetClip() );
  740. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  741. {
  742. if ( CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( pPresetGroupName ) )
  743. {
  744. SelectionState_t selection = m_pController->GetSelectionState( pAnimSet );
  745. if ( selection == SEL_NONE || selection == SEL_EMPTY )
  746. continue; // we're not adding a preset to this animationset, so no checks necessary...
  747. if ( pPresetGroup->m_bIsReadOnly )
  748. {
  749. vgui::MessageBox *pError = new MessageBox( "Add Preset Error", "Can't add preset to a read-only preset group!\n", this );
  750. pError->SetDeleteSelfOnClose( true );
  751. pError->DoModal();
  752. return;
  753. }
  754. if ( pPresetGroup->FindPreset( pPresetName ) != NULL )
  755. {
  756. vgui::MessageBox *pError = new MessageBox( "Add Preset Error", "A preset with that name already exists!\n", this );
  757. pError->SetDeleteSelfOnClose( true );
  758. pError->DoModal();
  759. return;
  760. }
  761. }
  762. }
  763. m_pController->AddPreset( pPresetGroupName, pPresetName, bAnimated );
  764. }
  765. //-----------------------------------------------------------------------------
  766. // Called from the add preset name dialogs used by this class
  767. //-----------------------------------------------------------------------------
  768. void CBaseAnimSetPresetFaderPanel::OnPresetNameSelected( KeyValues *pParams )
  769. {
  770. const char *pPresetName = pParams->GetString( "text", NULL );
  771. const char *pPresetGroupName = pParams->GetString( "presetGroupName" );
  772. bool bAnimated = pParams->GetBool( "animated" );
  773. AddPreset( pPresetGroupName, pPresetName, bAnimated );
  774. PopulatePresetList( false );
  775. }
  776. //-----------------------------------------------------------------------------
  777. // The 'add preset' context menu option
  778. //-----------------------------------------------------------------------------
  779. void CBaseAnimSetPresetFaderPanel::OnShowAddPresetDialog()
  780. {
  781. if ( !m_pController->GetAnimationSetClip() )
  782. return;
  783. CAddPresetDialog *pAddPresetDialog = new CAddPresetDialog( this );
  784. pAddPresetDialog->AddActionSignalTarget( this );
  785. const char *pCurrentGroupName = m_pSheet->GetActivePage() ? m_pSheet->GetActivePage()->GetName() : "";
  786. pAddPresetDialog->DoModal( m_pController->GetAnimationSetClip(), pCurrentGroupName, NULL );
  787. }
  788. //-----------------------------------------------------------------------------
  789. // Called by the preset group editor panel when it changes presets
  790. //-----------------------------------------------------------------------------
  791. void CBaseAnimSetPresetFaderPanel::OnPresetsChanged()
  792. {
  793. PopulatePresetList( false );
  794. }
  795. //-----------------------------------------------------------------------------
  796. // Brings up the preset manager
  797. //-----------------------------------------------------------------------------
  798. void CBaseAnimSetPresetFaderPanel::OnManagePresets()
  799. {
  800. if ( !m_hPresetEditor.Get() )
  801. {
  802. m_hPresetEditor = new CDmePresetGroupEditorFrame( this, "Manage Presets" );
  803. m_hPresetEditor->AddActionSignalTarget( this );
  804. m_hPresetEditor->SetVisible( false );
  805. m_hPresetEditor->SetDeleteSelfOnClose( false );
  806. m_hPresetEditor->MoveToCenterOfScreen();
  807. }
  808. m_hPresetEditor->SetAnimationSetClip( m_pController->GetAnimationSetClip() );
  809. m_hPresetEditor->DoModal();
  810. }
  811. void CBaseAnimSetPresetFaderPanel::ApplySchemeSettings( IScheme *scheme )
  812. {
  813. BaseClass::ApplySchemeSettings( scheme );
  814. m_pSliders->SetBgColor( Color( 42, 42, 42, 255 ) );
  815. }
  816. void CBaseAnimSetPresetFaderPanel::GetPreviewFader( FaderPreview_t& fader )
  817. {
  818. Q_memset( &fader, 0, sizeof( fader ) );
  819. fader.isbeingdragged = false;
  820. fader.holdingPreviewKey = false;
  821. CPresetSlider *slider = GetActivePresetSlider();
  822. if ( !slider )
  823. return;
  824. fader.isbeingdragged = slider->IsDragging();
  825. fader.holdingPreviewKey = input()->IsKeyDown( KEY_LSHIFT ) || input()->IsKeyDown( KEY_RSHIFT );
  826. int mx, my;
  827. input()->GetCursorPos( mx, my );
  828. if ( !IsWithin( mx, my ) )
  829. {
  830. fader.holdingPreviewKey = false;
  831. }
  832. fader.name = slider->GetName();
  833. fader.amount = slider->GetCurrent();
  834. fader.values = slider->GetAttributeDict();
  835. fader.nProceduralType = slider->GetProceduralPresetType();
  836. }
  837. void CBaseAnimSetPresetFaderPanel::UpdateProceduralPresetSlider( AttributeDict_t *values )
  838. {
  839. CPresetSlider *slider = GetActivePresetSlider();
  840. if ( !slider )
  841. return;
  842. int nProceduralType = slider->GetProceduralPresetType();
  843. switch ( nProceduralType )
  844. {
  845. case PROCEDURAL_PRESET_IN_CROSSFADE:
  846. case PROCEDURAL_PRESET_OUT_CROSSFADE:
  847. case PROCEDURAL_PRESET_HEAD_CROSSFADE:
  848. case PROCEDURAL_PRESET_DEFAULT_CROSSFADE:
  849. case PROCEDURAL_PRESET_ZERO_CROSSFADE:
  850. case PROCEDURAL_PRESET_HALF_CROSSFADE:
  851. case PROCEDRUAL_PRESET_ONE_CROSSFADE:
  852. GetController()->ProceduralPreset_UpdateCrossfade( values, nProceduralType );
  853. break;
  854. }
  855. }
  856. static void Parallel_UpdateControlValues( CPresetSlider *&slider )
  857. {
  858. slider->SetControlValues();
  859. }
  860. static ConVar ifm_threaded_updatecontrolvalues( "ifm_threaded_updatecontrolvalues", "1", 0 );
  861. void CBaseAnimSetPresetFaderPanel::UpdateControlValues( bool bVisibleOnly /*=true*/ )
  862. {
  863. CUtlVectorFixedGrowable< CPresetSlider*, 100 > workItems;
  864. workItems.EnsureCapacity( m_pSliders->GetItemCount() );
  865. for ( int i = m_pSliders->FirstItem(); i != m_pSliders->InvalidItemID(); i = m_pSliders->NextItem(i) )
  866. {
  867. CPresetSlider *pSlider = static_cast< CPresetSlider * >( m_pSliders->GetItemPanel( i ) );
  868. if ( !pSlider )
  869. continue;
  870. const char *pPresetName = pSlider->GetPresetName();
  871. if ( !pPresetName || !*pPresetName )
  872. continue;
  873. if ( bVisibleOnly && !pSlider->IsVisible() )
  874. continue;
  875. workItems.AddToTail( pSlider );
  876. }
  877. if ( ifm_threaded_updatecontrolvalues.GetBool() )
  878. {
  879. ParallelProcess( workItems.Base(), workItems.Count(), Parallel_UpdateControlValues );
  880. }
  881. else
  882. {
  883. FOR_EACH_VEC( workItems, i )
  884. {
  885. workItems[ i ]->SetControlValues();
  886. }
  887. }
  888. }
  889. CPresetSlider *CBaseAnimSetPresetFaderPanel::FindPresetSlider( const char *pName )
  890. {
  891. for ( int itemID = m_pSliders->FirstItem(); itemID != m_pSliders->InvalidItemID(); itemID = m_pSliders->NextItem( itemID ) )
  892. {
  893. CPresetSlider *pSlider = static_cast< CPresetSlider * >( m_pSliders->GetItemPanel( itemID ) );
  894. if ( !pSlider )
  895. continue;
  896. const char *pPresetName = pSlider->GetPresetName();
  897. if ( !pPresetName || !*pPresetName )
  898. continue;
  899. if ( !V_strcmp( pSlider->GetName(), pName ) )
  900. return pSlider;
  901. }
  902. return NULL;
  903. }
  904. void CBaseAnimSetPresetFaderPanel::SetActivePresetSlider( CPresetSlider *pSlider )
  905. {
  906. m_hActivePresetSlider = pSlider;
  907. }
  908. CPresetSlider *CBaseAnimSetPresetFaderPanel::GetActivePresetSlider()
  909. {
  910. return m_hActivePresetSlider;
  911. }
  912. CPresetSlider *CBaseAnimSetPresetFaderPanel::GetSliderForRow( int nSlot )
  913. {
  914. return assert_cast< CPresetSlider * >( m_pSliders->GetItemPanel( m_pSliders->GetItemIDFromRow( nSlot ) ) );
  915. }
  916. void CBaseAnimSetPresetFaderPanel::UpdateOrCreatePresetSlider( int nSlot, const char *pPresetGroupName, const char *pPresetName )
  917. {
  918. if ( !pPresetName )
  919. return;
  920. CPresetSlider *pSlider = NULL;
  921. if ( nSlot >= m_pSliders->GetItemCount() )
  922. {
  923. pSlider = new CPresetSlider( m_pSliders, this );
  924. m_pSliders->AddItem( NULL, pSlider );
  925. }
  926. else
  927. {
  928. pSlider = GetSliderForRow( nSlot );
  929. }
  930. if ( pSlider )
  931. {
  932. pSlider->Init( pPresetGroupName, pPresetName );
  933. pSlider->SetPos( 0 );
  934. pSlider->SetSize( 100, 20 );
  935. m_pSliders->SetItemVisible( m_pSliders->GetItemIDFromRow( nSlot ), true );
  936. }
  937. }
  938. void CBaseAnimSetPresetFaderPanel::RebuildPresetSliders( const char *pPresetGroupName, const CUtlVector< CUtlSymbolLarge > &presetNames )
  939. {
  940. m_pSliders->HideAllItems();
  941. int nPresets = presetNames.Count();
  942. for ( int i = 0; i < nPresets; ++i )
  943. {
  944. UpdateOrCreatePresetSlider( i, pPresetGroupName, presetNames[ i ].String() );
  945. }
  946. int nSliders = m_pSliders->GetItemCount();
  947. for ( int i = nPresets; i < nSliders; ++i )
  948. {
  949. CPresetSlider *pSlider = GetSliderForRow( i );
  950. if ( !pSlider )
  951. continue;
  952. pSlider->Clear();
  953. }
  954. UpdateControlValues( false );
  955. }
  956. void CBaseAnimSetPresetFaderPanel::OnPageChanged()
  957. {
  958. PopulatePresetList( true );
  959. }
  960. void CBaseAnimSetPresetFaderPanel::PopulatePresetList( bool bChanged )
  961. {
  962. CDmeFilmClip *pFilmClip = m_pController->GetAnimationSetClip();
  963. int nCurrentGroupIndex = m_pSheet->GetActivePageNum();
  964. bool bCurrentGroupIsProceduralGroup = nCurrentGroupIndex == 0;
  965. const char *pCurrentGroupName = m_pSheet->GetActivePage() ? m_pSheet->GetActivePage()->GetName() : "";
  966. CUtlVector< PresetGroupInfo_t > presetGroupInfo;
  967. presetGroupInfo.AddToTail( PresetGroupInfo_t( g_pDataModel->GetSymbol( PROCEDURAL_PRESET_GROUP_NAME ) ) );
  968. CollectPresetGroupInfo( pFilmClip, presetGroupInfo, false, true );
  969. int nPresetGroups = presetGroupInfo.Count();
  970. int nPresetGroupPages = m_presetGroupPages.Count();
  971. for ( int i = 0; i < nPresetGroupPages; ++i )
  972. {
  973. vgui::PropertyPage *pPage = m_presetGroupPages[ i ];
  974. if ( !pPage )
  975. continue;
  976. if ( i < nPresetGroups )
  977. {
  978. const char *pName = presetGroupInfo[ i ].presetGroupSym.String();
  979. const char *pPageName = pPage->GetName();
  980. if ( !*pPageName )
  981. {
  982. m_pSheet->AddPage( pPage, pName );
  983. }
  984. else
  985. {
  986. m_pSheet->SetPageTitle( pPage, pName );
  987. }
  988. pPage->SetName( pName );
  989. }
  990. else
  991. {
  992. m_pSheet->RemovePage( pPage );
  993. pPage->SetName( "" );
  994. }
  995. }
  996. for ( int i = nPresetGroupPages; i < nPresetGroups; ++i )
  997. {
  998. const char *pName = presetGroupInfo[ i ].presetGroupSym.String();
  999. vgui::PropertyPage *pPage = new vgui::PropertyPage( this, pName );
  1000. m_presetGroupPages.AddToTail( pPage );
  1001. m_pSheet->AddPage( pPage, pName );
  1002. }
  1003. if ( nCurrentGroupIndex < 0 )
  1004. {
  1005. m_pSliders->HideAllItems();
  1006. return;
  1007. }
  1008. vgui::PropertyPage *pCurrentGroupPage = m_presetGroupPages[ nCurrentGroupIndex ];
  1009. m_pSheet->SetActivePage( pCurrentGroupPage );
  1010. m_pSliders->SetParent( pCurrentGroupPage );
  1011. CUtlVector< CUtlSymbolLarge > presetNames;
  1012. if ( bCurrentGroupIsProceduralGroup )
  1013. {
  1014. CollectProceduralPresetNames( presetNames );
  1015. }
  1016. else
  1017. {
  1018. CollectPresetNamesForGroup( pFilmClip, pCurrentGroupName, presetNames );
  1019. }
  1020. RebuildPresetSliders( pCurrentGroupName, presetNames );
  1021. }
  1022. void CBaseAnimSetPresetFaderPanel::OnDeletePreset( const char *pPresetName )
  1023. {
  1024. CUndoScopeGuard guard( 0, NOTIFY_SETDIRTYFLAG, "Delete Preset" );
  1025. {
  1026. CAnimSetGroupAnimSetTraversal traversal( m_pController->GetAnimationSetClip() );
  1027. while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
  1028. {
  1029. // Delete it from various things
  1030. pAnimSet->RemovePreset( pPresetName );
  1031. }
  1032. }
  1033. PopulatePresetList( false );
  1034. }
  1035. void CBaseAnimSetPresetFaderPanel::DispatchCurve( int nCurveType )
  1036. {
  1037. // Nothing, must be handled by SFM
  1038. }