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.

124 lines
3.9 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef PETDOC_H
  9. #define PETDOC_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "dme_controls/inotifyui.h"
  14. #include "datamodel/dmehandle.h"
  15. #include "datamodel/dmelement.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class IPetDocCallback;
  20. class CPetDoc;
  21. class CDmeParticleSystemDefinition;
  22. //-----------------------------------------------------------------------------
  23. // The file format for particle system definitions
  24. //-----------------------------------------------------------------------------
  25. #define PET_FILE_FORMAT "pcf"
  26. typedef CDmrElementArray<CDmeParticleSystemDefinition> CDmrParticleSystemList;
  27. //-----------------------------------------------------------------------------
  28. // Contains all editable state
  29. //-----------------------------------------------------------------------------
  30. class CPetDoc : public IDmNotify, CBaseElementPropertiesChoices
  31. {
  32. public:
  33. CPetDoc( IPetDocCallback *pCallback );
  34. ~CPetDoc();
  35. // Inherited from INotifyUI
  36. virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  37. virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement,
  38. const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list );
  39. // Sets/Gets the file name
  40. const char *GetFileName();
  41. void SetFileName( const char *pFileName );
  42. // Dirty bits (has it changed since the last time it was saved?)
  43. void SetDirty( bool bDirty );
  44. bool IsDirty() const;
  45. // Creates a new document
  46. void CreateNew();
  47. // Saves/loads from file
  48. bool LoadFromFile( const char *pFileName );
  49. void SaveToFile( );
  50. // Returns the root object
  51. CDmElement *GetRootObject();
  52. // Returns the root object fileid
  53. DmFileId_t GetFileId();
  54. // Called when data changes (see INotifyUI for flags)
  55. void OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  56. // Returns the particle system definition list
  57. CDmAttribute *GetParticleSystemDefinitionList();
  58. int GetParticleSystemCount( );
  59. CDmeParticleSystemDefinition *GetParticleSystem( int nIndex );
  60. // add a new definition we've created
  61. void AddNewParticleSystemDefinition( CDmeParticleSystemDefinition *pNew,
  62. CUndoScopeGuard &Guard );
  63. // Adds a new particle system definition
  64. CDmeParticleSystemDefinition *AddNewParticleSystemDefinition( const char *pName );
  65. // Deletes a particle system definition
  66. void DeleteParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
  67. // find particle system def by name
  68. CDmeParticleSystemDefinition *FindParticleSystemDefinition( const char *pName );
  69. // Replace any particle system with the same name as the passed-in definition
  70. // with the passed-in definition
  71. void ReplaceParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
  72. // Does a particle system exist already?
  73. bool IsParticleSystemDefined( const char *pName );
  74. // For element choice lists. Return false if it's an unknown choice list type
  75. virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
  76. const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list );
  77. virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
  78. const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list );
  79. // Updates a specific particle defintion
  80. void UpdateParticleDefinition( CDmeParticleSystemDefinition *pDef );
  81. // Update all particle definitions
  82. void UpdateAllParticleSystems( );
  83. private:
  84. // Creates the root element
  85. bool CreateRootElement();
  86. IPetDocCallback *m_pCallback;
  87. CDmeHandle< CDmElement > m_hRoot;
  88. char m_pFileName[MAX_PATH];
  89. bool m_bDirty;
  90. };
  91. #endif // PETDOC_H