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.

210 lines
6.7 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef DMETRACK_H
  7. #define DMETRACK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlflags.h"
  12. #include "datamodel/dmelement.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "movieobjects/dmeclip.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CDmeClip;
  19. enum DmeClipType_t;
  20. //-----------------------------------------------------------------------------
  21. // Default track name
  22. //-----------------------------------------------------------------------------
  23. #define DMETRACK_DEFAULT_NAME "default"
  24. //-----------------------------------------------------------------------------
  25. // Constructor, destructor
  26. //-----------------------------------------------------------------------------
  27. class CDmeTrack : public CDmElement
  28. {
  29. DEFINE_ELEMENT( CDmeTrack, CDmElement );
  30. public:
  31. // Methods of IDmElement
  32. virtual void OnAttributeChanged( CDmAttribute *pAttribute );
  33. void SetCollapsed( bool state );
  34. bool IsCollapsed() const;
  35. void SetVolume( float state );
  36. float GetVolume() const;
  37. void SetMute( bool state );
  38. bool IsMute( bool bCheckSoloing = true ) const;
  39. // Is this track synched to the film track?
  40. void SetSynched( bool bState );
  41. bool IsSynched() const;
  42. int GetClipCount() const;
  43. CDmeClip *GetClip( int i ) const;
  44. const CUtlVector< DmElementHandle_t > &GetClips( ) const;
  45. void AddClip( CDmeClip *clip );
  46. bool RemoveClip( CDmeClip *clip );
  47. void RemoveClip( int i );
  48. void RemoveAllClips();
  49. int FindClip( CDmeClip *clip );
  50. CDmeClip *FindNamedClip( const char *name );
  51. DmeClipType_t GetClipType() const;
  52. void SetClipType( DmeClipType_t type );
  53. // Find clips at, intersecting or within a particular time interval
  54. void FindClipsAtTime( DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
  55. void FindClipsIntersectingTime( DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
  56. void FindClipsWithinTime( DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
  57. // Methods to shift clips around
  58. // These methods shift clips that straddle the start/end time (NOTE: time is measured in local time)
  59. // NOTE: bTestStartingTime true means if the starting time is after the start time, then shift
  60. // Setting it to false means if the clip intersects the time at all, then shift
  61. void ShiftAllClipsAfter ( DmeTime_t startTime, DmeTime_t dt, bool bTestStartingTime = true );
  62. void ShiftAllClipsBefore( DmeTime_t endTime, DmeTime_t dt, bool bTestEndingTime = true );
  63. void ShiftAllClips( DmeTime_t dt );
  64. // A version that works only on film clips
  65. void ShiftAllFilmClipsAfter ( CDmeClip *pClip, DmeTime_t dt, bool bShiftClip = false, bool bSortClips = true );
  66. void ShiftAllFilmClipsBefore( CDmeClip *pClip, DmeTime_t dt, bool bShiftClip = false, bool bSortClips = true );
  67. // Sorts all children so they ascend in time
  68. void SortClipsByStartTime( );
  69. // Shifts all clips to be non-overlapping
  70. void FixOverlaps();
  71. // Can this track contain clips that overlap in time?
  72. // NOTE: Non-overlapping clips will be
  73. bool IsNonoverlapping() const;
  74. // Is this a film track?
  75. bool IsFilmTrack() const;
  76. // Returns the next/previous clip in a film track
  77. CDmeClip* FindPrevFilmClip( CDmeClip *pClip );
  78. CDmeClip* FindNextFilmClip( CDmeClip *pClip );
  79. void FindAdjacentFilmClips( CDmeClip *pClip, CDmeClip *&pPrevClip, CDmeClip *&pNextClip );
  80. void FindAdjacentFilmClips( DmeTime_t localTime, CDmeClip *&pPrevClip, CDmeClip *&pNextClip );
  81. // Finds a clip at a particular time
  82. CDmeClip* FindFilmClipAtTime( DmeTime_t localTime );
  83. // Find first clip that intersects a specific time range
  84. CDmeClip* FindFirstFilmClipIntesectingTime( DmeTime_t localStartTime, DmeTime_t localEndTime );
  85. // Inserts space in a film track for a film clip
  86. void InsertSpaceInFilmTrack( DmeTime_t localStartTime, DmeTime_t localEndTime );
  87. // Singleton solo track (of the same clip type that this track is)
  88. CDmeTrack *GetSoloTrack( ) const;
  89. void SetSoloTrack( );
  90. bool IsSoloTrack() const;
  91. static CDmeTrack *GetSoloTrack( DmeClipType_t clipType );
  92. static void SetSoloTrack( DmeClipType_t clipType, CDmeTrack *pTrack );
  93. // Fills all gaps in a film track with slugs
  94. void FillAllGapsWithSlugs( const char *pSlugName, DmeTime_t startTime, DmeTime_t endTime );
  95. // Track vertical display scale
  96. void SetDisplayScale( float flDisplayScale );
  97. float GetDisplayScale() const;
  98. private:
  99. class CSuppressAutoFixup
  100. {
  101. public:
  102. CSuppressAutoFixup( CDmeTrack *pTrack, int nFlags ) : m_pTrack( pTrack ), m_nFlags( nFlags )
  103. {
  104. m_pTrack->m_Flags.SetFlag( m_nFlags );
  105. }
  106. ~CSuppressAutoFixup()
  107. {
  108. m_pTrack->m_Flags.ClearFlag( m_nFlags );
  109. }
  110. private:
  111. CDmeTrack *m_pTrack;
  112. int m_nFlags;
  113. };
  114. enum
  115. {
  116. IS_SORTED = 0x1,
  117. SUPPRESS_OVERLAP_FIXUP = 0x2,
  118. SUPPRESS_DIRTY_ORDERING = 0x4,
  119. };
  120. CDmaElementArray< CDmeClip > m_Clips;
  121. CDmaVar< float > m_Volume;
  122. CDmaVar< bool > m_Collapsed;
  123. CDmaVar< bool > m_Mute;
  124. CDmaVar< bool > m_Synched;
  125. CDmaVar< int > m_ClipType;
  126. CDmaVar< float > m_flDisplayScale;
  127. CUtlFlags< unsigned char > m_Flags;
  128. DmElementHandle_t m_hOwner;
  129. static DmElementHandle_t m_hSoloTrack[DMECLIP_TYPE_COUNT];
  130. friend class CSuppressAutoFixup;
  131. };
  132. //-----------------------------------------------------------------------------
  133. // Indicates whether tracks contain clips that are non-overlapping in time
  134. //-----------------------------------------------------------------------------
  135. inline bool CDmeTrack::IsNonoverlapping() const
  136. {
  137. return m_ClipType == DMECLIP_FILM;
  138. }
  139. //-----------------------------------------------------------------------------
  140. // Is this a film track?
  141. //-----------------------------------------------------------------------------
  142. inline bool CDmeTrack::IsFilmTrack() const
  143. {
  144. return m_ClipType == DMECLIP_FILM;
  145. }
  146. //-----------------------------------------------------------------------------
  147. // Track vertical display scale
  148. //-----------------------------------------------------------------------------
  149. inline void CDmeTrack::SetDisplayScale( float flDisplayScale )
  150. {
  151. m_flDisplayScale = flDisplayScale;
  152. }
  153. inline float CDmeTrack::GetDisplayScale() const
  154. {
  155. return m_flDisplayScale;
  156. }
  157. //-----------------------------------------------------------------------------
  158. // helper methods
  159. //-----------------------------------------------------------------------------
  160. CDmeTrackGroup *GetParentTrackGroup( CDmeTrack *pTrack );
  161. #endif // DMETRACK_H