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.

151 lines
5.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef BASEANIMATIONSETEDITOR_H
  7. #define BASEANIMATIONSETEDITOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/EditablePanel.h"
  12. #include "vgui_controls/ImageList.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "vgui/KeyCode.h"
  15. #include "dme_controls//AnimSetAttributeValue.h"
  16. #include "dme_controls/RecordingState.h"
  17. #include "tier1/utlvector.h"
  18. #include "movieobjects/dmelog.h"
  19. #include "vgui_controls/fileopenstatemachine.h"
  20. //-----------------------------------------------------------------------------
  21. // Forward declarations
  22. //-----------------------------------------------------------------------------
  23. struct LogPreview_t;
  24. class CDmeAnimationSet;
  25. class CDmeAnimationList;
  26. class CDmeChannelsClip;
  27. class CDmeChannel;
  28. class CBaseAnimSetControlGroupPanel;
  29. class CBaseAnimSetPresetFaderPanel;
  30. class CBaseAnimSetAttributeSliderPanel;
  31. class CDmeGameModel;
  32. //-----------------------------------------------------------------------------
  33. // Base class for the panel for editing animation sets
  34. //-----------------------------------------------------------------------------
  35. class CBaseAnimationSetEditor : public vgui::EditablePanel, public vgui::IFileOpenStateMachineClient
  36. {
  37. DECLARE_CLASS_SIMPLE( CBaseAnimationSetEditor, vgui::EditablePanel );
  38. public:
  39. enum EAnimSetLayout_t
  40. {
  41. LAYOUT_SPLIT = 0,
  42. LAYOUT_VERTICAL,
  43. LAYOUT_HORIZONTAL,
  44. };
  45. CBaseAnimationSetEditor( vgui::Panel *parent, char const *panelName, bool bShowGroups );
  46. virtual ~CBaseAnimationSetEditor();
  47. virtual void CreateToolsSubPanels();
  48. int BuildVisibleControlList( CUtlVector< LogPreview_t >& list );
  49. int BuildFullControlList( CUtlVector< LogPreview_t >& list );
  50. void RecomputePreview();
  51. virtual void ChangeLayout( EAnimSetLayout_t newLayout );
  52. CBaseAnimSetControlGroupPanel *GetControlGroup();
  53. CBaseAnimSetPresetFaderPanel *GetPresetFader();
  54. CBaseAnimSetAttributeSliderPanel *GetAttributeSlider();
  55. void ChangeAnimationSet( CDmeAnimationSet *newAnimSet );
  56. virtual void SetRecordingState( RecordingState_t state, bool updateSettings );
  57. RecordingState_t GetRecordingState() const;
  58. CDmeAnimationSet *GetAnimationSet();
  59. // Inherited from IFileOpenStateMachineClient
  60. public:
  61. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
  62. virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  63. virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  64. protected:
  65. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  66. virtual void PerformLayout();
  67. virtual void OnDataChanged();
  68. MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
  69. MESSAGE_FUNC_INT( OnChangeLayout, "OnChangeLayout", value );
  70. MESSAGE_FUNC( OnTextChanged, "TextChanged" );
  71. MESSAGE_FUNC_PARAMS( OnButtonToggled, "ButtonToggled", params );
  72. MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", params );
  73. MESSAGE_FUNC_PARAMS( OnImportConfirmed, "ImportConfirmed", params );
  74. MESSAGE_FUNC_PARAMS( OnImportAnimation, "ImportAnimation", params );
  75. MESSAGE_FUNC( OnExportFacialAnimation, "ExportFacialAnimation" );
  76. MESSAGE_FUNC_PARAMS( OnImportAnimationSelected, "DmeSelected", params );
  77. MESSAGE_FUNC_PARAMS( OnImportAnimationCancelled, "DmeSelectionCancelled", params );
  78. // Selects an animation to import
  79. void SelectImportAnimation( CDmeAnimationList *pAnimationList, bool bVisibleOnly );
  80. // Imports a specific channels clip into the animation set
  81. void ImportAnimation( CDmeChannelsClip *pChannelsClip, bool bVisibleOnly );
  82. // Finds a channel in the animation set to overwrite with import data
  83. CDmeChannel* FindImportChannel( CDmeChannel *pChannel, CDmeChannelsClip *pChannelsClip );
  84. // Transforms an imported channel, if necessary
  85. void TransformImportedChannel( CDmeChannel *pChannel );
  86. // Transforms an imported position log
  87. void TransformImportedPositionLog( const matrix3x4_t& matrix, CDmeVector3Log *pPositionLog );
  88. // Transforms an imported orientation log
  89. void TransformImportedOrientationLog( const matrix3x4_t& matrix, CDmeQuaternionLog *pOrientationLog );
  90. // Expands channels clip time to encompass log
  91. void FixupChannelsClipTime( CDmeChannel *pChannel, CDmeLog *pLog );
  92. void FixupChannelsClipTime( CDmeChannelsClip *pChannelsClip, CDmeLog *pLog );
  93. // Adds a log layer to the list of logs for export
  94. void AddLogLayerForExport( CDmElement *pRoot, const char *pControlName, CDmeChannel *pChannel, DmeTime_t tExportStart, DmeTime_t tExportEnd );
  95. // Exports animations
  96. void ExportAnimations( CDmElement *pAnimations, DmeTime_t tExportStart, DmeTime_t tExportEnd );
  97. // Inherited classes need to implement this for export to work.
  98. virtual CDmeFilmClip *GetAnimationSetClip() { return NULL; }
  99. virtual CDmeFilmClip *GetRootClip() { return NULL; }
  100. protected:
  101. EAnimSetLayout_t m_Layout;
  102. vgui::DHANDLE< vgui::Splitter > m_Splitter;
  103. vgui::DHANDLE< CBaseAnimSetControlGroupPanel > m_hControlGroup;
  104. vgui::DHANDLE< CBaseAnimSetPresetFaderPanel > m_hPresetFader;
  105. vgui::DHANDLE< CBaseAnimSetAttributeSliderPanel > m_hAttributeSlider;
  106. vgui::DHANDLE< vgui::Menu > m_hContextMenu;
  107. vgui::DHANDLE< vgui::FileOpenStateMachine > m_hFileOpenStateMachine;
  108. vgui::ToggleButton *m_pState[ NUM_AS_RECORDING_STATES ];
  109. vgui::ToggleButton *m_pSelectionModeType;
  110. vgui::ImageList m_Images;
  111. CDmeHandle< CDmeAnimationSet > m_AnimSet;
  112. vgui::ComboBox *m_pComboBox;
  113. RecordingState_t m_RecordingState;
  114. };
  115. #endif // BASEANIMATIONSETEDITOR_H