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.

83 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef FOUNDRYDOC_H
  9. #define FOUNDRYDOC_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "dme_controls/inotifyui.h"
  14. #include "datamodel/dmehandle.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class IFoundryDocCallback;
  19. class CDmeVMFEntity;
  20. //-----------------------------------------------------------------------------
  21. // Contains all editable state
  22. //-----------------------------------------------------------------------------
  23. class CFoundryDoc : public IDmNotify
  24. {
  25. public:
  26. CFoundryDoc( IFoundryDocCallback *pCallback );
  27. ~CFoundryDoc();
  28. // Inherited from INotifyUI
  29. virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  30. // Sets/Gets the file name
  31. const char *GetBSPFileName();
  32. const char *GetVMFFileName();
  33. void SetVMFFileName( const char *pFileName );
  34. // Dirty bits (has it changed since the last time it was saved?)
  35. void SetDirty( bool bDirty );
  36. bool IsDirty() const;
  37. // Saves/loads from file
  38. bool LoadFromFile( const char *pFileName );
  39. void SaveToFile( );
  40. // Returns the root object
  41. CDmElement *GetRootObject();
  42. // Called when data changes (see INotifyUI for flags)
  43. void OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
  44. // Create a text block the engine can parse containing the entity data to spawn
  45. const char* GenerateEntityData( const char *pActualEntityData );
  46. // Returns the entity list
  47. CDmAttribute *GetEntityList();
  48. // Deletes an entity
  49. void DeleteEntity( CDmeVMFEntity *pEntity );
  50. private:
  51. // Always copy the worldspawn and other entities that had data built into them by VBSP out
  52. void AddOriginalEntities( CUtlBuffer &entityBuf, const char *pActualEntityData );
  53. // Copy in other entities from the editable VMF
  54. void AddVMFEntities( CUtlBuffer &entityBuf, const char *pActualEntityData );
  55. IFoundryDocCallback *m_pCallback;
  56. CDmeHandle< CDmElement > m_hRoot;
  57. char m_pBSPFileName[512];
  58. char m_pVMFFileName[512];
  59. bool m_bDirty;
  60. };
  61. #endif // FOUNDRYDOC_H