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.

162 lines
5.2 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #ifndef MANIFEST_H
  7. #define MANIFEST_H
  8. #pragma once
  9. #include "KeyValues.h"
  10. #include "UtlVector.h"
  11. #include "MapDoc.h"
  12. class BoundBox;
  13. class CSelection;
  14. class CMapWorld;
  15. class CManifestInstance;
  16. typedef struct SManifestLoadPrefs TManifestLoadPrefs;
  17. class CManifestMap
  18. {
  19. public:
  20. CManifestMap( void );
  21. bool IsEditable( void );
  22. CMapDoc *m_Map;
  23. CString m_RelativeMapFileName, m_AbsoluteMapFileName;
  24. CString m_FriendlyName;
  25. bool m_bTopLevelMap;
  26. bool m_bReadOnly;
  27. bool m_bIsVersionControlled;
  28. bool m_bCheckedOut;
  29. bool m_bDefaultCheckin;
  30. int m_InternalID;
  31. CManifestInstance *m_Entity;
  32. // user prefs ( which don't impact the bsp process )
  33. bool m_bVisible;
  34. bool m_bPrimaryMap;
  35. bool m_bProtected;
  36. };
  37. class CManifestInstance : public CMapEntity
  38. {
  39. public:
  40. DECLARE_MAPCLASS( CManifestInstance, CMapEntity )
  41. CManifestInstance( void );
  42. CManifestInstance( CManifestMap *pManifestMap );
  43. virtual bool IsEditable( void );
  44. CManifestMap *GetManifestMap( void ) { return m_pManifestMap; }
  45. private:
  46. CManifestMap *m_pManifestMap;
  47. };
  48. class CManifest : public CMapDoc
  49. {
  50. friend class CManifestCheckin;
  51. protected:
  52. DECLARE_DYNCREATE(CManifest)
  53. public:
  54. CManifest( void );
  55. ~CManifest( void );
  56. static ChunkFileResult_t LoadKeyInfoCallback( const char *szKey, const char *szValue, CManifest *pDoc );
  57. static ChunkFileResult_t LoadManifestInfoCallback( CChunkFile *pFile, CManifest *pDoc );
  58. static ChunkFileResult_t LoadKeyCallback( const char *szKey, const char *szValue, CManifestMap *pManifestMap );
  59. static ChunkFileResult_t LoadManifestVMFCallback( CChunkFile *pFile, CManifest *pDoc );
  60. static ChunkFileResult_t LoadManifestMapsCallback( CChunkFile *pFile, CManifest *pDoc );
  61. static ChunkFileResult_t LoadKeyPrefsCallback( const char *szKey, const char *szValue, TManifestLoadPrefs *pManifestLoadPrefs );
  62. static ChunkFileResult_t LoadManifestVMFPrefsCallback( CChunkFile *pFile, CManifest *pDoc );
  63. static ChunkFileResult_t LoadManifestMapsPrefsCallback( CChunkFile *pFile, CManifest *pDoc );
  64. static ChunkFileResult_t LoadManifestCordoningPrefsCallback( CChunkFile *pFile, CManifest *pDoc );
  65. bool Load( const char *pszFileName );
  66. bool Save( const char *pszFileName, bool bForce );
  67. bool IsValid( void ) { return m_bIsValid; }
  68. virtual void Initialize( void );
  69. virtual void Update( void );
  70. virtual void SetModifiedFlag( BOOL bModified = TRUE );
  71. virtual bool IsManifest( void ) { return true; }
  72. void GetFullMapPath( const char *pManifestMapFileName, char *pOutputPath );
  73. void SetManifestPrefsModifiedFlag( bool bModified = true );
  74. int GetNumMaps( void ) { return m_Maps.Count(); }
  75. CManifestMap *GetMap( int index ) { return m_Maps[ index ]; }
  76. CManifestMap *FindMap( CMapDoc *pMap );
  77. CManifestMap *FindMapByID( int InternalID );
  78. void SetPrimaryMap( CManifestMap *pManifestMap );
  79. CManifestMap *GetPrimaryMap( void ) { return m_pPrimaryMap; }
  80. void SetVisibility( CManifestMap *pManifestMap, bool bIsVisible );
  81. void MoveSelectionToSubmap( CManifestMap *pManifestMap, bool CenterContents );
  82. CManifestMap *MoveSelectionToNewSubmap( CString &FriendlyName, CString &FileName, bool CenterContents );
  83. CManifestMap *CreateNewMap( const char *AbsoluteFileName, const char *RelativeFileName, bool bSetID );
  84. CManifestMap *AddNewSubmap( CString &FriendlyName, CString &FileName );
  85. bool AddExistingMap( const char *pszFileName, bool bFromInstance );
  86. bool AddExistingMap( void );
  87. bool RemoveSubMap( CManifestMap *pManifestMap );
  88. bool CheckOut( );
  89. bool AddToVersionControl( );
  90. void CheckFileStatus( );
  91. CSelection *GetSelection( void ) { return m_pSelection; }
  92. void ClearSelection( void );
  93. virtual void UpdateInstanceMap( CMapDoc *pInstanceMapDoc );
  94. virtual void AddObjectToWorld(CMapClass *pObject, CMapClass *pParent = NULL);
  95. CMapWorld *GetManifestWorld( void ) { return m_ManifestWorld; }
  96. bool m_bReadOnly;
  97. bool m_bIsVersionControlled;
  98. bool m_bCheckedOut;
  99. bool m_bDefaultCheckin;
  100. protected:
  101. virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  102. virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
  103. virtual void DeleteContents( void );
  104. private:
  105. void AddManifestObjectToWorld( CMapClass *pObject, CMapClass *pParent = NULL );
  106. void RemoveManifestObjectFromWorld( CMapClass *pObject, bool bRemoveChildren );
  107. bool LoadVMFManifest( const char *pszFileName );
  108. bool LoadVMFManifestUserPrefs( const char *pszFileName );
  109. bool SaveVMFManifest( const char *pszFileName );
  110. bool SaveVMFManifestMaps( const char *pszFileName );
  111. bool SaveVMFManifestUserPrefs( const char *pszFileName );
  112. int m_NextInternalID;
  113. bool m_bIsValid;
  114. bool m_bRelocateSave;
  115. CUtlVector< CManifestMap * > m_Maps;
  116. CManifestMap *m_pPrimaryMap;
  117. char m_ManifestDir[ MAX_PATH ];
  118. CMenu m_ManifestMenu;
  119. CMapWorld *m_ManifestWorld;
  120. bool m_bManifestChanged, m_bManifestUserPrefsChanged;
  121. CHistory *m_pSaveUndo;
  122. CHistory *m_pSaveRedo;
  123. protected:
  124. //{{AFX_MSG(CMapDoc)
  125. afx_msg void OnFileSaveAs();
  126. //}}AFX_MSG
  127. public:
  128. DECLARE_MESSAGE_MAP()
  129. };
  130. #endif // #define MANIFEST_H