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.

223 lines
7.4 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: P.E.T. (Particle Editing Tool); main UI smarts class
  4. //
  5. //=============================================================================
  6. #ifndef PETTOOL_H
  7. #define PETTOOL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/platform.h"
  12. #include "toolutils/basetoolsystem.h"
  13. #include "toolutils/recentfilelist.h"
  14. #include "toolutils/toolmenubar.h"
  15. #include "toolutils/toolswitchmenubutton.h"
  16. #include "toolutils/tooleditmenubutton.h"
  17. #include "toolutils/toolfilemenubutton.h"
  18. #include "toolutils/toolmenubutton.h"
  19. #include "datamodel/dmelement.h"
  20. #include "datamodel/dmehandle.h"
  21. #include "toolframework/ienginetool.h"
  22. #include "toolutils/enginetools_int.h"
  23. #include "toolutils/savewindowpositions.h"
  24. #include "toolutils/toolwindowfactory.h"
  25. #include "movieobjects/dmeparticlesystemdefinition.h"
  26. #include "particles/particles.h"
  27. //-----------------------------------------------------------------------------
  28. // Forward declarations
  29. //-----------------------------------------------------------------------------
  30. class CDmElement;
  31. class CPetDoc;
  32. class CParticleSystemPropertiesContainer;
  33. class CParticleSystemDefinitionBrowser;
  34. class CParticleSystemPreviewPanel;
  35. class CSheetEditorPanel;
  36. class CDmeParticleSystemDefinition;
  37. enum ParticleFunctionType_t;
  38. namespace vgui
  39. {
  40. class Panel;
  41. }
  42. enum
  43. {
  44. NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED = (1<<NOTIFY_FLAG_FIRST_APPLICATION_BIT)
  45. };
  46. //-----------------------------------------------------------------------------
  47. // Allows the doc to call back into the CommEdit editor tool
  48. //-----------------------------------------------------------------------------
  49. abstract_class IPetDocCallback
  50. {
  51. public:
  52. // Called by the doc when the data changes
  53. virtual void OnDocChanged( const char *pReason, int nNotifySource, int nNotifyFlags ) = 0;
  54. };
  55. //-----------------------------------------------------------------------------
  56. // Global methods of the commedit tool
  57. //-----------------------------------------------------------------------------
  58. abstract_class IPetTool
  59. {
  60. public:
  61. // Gets at the rool panel (for modal dialogs)
  62. virtual vgui::Panel *GetRootPanel() = 0;
  63. // Gets the registry name (for saving settings)
  64. virtual const char *GetRegistryName() = 0;
  65. };
  66. //-----------------------------------------------------------------------------
  67. // Implementation of the CommEdit tool
  68. //-----------------------------------------------------------------------------
  69. class CPetTool : public CBaseToolSystem, public IFileMenuCallbacks, public IPetDocCallback, public IPetTool
  70. {
  71. DECLARE_CLASS_SIMPLE( CPetTool, CBaseToolSystem );
  72. public:
  73. CPetTool();
  74. // Inherited from IToolSystem
  75. virtual const char *GetToolName() { return "Particle Editor"; }
  76. virtual bool Init( );
  77. virtual void Shutdown();
  78. virtual bool CanQuit( const char *pExitMsg );
  79. virtual void OnToolActivate();
  80. virtual void OnToolDeactivate();
  81. virtual void Think( bool finalTick );
  82. // Inherited from IFileMenuCallbacks
  83. virtual int GetFileMenuItemsEnabled( );
  84. virtual void AddRecentFilesToMenu( vgui::Menu *menu );
  85. virtual bool GetPerforceFileName( char *pFileName, int nMaxLen );
  86. // Inherited from IPetDocCallback
  87. virtual void OnDocChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  88. virtual vgui::Panel *GetRootPanel() { return this; }
  89. // Inherited from CBaseToolSystem
  90. virtual vgui::HScheme GetToolScheme();
  91. virtual vgui::Menu *CreateActionMenu( vgui::Panel *pParent );
  92. virtual void OnCommand( const char *cmd );
  93. virtual const char *GetRegistryName() { return "PetTool"; }
  94. virtual const char *GetBindingsContextFile() { return "cfg/Pet.kb"; }
  95. virtual vgui::MenuBar *CreateMenuBar( CBaseToolSystem *pParent );
  96. MESSAGE_FUNC( Save, "OnSave" );
  97. void SaveAndTest();
  98. void PreOperatorsPaste();
  99. public:
  100. MESSAGE_FUNC( OnRestartLevel, "RestartLevel" );
  101. MESSAGE_FUNC( OnNew, "OnNew" );
  102. MESSAGE_FUNC( OnOpen, "OnOpen" );
  103. MESSAGE_FUNC( OnSaveAs, "OnSaveAs" );
  104. MESSAGE_FUNC( OnClose, "OnClose" );
  105. MESSAGE_FUNC( OnCloseNoSave, "OnCloseNoSave" );
  106. MESSAGE_FUNC( OnMarkNotDirty, "OnMarkNotDirty" );
  107. MESSAGE_FUNC( OnExit, "OnExit" );
  108. MESSAGE_FUNC( OnCopySystems, "OnCopySystems" );
  109. MESSAGE_FUNC( OnCopyFunctions, "OnCopyFunctions" );
  110. MESSAGE_FUNC( OnPaste, "OnPaste" );
  111. MESSAGE_FUNC( OnRequestPaste, "RequestPaste" );
  112. // Commands related to the edit menu
  113. void OnDescribeUndo();
  114. // Methods related to the view menu
  115. MESSAGE_FUNC( OnToggleProperties, "OnToggleProperties" );
  116. MESSAGE_FUNC( OnToggleParticleSystemBrowser, "OnToggleParticleSystemBrowser" );
  117. MESSAGE_FUNC( OnToggleParticlePreview, "OnToggleParticlePreview" );
  118. // MESSAGE_FUNC( OnToggleSheetEditor, "OnToggleSheetEditor" );
  119. MESSAGE_FUNC( OnDefaultLayout, "OnDefaultLayout" );
  120. // Keybindings
  121. KEYBINDING_FUNC( undo, KEY_Z, vgui::MODIFIER_CONTROL, OnUndo, "#undo_help", 0 );
  122. KEYBINDING_FUNC( redo, KEY_Z, vgui::MODIFIER_CONTROL | vgui::MODIFIER_SHIFT, OnRedo, "#redo_help", 0 );
  123. KEYBINDING_FUNC_NODECLARE( edit_paste, KEY_V, vgui::MODIFIER_CONTROL, OnPaste, "#edit_paste_help", 0 );
  124. void PerformNew();
  125. void OpenFileFromHistory( int slot );
  126. void OpenSpecificFile( const char *pFileName );
  127. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
  128. virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  129. virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
  130. virtual void OnFileOperationCompleted( const char *pFileType, bool bWroteFile, vgui::FileOpenStateMachine::CompletionState_t state, KeyValues *pContextKeyValues );
  131. // returns the document
  132. CPetDoc *GetDocument();
  133. // Gets at tool windows
  134. CParticleSystemPropertiesContainer *GetProperties();
  135. CParticleSystemDefinitionBrowser *GetParticleSystemDefinitionBrowser();
  136. CParticleSystemPreviewPanel *GetParticlePreview();
  137. // CSheetEditorPanel *GetSheetEditor();
  138. void SetCurrentParticleSystem( CDmeParticleSystemDefinition *pParticleSystem, bool bForceBrowserSelection = true );
  139. CDmeParticleSystemDefinition* GetCurrentParticleSystem( void );
  140. private:
  141. // Creates a new document
  142. void NewDocument( );
  143. // Loads up a new document
  144. bool LoadDocument( const char *pDocName );
  145. // Updates the menu bar based on the current file
  146. void UpdateMenuBar( );
  147. virtual const char *GetLogoTextureName();
  148. // Creates, destroys tools
  149. void CreateTools( CPetDoc *doc );
  150. void DestroyTools();
  151. // Initializes the tools
  152. void InitTools();
  153. // Shows, toggles tool windows
  154. void ToggleToolWindow( Panel *tool, char const *toolName );
  155. void ShowToolWindow( Panel *tool, char const *toolName, bool visible );
  156. // Kills all tool windows
  157. void DestroyToolContainers();
  158. private:
  159. // Document
  160. CPetDoc *m_pDoc;
  161. // The menu bar
  162. CToolFileMenuBar *m_pMenuBar;
  163. // Element properties for editing material
  164. vgui::DHANDLE< CParticleSystemPropertiesContainer > m_hProperties;
  165. // The entity report
  166. vgui::DHANDLE< CParticleSystemDefinitionBrowser > m_hParticleSystemDefinitionBrowser;
  167. // Particle preview window
  168. vgui::DHANDLE< CParticleSystemPreviewPanel > m_hParticlePreview;
  169. // Sheet editor
  170. // vgui::DHANDLE< CSheetEditorPanel > m_hSheetEditorPanel;
  171. // The currently viewed entity
  172. CDmeHandle< CDmeParticleSystemDefinition > m_hCurrentParticleSystem;
  173. // Separate undo context for the act busy tool
  174. CToolWindowFactory< ToolWindow > m_ToolWindowFactory;
  175. };
  176. extern CPetTool *g_pPetTool;
  177. #endif // PETTOOL_H