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.

186 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #if !defined( ANIMATIONBROWSER_H )
  8. #define ANIMATIONBROWSER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #define IDC_AB_TRAYSCROLL 1001
  13. #define IDC_AB_THUMBNAIL_INCREASE 1002
  14. #define IDC_AB_THUMBNAIL_DECREASE 1003
  15. #define IDC_AB_CONTEXT_CREATEBITMAP 1004
  16. #define IDC_AB_CONTEXT_CREATEALLBITMAPS 1005
  17. #define IDC_AB_FILTERTAB 1006
  18. #define IDC_AB_CREATE_CUSTOM 1007
  19. #define IDC_AB_ADDTOGROUPSTART 1100
  20. #define IDC_AB_ADDTOGROUPEND 1199
  21. #define IDC_AB_REMOVEFROMGROUPSTART 1200
  22. #define IDC_AB_REMOVEFROMGROUPEND 1299
  23. #define IDC_AB_DELETEGROUPSTART 1300
  24. #define IDC_AB_DELETEGROUPEND 1399
  25. #define IDC_AB_RENAMEGROUPSTART 1400
  26. #define IDC_AB_RENAMEGROUPEND 1499
  27. #define COLOR_TRAYBACKGROUND RGB( 240, 240, 220 )
  28. #include "faceposertoolwindow.h"
  29. #include "StudioModel.h"
  30. class CAnimBrowserTab;
  31. class CCustomAnim
  32. {
  33. public:
  34. CCustomAnim( const FileNameHandle_t &h )
  35. :
  36. m_bDirty( false ),
  37. m_ShortName( UTL_INVAL_SYMBOL )
  38. {
  39. m_Handle = h;
  40. }
  41. void LoadFromFile();
  42. void SaveToFile();
  43. bool HasAnimation( char const *search );
  44. bool m_bDirty;
  45. CUtlSymbol m_ShortName;
  46. FileNameHandle_t m_Handle;
  47. CUtlVector< CUtlSymbol > m_Animations;
  48. };
  49. //-----------------------------------------------------------------------------
  50. // Purpose:
  51. //-----------------------------------------------------------------------------
  52. class AnimationBrowser : public mxWindow, public IFacePoserToolWindow
  53. {
  54. public:
  55. enum
  56. {
  57. FILTER_NONE = 0,
  58. FILTER_GESTURES,
  59. FILTER_POSTURES,
  60. FILTER_STRING,
  61. FILTER_FIRST_CUSTOM
  62. };
  63. AnimationBrowser( mxWindow *parent, int id = 0 );
  64. virtual ~AnimationBrowser ( void );
  65. virtual void Shutdown();
  66. virtual void redraw ();
  67. virtual bool PaintBackground( void );
  68. virtual int handleEvent (mxEvent *event);
  69. virtual void Think( float dt );
  70. void ThumbnailIncrease( void );
  71. void ThumbnailDecrease( void );
  72. void RestoreThumbnailSize( void );
  73. void Select( int sequence );
  74. void Deselect( void );
  75. void SetCellSize( int cellsize );
  76. void ReloadBitmaps( void );
  77. virtual void OnModelChanged();
  78. void OnAddCustomAnimationFilter();
  79. private: // Methods
  80. void OnFilter();
  81. bool SequencePassesFilter( StudioModel *model, int sequence, mstudioseqdesc_t &seqdesc );
  82. int GetSequenceCount();
  83. mstudioseqdesc_t *GetSeqDesc( int index );
  84. int TranslateSequenceNumber( int index );
  85. int GetCellUnderPosition( int x, int y );
  86. bool ComputeRect( int cell, int& rcx, int& rcy, int& rcw, int& rch );
  87. int ComputePixelsNeeded( void );
  88. void RepositionSlider();
  89. void SetClickedCell( int cell );
  90. void ShowRightClickMenu( int mx, int my );
  91. void DrawThumbNail( int sequence, CChoreoWidgetDrawHelper& helper,
  92. int rcx, int rcy, int rcw, int rch );
  93. void DrawSequenceFocusRect( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, COLORREF clr );
  94. void DrawSequenceDescription( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, int sequence, mstudioseqdesc_t &seqdesc );
  95. void DrawFocusRect( void );
  96. // Custom group tab stuff
  97. void FindCustomFiles( char const *subdir, CUtlVector< FileNameHandle_t >& files );
  98. void AddCustomFile( const FileNameHandle_t& handle );
  99. void RenameCustomFile( int index );
  100. void DeleteCustomFile( int index );
  101. void PurgeCustom();
  102. void BuildCustomFromFiles( CUtlVector< FileNameHandle_t >& files );
  103. void UpdateCustomTabs();
  104. int FindCustomFile( char const *shortName );
  105. void AddAnimationToCustomFile( int index, char const *animationName );
  106. void RemoveAnimationFromCustomFile( int index, char const *animationName );
  107. void RemoveAllAnimationsFromCustomFile( int index );
  108. private: // Data
  109. mxScrollbar *slScrollbar;
  110. CAnimBrowserTab *m_pFilterTab;
  111. mxLineEdit *m_pSearchEntry;
  112. int m_nTopOffset;
  113. int m_nLastNumAnimations;
  114. int m_nGranularity;
  115. int m_nCurCell;
  116. int m_nClickedCell;
  117. // Formatting
  118. int m_nButtonSquare;
  119. int m_nGap;
  120. int m_nDescriptionHeight;
  121. int m_nSnapshotWidth;
  122. int m_nSnapshotHeight;
  123. bool m_bDragging;
  124. RECT m_rcFocus;
  125. RECT m_rcOrig;
  126. int m_nDragCell;
  127. int m_nXStart;
  128. int m_nYStart;
  129. mxButton *m_pThumbnailIncreaseButton;
  130. mxButton *m_pThumbnailDecreaseButton;
  131. CUtlVector< int > m_Filtered;
  132. int m_nCurFilter;
  133. char m_szSearchString[ 256 ];
  134. float m_flDragTime;
  135. CUtlVector< CCustomAnim * > m_CustomAnimationTabs;
  136. };
  137. extern AnimationBrowser *g_pAnimationBrowserTool;
  138. #endif // ANIMATIONBROWSER_H