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.

122 lines
3.8 KiB

  1. //========= Copyright 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. // add a new definition we've created
  59. void AddNewParticleSystemDefinition( CDmeParticleSystemDefinition *pNew,
  60. CUndoScopeGuard &Guard );
  61. // Adds a new particle system definition
  62. CDmeParticleSystemDefinition *AddNewParticleSystemDefinition( const char *pName );
  63. // Deletes a particle system definition
  64. void DeleteParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
  65. // find particle system def by name
  66. CDmeParticleSystemDefinition *FindParticleSystemDefinition( const char *pName );
  67. // Replace any particle system with the same name as the passed-in definition
  68. // with the passed-in definition
  69. void ReplaceParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
  70. // Does a particle system exist already?
  71. bool IsParticleSystemDefined( const char *pName );
  72. // For element choice lists. Return false if it's an unknown choice list type
  73. virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
  74. const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list );
  75. virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
  76. const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list );
  77. // Updates a specific particle defintion
  78. void UpdateParticleDefinition( CDmeParticleSystemDefinition *pDef );
  79. // Update all particle definitions
  80. void UpdateAllParticleSystems( );
  81. private:
  82. // Creates the root element
  83. bool CreateRootElement();
  84. IPetDocCallback *m_pCallback;
  85. CDmeHandle< CDmElement > m_hRoot;
  86. char m_pFileName[MAX_PATH];
  87. bool m_bDirty;
  88. };
  89. #endif // PETDOC_H