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.

177 lines
6.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef PRESETGROUPEDITORPANEL_H
  8. #define PRESETGROUPEDITORPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlvector.h"
  13. #include "vgui_controls/Frame.h"
  14. #include "datamodel/dmehandle.h"
  15. #include "vgui_controls/fileopenstatemachine.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class CDmeAnimationSet;
  20. class CDmePresetListPanel;
  21. class CDmePresetGroupListPanel;
  22. class CDmePresetGroup;
  23. class CDmePreset;
  24. namespace vgui
  25. {
  26. class PropertySheet;
  27. class PropertyPage;
  28. class Button;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Dag editor panel
  32. //-----------------------------------------------------------------------------
  33. class CDmePresetGroupEditorPanel : public vgui::EditablePanel, public vgui::IFileOpenStateMachineClient
  34. {
  35. DECLARE_CLASS_SIMPLE( CDmePresetGroupEditorPanel, vgui::EditablePanel );
  36. public:
  37. // constructor, destructor
  38. CDmePresetGroupEditorPanel( vgui::Panel *pParent, const char *pName );
  39. virtual ~CDmePresetGroupEditorPanel();
  40. // Sets the current scene + animation list
  41. void SetAnimationSet( CDmeAnimationSet *pAnimationSet );
  42. CDmeAnimationSet *GetAnimationSet();
  43. void RefreshAnimationSet();
  44. void NotifyDataChanged();
  45. // Returns selected presets/groups
  46. CDmePresetGroup* GetSelectedPresetGroup( );
  47. CDmePreset* GetSelectedPreset( );
  48. // Drag/drop reordering of preset groups
  49. void MovePresetGroupInFrontOf( CDmePresetGroup *pDragGroup, CDmePresetGroup *pDropGroup );
  50. // Drag/drop reordering of presets
  51. void MovePresetInFrontOf( CDmePreset *pDragPreset, CDmePreset *pDropPreset );
  52. // Drag/drop preset moving
  53. void MovePresetIntoGroup( CDmePreset *pPreset, CDmePresetGroup *pGroup );
  54. // Toggle group visibility
  55. void ToggleGroupVisibility( CDmePresetGroup *pPresetGroup );
  56. MESSAGE_FUNC( OnMovePresetUp, "MovePresetUp" );
  57. MESSAGE_FUNC( OnMovePresetDown, "MovePresetDown" );
  58. MESSAGE_FUNC( OnMoveGroupUp, "MoveGroupUp" );
  59. MESSAGE_FUNC( OnMoveGroupDown, "MoveGroupDown" );
  60. MESSAGE_FUNC( OnRemoveGroup, "RemoveGroup" );
  61. MESSAGE_FUNC( OnRemovePreset, "RemovePreset" );
  62. // Inherited from IFileOpenStateMachineClient
  63. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
  64. virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  65. virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  66. private:
  67. MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", kv );
  68. MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
  69. MESSAGE_FUNC( OnAddGroup, "AddGroup" );
  70. MESSAGE_FUNC( OnAddPhonemeGroup, "AddPhonemeGroup" );
  71. MESSAGE_FUNC( OnRenameGroup, "RenameGroup" );
  72. MESSAGE_FUNC( OnEditPresetRemapping, "EditPresetRemapping" );
  73. MESSAGE_FUNC( OnRemoveDefaultControls, "RemoveDefaultControls" );
  74. MESSAGE_FUNC( OnRemapPresets, "RemapPresets" );
  75. MESSAGE_FUNC( OnAddPreset, "AddPreset" );
  76. MESSAGE_FUNC( OnRenamePreset, "RenamePreset" );
  77. MESSAGE_FUNC( OnToggleGroupVisibility, "ToggleGroupVisibility" );
  78. MESSAGE_FUNC( OnToggleGroupSharing, "ToggleGroupSharing" );
  79. MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
  80. MESSAGE_FUNC_PARAMS( OnItemDeselected, "ItemDeselected", kv );
  81. MESSAGE_FUNC( OnImportPresets, "ImportPresets" );
  82. MESSAGE_FUNC( OnExportPresets, "ExportPresets" );
  83. MESSAGE_FUNC( OnImportPresetGroups, "ImportPresetGroups" );
  84. MESSAGE_FUNC( OnExportPresetGroups, "ExportPresetGroups" );
  85. MESSAGE_FUNC( OnExportPresetGroupToVFE, "ExportPresetGroupsToVFE" );
  86. MESSAGE_FUNC( OnExportPresetGroupToTXT, "ExportPresetGroupsToTXT" );
  87. MESSAGE_FUNC_PARAMS( OnPresetPicked, "PresetPicked", params );
  88. MESSAGE_FUNC_PARAMS( OnPresetPickCancelled, "PresetPickCancelled", params );
  89. MESSAGE_FUNC_PARAMS( OnFileStateMachineFinished, "FileStateMachineFinished", params );
  90. // Cleans up the context menu
  91. void CleanupContextMenu();
  92. // If it finds a duplicate group/preset name, reports an error message and returns it found one
  93. bool HasDuplicatePresetName( const char *pPresetName, CDmePreset *pIgnorePreset = NULL );
  94. bool HasDuplicateGroupName( const char *pControlName, CDmePresetGroup *pIgnoreGroup = NULL );
  95. // Refreshes the list of presets
  96. void RefreshPresetNames( );
  97. // Called by OnInputCompleted after we get a new group or preset name
  98. void PerformAddGroup( const char *pNewGroupName );
  99. void PerformAddPhonemeGroup( const char *pNewGroupName );
  100. void PerformRenameGroup( const char *pNewGroupName );
  101. void PerformAddPreset( const char *pNewPresetName );
  102. void PerformRenamePreset( const char *pNewPresetName );
  103. // Called to open a context-sensitive menu for a particular preset
  104. void OnOpenPresetContextMenu( );
  105. // Gets/sets a selected preset
  106. void SetSelectedPreset( CDmePreset* pPreset );
  107. // Selects a particular preset group
  108. void SetSelectedPresetGroup( CDmePresetGroup* pPresetGroup );
  109. // Imports presets
  110. void ImportPresets( const CUtlVector< CDmePreset * >& presets );
  111. CDmeHandle< CDmeAnimationSet > m_hAnimationSet;
  112. vgui::Splitter *m_pSplitter;
  113. CDmePresetGroupListPanel *m_pPresetGroupList;
  114. CDmePresetListPanel *m_pPresetList;
  115. vgui::DHANDLE< vgui::Menu > m_hContextMenu;
  116. vgui::DHANDLE< vgui::FileOpenStateMachine > m_hFileOpenStateMachine;
  117. };
  118. //-----------------------------------------------------------------------------
  119. // Frame for combination system
  120. //-----------------------------------------------------------------------------
  121. class CDmePresetGroupEditorFrame : public vgui::Frame, public IDmNotify
  122. {
  123. DECLARE_CLASS_SIMPLE( CDmePresetGroupEditorFrame, vgui::Frame );
  124. public:
  125. CDmePresetGroupEditorFrame( vgui::Panel *pParent, const char *pTitle );
  126. ~CDmePresetGroupEditorFrame();
  127. // Sets the current scene + animation list
  128. void SetAnimationSet( CDmeAnimationSet *pAnimationSet );
  129. // Inherited from IDmNotify
  130. virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  131. private:
  132. MESSAGE_FUNC( OnPresetsChanged, "PresetsChanged" );
  133. MESSAGE_FUNC_PARAMS( OnAddNewPreset, "AddNewPreset", params );
  134. KEYBINDING_FUNC( undo, KEY_Z, vgui::MODIFIER_CONTROL, OnUndo, "#undo_help", 0 );
  135. KEYBINDING_FUNC( redo, KEY_Z, vgui::MODIFIER_CONTROL | vgui::MODIFIER_SHIFT, OnRedo, "#redo_help", 0 );
  136. // Inherited from Frame
  137. virtual void OnCommand( const char *pCommand );
  138. CDmePresetGroupEditorPanel *m_pEditor;
  139. vgui::Button *m_pOkButton;
  140. };
  141. #endif // PRESETGROUPEDITORPANEL_H