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.

171 lines
6.4 KiB

  1. //========= Copyright � 1996-2001, Valve LLC, 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 CDmeFilmClip;
  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. void SetAnimationSetClip( CDmeFilmClip *pFilmClip );
  41. CDmeFilmClip *GetAnimationSetClip();
  42. void RefreshAnimationSet();
  43. void NotifyDataChanged();
  44. // Returns selected presets/groups
  45. const char* GetSelectedPresetGroupName();
  46. const char* GetSelectedPresetName();
  47. // Drag/drop reordering of preset groups
  48. void MovePresetGroupInFrontOf( const char *pDragGroupName, const char *pDropGroupName );
  49. // Drag/drop reordering of presets
  50. void MovePresetInFrontOf( const char *pDragPresetName, const char *pDropPresetName );
  51. // Drag/drop preset moving
  52. void MovePresetIntoGroup( const char *pPresetName, const char *pSrcGroupName, const char *pDstGroupName );
  53. // Toggle group visibility
  54. void ToggleGroupVisibility( const char *pPresetGroupName );
  55. MESSAGE_FUNC( OnMovePresetUp, "MovePresetUp" );
  56. MESSAGE_FUNC( OnMovePresetDown, "MovePresetDown" );
  57. MESSAGE_FUNC( OnMoveGroupUp, "MoveGroupUp" );
  58. MESSAGE_FUNC( OnMoveGroupDown, "MoveGroupDown" );
  59. MESSAGE_FUNC( OnRemoveGroup, "RemoveGroup" );
  60. MESSAGE_FUNC( OnRemovePreset, "RemovePreset" );
  61. // Inherited from IFileOpenStateMachineClient
  62. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
  63. virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  64. virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  65. private:
  66. MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", kv );
  67. MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
  68. MESSAGE_FUNC( OnAddGroup, "AddGroup" );
  69. MESSAGE_FUNC( OnAddPhonemeGroup, "AddPhonemeGroup" );
  70. MESSAGE_FUNC( OnRenameGroup, "RenameGroup" );
  71. MESSAGE_FUNC( OnRemoveDefaultControls, "RemoveDefaultControls" );
  72. MESSAGE_FUNC( OnRenamePreset, "RenamePreset" );
  73. MESSAGE_FUNC( OnToggleGroupVisibility, "ToggleGroupVisibility" );
  74. MESSAGE_FUNC( OnToggleGroupSharing, "ToggleGroupSharing" );
  75. MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
  76. MESSAGE_FUNC_PARAMS( OnItemDeselected, "ItemDeselected", kv );
  77. MESSAGE_FUNC( OnImportPresets, "ImportPresets" );
  78. MESSAGE_FUNC( OnExportPresets, "ExportPresets" );
  79. MESSAGE_FUNC( OnImportPresetGroups, "ImportPresetGroups" );
  80. MESSAGE_FUNC( OnExportPresetGroups, "ExportPresetGroups" );
  81. MESSAGE_FUNC( OnExportPresetGroupToVFE, "ExportPresetGroupsToVFE" );
  82. MESSAGE_FUNC( OnExportPresetGroupToTXT, "ExportPresetGroupsToTXT" );
  83. MESSAGE_FUNC_PARAMS( OnPresetPicked, "PresetPicked", params );
  84. MESSAGE_FUNC_PARAMS( OnPresetPickCancelled, "PresetPickCancelled", params );
  85. MESSAGE_FUNC_PARAMS( OnFileStateMachineFinished, "FileStateMachineFinished", params );
  86. // Cleans up the context menu
  87. void CleanupContextMenu();
  88. // If it finds a duplicate group/preset name, reports an error message and returns it found one
  89. bool HasDuplicatePresetName( const char *pPresetName, const char *pIgnorePresetName = NULL );
  90. bool HasDuplicateGroupName ( const char *pGroupName, const char *pIgnorePresetGroupName = NULL );
  91. // Refreshes the list of presets
  92. void RefreshPresetNames( );
  93. // Called by OnInputCompleted after we get a new group or preset name
  94. void PerformAddGroup( const char *pNewGroupName );
  95. void PerformAddPhonemeGroup( const char *pNewGroupName );
  96. void PerformRenameGroup( const char *pNewGroupName );
  97. void PerformRenamePreset( const char *pNewPresetName );
  98. // Called to open a context-sensitive menu for a particular preset
  99. void OnOpenPresetContextMenu( );
  100. // Gets/sets a selected preset
  101. void SetSelectedPreset( const char* pPresetName );
  102. // Selects a particular preset group
  103. void SetSelectedPresetGroup( const char* pPresetGroupName );
  104. // Imports presets
  105. void ImportPresets( CUtlVector< const char * >& presetNames, CDmElement *pRoot );
  106. CDmeHandle< CDmeFilmClip > m_hFilmClip;
  107. vgui::Splitter *m_pSplitter;
  108. CDmePresetGroupListPanel *m_pPresetGroupList;
  109. CDmePresetListPanel *m_pPresetList;
  110. vgui::DHANDLE< vgui::Menu > m_hContextMenu;
  111. vgui::DHANDLE< vgui::FileOpenStateMachine > m_hFileOpenStateMachine;
  112. };
  113. //-----------------------------------------------------------------------------
  114. // Frame for combination system
  115. //-----------------------------------------------------------------------------
  116. class CDmePresetGroupEditorFrame : public vgui::Frame, public IDmNotify
  117. {
  118. DECLARE_CLASS_SIMPLE( CDmePresetGroupEditorFrame, vgui::Frame );
  119. public:
  120. CDmePresetGroupEditorFrame( vgui::Panel *pParent, const char *pTitle );
  121. ~CDmePresetGroupEditorFrame();
  122. // Inherited from IDmNotify
  123. virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  124. void SetAnimationSetClip( CDmeFilmClip *pClip ) { m_pEditor->SetAnimationSetClip( pClip ); }
  125. void RefreshAnimationSet() { m_pEditor->RefreshAnimationSet(); }
  126. private:
  127. MESSAGE_FUNC( OnPresetsChanged, "PresetsChanged" );
  128. KEYBINDING_FUNC( undo, KEY_Z, vgui::MODIFIER_CONTROL, OnUndo, "#undo_help", 0 );
  129. KEYBINDING_FUNC( redo, KEY_Z, vgui::MODIFIER_CONTROL | vgui::MODIFIER_SHIFT, OnRedo, "#redo_help", 0 );
  130. // Inherited from Frame
  131. virtual void OnCommand( const char *pCommand );
  132. CDmePresetGroupEditorPanel *m_pEditor;
  133. vgui::Button *m_pOkButton;
  134. };
  135. #endif // PRESETGROUPEDITORPANEL_H