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.

1178 lines
42 KiB

  1. //========================== Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. ===========================
  2. //
  3. //
  4. //
  5. //======================================================================================================================
  6. #ifndef MAPDOC_H
  7. #define MAPDOC_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cordon.h"
  12. #include "MapClass.h"
  13. #include "Selection.h"
  14. #include "MapEntity.h"
  15. #include "GameConfig.h"
  16. #include "filesystem.h"
  17. #include "tier1/utlrbtree.h"
  18. #include "tier1/utlstack.h"
  19. class CToolManager;
  20. class CMapDoc;
  21. class CGameConfig;
  22. class CHistory;
  23. class CMapGroup;
  24. class CMapView;
  25. class CMapView3D;
  26. class CMapView2D;
  27. class IBSPLighting;
  28. class CRender;
  29. class CManifest;
  30. class CFoW;
  31. class CGridNav;
  32. struct FindEntity_t;
  33. struct FindGroup_t;
  34. struct AddNonSelectedInfo_t;
  35. struct AssetUsageInfo_t;
  36. enum SelectionHandleMode_t;
  37. enum MAPFORMAT;
  38. enum ToolID_t;
  39. enum
  40. {
  41. // hints what recently changed
  42. MAPVIEW_UPDATE_OBJECTS = 0x001, // a world object has changed (pos, size etc)
  43. MAPVIEW_UPDATE_ANIMATION = 0x002, // an object animation has been changed
  44. MAPVIEW_UPDATE_COLOR = 0x004, // an object color has been changed
  45. MAPVIEW_UPDATE_SELECTION = 0x008, // the current selection has changed
  46. MAPVIEW_UPDATE_TOOL = 0x010, // the current tool has been changed
  47. // what views should be updated
  48. MAPVIEW_UPDATE_ONLY_2D = 0x020, // update only 2D views for some reason
  49. MAPVIEW_UPDATE_ONLY_3D = 0x040, // update only 3D views for some reason
  50. MAPVIEW_UPDATE_ONLY_LOGICAL = 0x080, // update only Logical views for some reason
  51. MAPVIEW_OPTIONS_CHANGED = 0x100, // view options has been changed
  52. MAPVIEW_UPDATE_VISGROUP_STATE = 0x200, // a visgroup was hidden or shown.
  53. MAPVIEW_UPDATE_VISGROUP_ALL = 0x400, // a visgroup was created or deleted.
  54. MAPVIEW_RENDER_NOW = 0x800, // bypass the main frame loop and render now
  55. };
  56. // Flags for view2dinfo.wflags
  57. enum
  58. {
  59. VI_ZOOM = 0x01,
  60. VI_CENTER = 0x02
  61. };
  62. // Display modes for instances
  63. enum ShowInstance_t
  64. {
  65. INSTANCES_HIDE = 0, // instance contents are not displayed
  66. INSTANCES_SHOW_TINTED, // instance contents are displayed with a yellowish tint
  67. INSTANCES_SHOW_NORMAL // instance contents are displayed normally
  68. };
  69. enum VMFLoadFlags_t
  70. {
  71. VMF_LOAD_ACTIVATE = 0x01, // loading map should be activated
  72. VMF_LOAD_IS_SUBMAP = 0x02, // loading map is part of an instance / manifest
  73. };
  74. enum SelectCordonFlags_t
  75. {
  76. SELECT_CORDON_FROM_TOOL = 0x01,
  77. SELECT_CORDON_FROM_DIALOG = 0x02,
  78. };
  79. // File state
  80. #define FILE_IS_READ_ONLY 0x01
  81. #define FILE_IS_CHECKED_OUT 0x02
  82. #define FILE_IS_VERSION_CONTROLLED 0x04
  83. typedef struct
  84. {
  85. WORD wFlags;
  86. float fZoom;
  87. Vector ptCenter;
  88. } VIEW2DINFO;
  89. struct ExportDXFInfo_s
  90. {
  91. int nObject;
  92. bool bVisOnly;
  93. CMapWorld *pWorld;
  94. FILE *fp;
  95. };
  96. typedef struct
  97. {
  98. int m_nHammerID;
  99. CMapEntity *m_pEntityFound;
  100. } FindEntityByHammerID_t;
  101. //
  102. // The doc holds a list of objects with dependents that changed since the last render. The list
  103. // must be processed before rendering so that interobject dependencies are resolved.
  104. //
  105. struct NotifyListEntry_t
  106. {
  107. CUtlReference< CMapClass > pObject;
  108. Notify_Dependent_t eNotifyType;
  109. };
  110. //
  111. // To pass as hint to UpdateAllViews.
  112. //
  113. class UpdateBox : public CObject
  114. {
  115. public:
  116. UpdateBox(void) { Objects = NULL; }
  117. CMapObjectList *Objects;
  118. BoundBox Box;
  119. };
  120. // this holds all of the data needed to visualize the level's portal file
  121. struct portalfile_t
  122. {
  123. CString fileName;
  124. int totalVerts;
  125. CUtlVector<Vector> verts;
  126. CUtlVector<int> vertCount;
  127. };
  128. struct UpdateVisibilityData_t
  129. {
  130. CMapDoc *pDoc;
  131. bool bRadiusCullingEnabled;
  132. Vector vecRadiusCullCenter;
  133. float flRadiusCullDistSq;
  134. };
  135. // this is a structure to manage clipboards
  136. class IHammerClipboard
  137. {
  138. protected:
  139. IHammerClipboard(){}
  140. virtual ~IHammerClipboard() {}
  141. public:
  142. static IHammerClipboard *CreateInstance();
  143. public:
  144. virtual void Destroy() = 0;
  145. };
  146. class CMapDoc : public CDocument
  147. {
  148. friend class CManifest;
  149. protected:
  150. DECLARE_DYNCREATE(CMapDoc)
  151. public:
  152. // attribs:
  153. bool m_bSnapToGrid;
  154. bool m_bShowGrid;
  155. bool m_bShowLogicalGrid;
  156. // pointfile stuff:
  157. enum
  158. {
  159. PFPNext = 1,
  160. PFPPrev = -1
  161. };
  162. int m_iCurPFPoint;
  163. CUtlVector<Vector> m_PFPoints;
  164. CString m_strLastPointFile;
  165. portalfile_t *m_pPortalFile;
  166. static inline CMapDoc *GetActiveMapDoc(void);
  167. static void SetActiveMapDoc(CMapDoc *pDoc);
  168. static void ActivateMapDoc( CMapDoc *pDoc );
  169. static inline CManifest *GetManifest( void );
  170. static inline int GetInLevelLoad( );
  171. static void NoteEngineGotFocus();
  172. private:
  173. static CMapDoc *m_pMapDoc;
  174. static CManifest *m_pManifest;
  175. static int m_nInLevelLoad;
  176. public:
  177. CMapDoc(void);
  178. virtual ~CMapDoc();
  179. virtual void Initialize( void );
  180. virtual bool IsManifest( void ) { return false; }
  181. IBSPLighting *GetBSPLighting() { return m_pBSPLighting; }
  182. CToolManager *GetTools() { return m_pToolManager; } // return tools working on this document
  183. CSelection *GetSelection() { return m_pSelection; } // return current selection
  184. void BeginShellSession(void);
  185. void EndShellSession(void);
  186. bool IsShellSessionActive(void);
  187. inline int GetDocVersion(void);
  188. inline void DecrementDocVersion(void);
  189. //
  190. // Interface to the map document. Functions for object creation, deletion, etc.
  191. //
  192. CMapEntity *CreateEntity(const char *pszClassName, float x, float y, float z);
  193. bool DeleteEntity(const char *pszClassName, float x, float y, float z);
  194. CMapEntity *FindEntity(const char *pszClassName, float x, float y, float z);
  195. CMapEntity *FindEntityByName( const char *pszName, bool bVisiblesOnly );
  196. CMapEntity *FindEntityByHammerID( int nHammerID );
  197. bool FindEntitiesByKeyValue(CMapEntityList &Found, const char *szKey, const char *szValue, bool bVisiblesOnly);
  198. bool FindEntitiesByName(CMapEntityList &Found, const char *szName, bool bVisiblesOnly);
  199. bool FindEntitiesByClassName(CMapEntityList &Found, const char *szClassName, bool bVisiblesOnly);
  200. bool FindEntitiesByNameOrClassName(CMapEntityList &Found, const char *pszName, bool bVisiblesOnly);
  201. void GetUsedModels( CUtlVector<AssetUsageInfo_t> &usedModels );
  202. bool CheckOut( );
  203. bool CheckOutBsp( );
  204. bool AddToVersionControl( );
  205. bool SyncToHeadRevision( );
  206. bool SyncBspToHeadRevision( );
  207. bool Revert( );
  208. void CheckFileStatus( );
  209. bool GetBspFileStatus( unsigned char &FileStatus );
  210. bool BspOkToCheckOut();
  211. void GetBspPathFromVmfPath( CUtlString &bspPath );
  212. bool IsReadOnly( ) { return m_bReadOnly; }
  213. bool IsVersionControlled( ) { return m_bIsVersionControlled; }
  214. bool IsCheckedOut( ) { return m_bCheckedOut; }
  215. bool IsDefaultCheckIn( ) { return m_bDefaultCheckin; }
  216. void ClearDefaultCheckIn( ) { m_bDefaultCheckin = false; }
  217. virtual void Update(void);
  218. virtual void SetModifiedFlag(BOOL bModified = TRUE);
  219. void SetAutosaveFlag(BOOL bAutosave = TRUE);
  220. BOOL NeedsAutosave();
  221. BOOL IsAutosave();
  222. CString *AutosavedFrom();
  223. void AddReference( void );
  224. void RemoveReference( void );
  225. int GetReferenceCount( void ) { return m_nExternalReferenceCount; }
  226. // Used to track down a potential crash.
  227. bool AnyNotificationsForObject(CMapClass *pObject);
  228. void SetAnimationTime( float time );
  229. float GetAnimationTime( void ) { return m_flAnimationTime; }
  230. bool IsAnimating( void ) { return m_bIsAnimating; }
  231. // other stuff
  232. float m_flCurrentTime;
  233. void UpdateCurrentTime( void );
  234. float GetTime( void ) { return m_flCurrentTime; }
  235. void GotoPFPoint(int iDirection);
  236. //
  237. // Users can create one or more cordons, which are sets of rectangular boxes that define a volumetric
  238. // visibility region. When a cordon is active, any objects outside the cordon volume are hidden.
  239. //
  240. // Cordons can be named for convenience. When the map is saved with a cordon active, brushes are
  241. // added to the file to seal the cordon volume so that the map compiles without leaks.
  242. //
  243. bool Cordon_SetCordoning( bool bState );
  244. inline bool Cordon_IsCordoning();
  245. inline int Cordon_GetCount();
  246. inline Cordon_t *Cordon_GetCordon( int nIndex );
  247. void Cordon_GetIndices( Cordon_t *pCordon, BoundBox *pBox, int *pnCordon, int *pnBox );
  248. void Cordon_GetBounds( Vector &mins, Vector &maxs );
  249. void Cordon_Activate( int nIndex, bool bActive );
  250. Cordon_t *Cordon_CreateNewCordon( const char *name = NULL, BoundBox **ppBox = NULL );
  251. Cordon_t *Cordon_AddCordon( const char *szName );
  252. BoundBox *Cordon_AddBox( Cordon_t *cordon );
  253. void Cordon_RemoveCordon( Cordon_t *cordon );
  254. void Cordon_RemoveBox( Cordon_t *cordon, BoundBox *box );
  255. void Cordon_CombineCordons( Cordon_t *pSourceCordon, BoundBox *pSourceBox, Cordon_t *pDestCordon );
  256. // We can only edit one of our cordon bounds at a time
  257. Cordon_t *Cordon_GetSelectedCordonForEditing( BoundBox **pBox = NULL );
  258. void Cordon_SelectCordonForEditing( Cordon_t *cordon, BoundBox *box, int nFlags = 0 ); // NULL cordon here means use current edit cordon
  259. void Cordon_GetEditCordon( Vector &mins, Vector &maxs );
  260. void Cordon_SetEditCordon( const Vector &mins, const Vector &maxs );
  261. inline bool Cordon_IsEditCordon( int nCordon, int nBox );
  262. CMapWorld *Cordon_CreateWorld();
  263. CMapWorld *Cordon_AddCordonObjectsToWorld( CMapObjectList &CordonList );
  264. ChunkFileResult_t Cordon_SaveVMF( CChunkFile *pFile, CSaveInfo *pSaveInfo );
  265. CMapWorld *Cordon_AddTempObjectsToWorld( CMapObjectList &CordonList );
  266. bool Cordon_IsCulledByCordon( CMapClass *pObject );
  267. void Cordon_MoveUp( Cordon_t *cordon );
  268. void Cordon_MoveDown( Cordon_t *cordon );
  269. protected:
  270. CUtlVector<Cordon_t> m_Cordons;
  271. bool m_bIsCordoning;
  272. int m_nEditCordon;
  273. int m_nEditCordonBox;
  274. public:
  275. CMapView *GetActiveMapView();
  276. CMapView3D *GetFirst3DView();
  277. void Snap( Vector &pt, int nFlags = 0 );
  278. inline bool IsSnapEnabled();
  279. //
  280. // Face selection for face editing.
  281. //
  282. void SelectFace(CMapSolid *pSolid, int iFace, int cmd);
  283. void UpdateForApplicator(BOOL bApplicator);
  284. void UpdateAnimation( void );
  285. void DeleteObject(CMapClass *pObject);
  286. void DeleteObjectList(CMapObjectList &List);
  287. void InternalEnableLightPreview( bool bCustomFilename );
  288. //
  289. // Object selection:
  290. //
  291. bool SelectObject(CMapClass *pobj, int cmd = scSelect);
  292. void SelectObjectList(const CMapObjectList *pList, int cmd = (scSelect|scClear|scSaveChanges) );
  293. void SelectRegion( BoundBox *pBox, bool bInsideOnly, bool ResetSelection = true );
  294. void SelectLogicalRegion( const Vector2D &vecMins, const Vector2D &vecMaxs, bool bInsideOnly);
  295. // View centering.
  296. void CenterViewsOnSelection();
  297. void CenterViewsOn(const Vector &vec);
  298. void CenterLogicalViewsOnSelection();
  299. void CenterLogicalViewsOn(const Vector2D &vecLogical);
  300. void Center2DViewsOnSelection();
  301. void Center2DViewsOn(const Vector &vec);
  302. void Center3DViewsOnSelection();
  303. void Center3DViewsOn(const Vector &vPos);
  304. void Set3DViewsPosAng( const Vector &vPos, const Vector &vAng );
  305. void GetSelectedCenter(Vector &vCenter);
  306. void ClearEntitySelection();
  307. void GetBestVisiblePoint(Vector &ptOrg);
  308. void GetBestVisibleBox( Vector &vecMins, Vector &vecMaxs );
  309. bool PickTrace( const Vector &vPosition, const Vector &vDirection, Vector *pHitPosition );
  310. bool DropTraceOnDisplacementsAndClips( const Vector &vPosition, Vector *pHitPosition, bool *pHitClip );
  311. void Cut( IHammerClipboard *pClipboard );
  312. void Copy( IHammerClipboard *pClipboard = NULL );
  313. void Paste(CMapObjectList &Objects, CMapWorld *pSourceWorld, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix);
  314. void PasteInstance(CMapObjectList &Objects, CMapWorld *pSourceWorld, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix);
  315. void Paste( IHammerClipboard *pClipboard, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix );
  316. void Delete( void );
  317. // FIXME: refactor these!
  318. void CloneObjects(const CMapObjectList &Objects);
  319. void NudgeObjects(const Vector &Delta, bool bClone);
  320. void GetNudgeVector(const Vector& vHorz, const Vector& vVert, int nChar, bool bSnap, Vector &vecNudge);
  321. void GetBestPastePoint(Vector &vecPasteOrigin, IHammerClipboard *pClipboard);
  322. void UpdateStatusbar();
  323. void UpdateStatusBarSnap();
  324. void SetView2dInfo(VIEW2DINFO& vi);
  325. void SetViewLogicalInfo(VIEW2DINFO& vi);
  326. void SetActiveView(CMapView *pViewActivate);
  327. void SetUndoActive(bool bActive);
  328. void UpdateTitle(CView*);
  329. void CountSolids();
  330. void CountSolids2();
  331. void ReplaceTextures(
  332. LPCTSTR pszFind,
  333. LPCTSTR pszReplace,
  334. BOOL bEverything,
  335. int iAction,
  336. BOOL bHidden,
  337. bool bRescaleTextureCoordinates);
  338. void BatchReplaceTextures( FileHandle_t fp );
  339. bool Is3DGridEnabled(void) { return(m_bShow3DGrid); }
  340. ShowInstance_t GetShowInstance( void ) { return m_tShowInstance; }
  341. void ReleaseVideoMemory( );
  342. inline MAPFORMAT GetMapFormat(void);
  343. inline CMapWorld *GetMapWorld(void);
  344. inline CGameConfig *GetGame(void);
  345. inline int GetGridSpacing(void) { return(max(m_nGridSpacing, 1)); }
  346. inline CGridNav *GetGridNav(void);
  347. inline CHistory *GetDocHistory(void);
  348. inline int GetNextMapObjectID(void);
  349. inline int GetNextLoadID(); // PORTAL2 SHIP: keep track of load order to preserve it on save so that maps can be diffed.
  350. inline int GetNextNodeID(void);
  351. inline void SetNextNodeID(int nID);
  352. static int GetDocumentCount();
  353. static CMapDoc *GetDocument(int index);
  354. void SetMRU(CMapView2D *pView);
  355. void RemoveMRU(CMapView2D *pView);
  356. CUtlVector<CMapView2D*> MRU2DViews;
  357. // if theres anything the document whats to show, do it in RenderDocument()
  358. void RenderDocument(CRender *pRender);
  359. void RenderAllViews(void);
  360. BOOL SelectDocType(void);
  361. BOOL SaveModified(void);
  362. // Set edit prefab mode.
  363. void EditPrefab3D(DWORD dwPrefabID);
  364. //
  365. // Call these when modifying the document contents.
  366. //
  367. virtual void AddObjectToWorld(CMapClass *pObject, CMapClass *pParent = NULL);
  368. BOOL FindObject(CMapClass *pObject);
  369. void RemoveObjectFromWorld(CMapClass *pMapClass, bool bNotifyChildren);
  370. void RenderPreloadObject(CMapClass *pObject);
  371. void UpdateObject(CMapClass *pMapClass);
  372. void UpdateVisibilityAll(void);
  373. void UpdateVisibility(CMapClass *pObject);
  374. void NotifyDependents(CMapClass *pObject, Notify_Dependent_t eNotifyType);
  375. // Radius culling
  376. bool IsCulledBy3DCameraDistance( CMapClass *pObject, UpdateVisibilityData_t *pData );
  377. //
  378. // Morph tool.
  379. //
  380. void Morph_SelectObject(CMapSolid *pSolid, unsigned int uCmd);
  381. void Morph_GetBounds(Vector &mins, Vector &maxs, bool bReset);
  382. int Morph_GetObjectCount(void);
  383. CSSolid *Morph_GetFirstObject(POSITION &pos);
  384. CSSolid *Morph_GetNextObject(POSITION &pos);
  385. //
  386. inline bool IsDispSolidDrawMask( void ) { return m_bDispSolidDrawMask; }
  387. inline void SetDispDrawWalkable( bool bValue ) { m_bDispDrawWalkable = bValue; }
  388. inline bool IsDispDrawWalkable( void ) { return m_bDispDrawWalkable; }
  389. inline bool IsDispDraw3D() { return m_bDispDraw3D; }
  390. inline void SetDispDrawBuildable( bool bValue ) { m_bDispDrawBuildable = bValue; }
  391. inline bool IsDispDrawBuildable( void ) { return m_bDispDrawBuildable; }
  392. inline bool IsDispDrawRemovedVerts( void ) { return m_bDispDrawRemovedVerts; }
  393. inline void SetDispDrawRemovedVerts( bool bValue ) { m_bDispDrawRemovedVerts = bValue; }
  394. //
  395. // List of VisGroups.
  396. //
  397. void ShowNewVisGroupsDialog(CMapObjectList &Objects, bool bUnselectObjects);
  398. void VisGroups_CreateNamedVisGroup(CMapObjectList &Objects, const char *szName, bool bHide, bool bRemoveFromOtherVisGroups);
  399. void VisGroups_AddObjectsToVisGroup(CMapObjectList &Objects, CVisGroup *pVisGroup, bool bHide, bool bRemoveFromOtherVisGroups);
  400. CVisGroup *VisGroups_AddGroup(CVisGroup *pGroup);
  401. bool VisGroups_ObjectCanBelongToVisGroup(CMapClass *pObject);
  402. CVisGroup *VisGroups_AddGroup(LPCTSTR pszName, bool bAuto = false);
  403. static BOOL VisGroups_CheckForGroupCallback(CMapClass *pObject, CVisGroup *pGroup);
  404. int VisGroups_GetCount();
  405. CVisGroup *VisGroups_GetVisGroup(int nIndex);
  406. int VisGroups_GetRootCount();
  407. CVisGroup *VisGroups_GetRootVisGroup(int nIndex);
  408. CVisGroup *VisGroups_GroupForID(DWORD id);
  409. CVisGroup *VisGroups_GroupForName( const char *pszName, bool bIsAuto );
  410. void VisGroups_PurgeGroups();
  411. void VisGroups_MoveUp(CVisGroup *pGroup);
  412. void VisGroups_MoveDown(CVisGroup *pGroup);
  413. void VisGroups_ShowVisGroup(CVisGroup *pGroup, bool bShow);
  414. void VisGroups_UpdateAll();
  415. void VisGroups_UpdateForObject(CMapClass *pObject);
  416. void VisGroups_SetParent(CVisGroup *pVisGroup, CVisGroup *pNewParent);
  417. bool VisGroups_CanMoveUp(CVisGroup *pGroup);
  418. bool VisGroups_CanMoveDown(CVisGroup *pGroup);
  419. void VisGroups_RemoveGroup(CVisGroup *pGroup);
  420. void VisGroups_CombineGroups(CVisGroup *pFrom, CVisGroup *pTo);
  421. bool VisGroups_LockUpdates( bool bLock );
  422. void VisGroups_CheckMemberVisibility(CVisGroup *pGroup);
  423. // Quick Hide
  424. void QuickHide_HideObjects( void );
  425. void QuickHide_HideUnselectedObjects( void );
  426. void QuickHide_Unhide( void );
  427. bool QuickHide_IsObjectHidden( CMapClass *pObject );
  428. ChunkFileResult_t QuickHide_SaveVMF( CChunkFile *pFile, CSaveInfo *pSaveInfo );
  429. CUtlVector< CMapClass* > m_QuickHideGroup;
  430. CUtlVector< CMapClass* > m_QuickHideGroupedParents;
  431. // Default logical placement for new entities
  432. void GetDefaultNewLogicalPosition( Vector2D &vecPosition );
  433. // Fog of War
  434. CFoW *GetFoW( void ) { return m_pFoW; }
  435. private:
  436. void VisGroups_Validate();
  437. void VisGroups_UpdateParents();
  438. void VisGroups_UnlinkGroup(CVisGroup *pGroup);
  439. void VisGroups_DoRemoveOrCombine(CVisGroup *pFrom, CVisGroup *pTo);
  440. bool FindNotification(CMapClass *pObject, Notify_Dependent_t eNotifyType);
  441. protected:
  442. // ClassWizard generated virtual function overrides
  443. //{{AFX_VIRTUAL(CMapDoc)
  444. public:
  445. virtual BOOL OnNewDocument();
  446. virtual void DeleteContents();
  447. virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  448. virtual void OnCloseDocument(void);
  449. virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
  450. //}}AFX_VIRTUAL
  451. BOOL Serialize(std::fstream &file, BOOL fIsStoring, BOOL bRMF);
  452. // Save a VMF file. saveFlags is a combination of SAVEFLAGS_ defines.
  453. bool SaveVMF(const char *pszFileName, int saveFlags );
  454. void PreloadDocument();
  455. bool LoadVMF( const char *pszFileName, int LoadFlags = VMF_LOAD_ACTIVATE );
  456. void PostloadDocument(const char *pszFileName);
  457. inline bool IsLoading(void);
  458. inline void SetInitialUpdate( void ) { m_bHasInitialUpdate = true; }
  459. inline bool HasInitialUpdate( void ) { return m_bHasInitialUpdate; }
  460. // manifest routines
  461. void SetManifest( CManifest *pManifest );
  462. void SetEditable( bool IsEditable ) { m_bIsEditable = IsEditable; }
  463. bool IsEditable( void ) { return m_bIsEditable; }
  464. bool IsSelectionEditable( void );
  465. bool CreateNewManifest( void );
  466. CMapWorld *GetCurrentWorld( void );
  467. int GetClipboardCount( void );
  468. void ManifestPaste( CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix );
  469. virtual void UpdateInstanceMap( CMapDoc *pInstanceMapDoc );
  470. bool CollapseInstance( CMapEntity *pEntity, int &InstanceCount );
  471. void CollapseInstances( bool bOnlySelected );
  472. void CollapseInstancesRecursive( bool bOnlySelected );
  473. void PopulateInstanceParms_r( CMapEntity *pEntity, const CMapObjectList *pChildren, CUtlVector< CString > &ParmList );
  474. void PopulateInstanceParms( CMapEntity *pEntity );
  475. void PopulateInstance( CMapEntity *pEntity );
  476. void InstanceMoved( void );
  477. void ShowWindow( bool bIsVisible );
  478. bool IsVisible( void );
  479. void BuildAllDetailObjects();
  480. void ExpandObjectKeywords(CMapClass *pObject, CMapWorld *pWorld);
  481. #ifdef _DEBUG
  482. virtual void AssertValid() const;
  483. virtual void Dump(CDumpContext& dc) const;
  484. #endif
  485. void UpdateAllCameras(const Vector *vecViewPos, const Vector *vecLookAt, const float *fZoom);
  486. void UpdateAllViews(int nFlags, UpdateBox *ub = NULL );
  487. void SetSmoothingGroupVisual( int iGroup ) { m_SmoothingGroupVisual = iGroup; }
  488. int GetSmoothingGroupVisual( void ) { return m_SmoothingGroupVisual; }
  489. void AddToAutoVisGroup( CMapClass *pObject );
  490. void AddToAutoVisGroup( CMapClass *pObject, const char *pAutoVisGroup );
  491. void AddAutoVisGroup( const char *pAutoVisGroup, const char *pParentName );
  492. void AddChildGroupToAutoVisGroup( CMapClass *pObject, const char *pAutoVisGroup, const char *pParentName );
  493. void RemoveFromAutoVisGroups( CMapClass *pObject );
  494. void AddToFGDAutoVisGroups( CMapClass *pObject );
  495. // Builds a list of all objects which are connected to outputs of pObj
  496. void BuildCascadingSelectionList( CMapClass *pObj, CUtlRBTree< CMapClass*, unsigned short > &list, bool bRecursive );
  497. void Public_SaveMap() { OnFileSave(); }
  498. protected:
  499. void AssignAllToAutoVisGroups();
  500. CVisGroup *GetRootAutoVisGroup();
  501. // Tools:
  502. CToolManager *m_pToolManager;
  503. int m_nGridSpacing;
  504. bool m_bDispSolidDrawMask;
  505. bool m_bDispDrawWalkable;
  506. bool m_bDispDraw3D;
  507. bool m_bDispDrawBuildable;
  508. bool m_bDispDrawRemovedVerts;
  509. bool m_bHasInitialUpdate;
  510. bool m_bLoading; // Set to true while we are being loaded from VMF.
  511. bool m_bReadOnly;
  512. bool m_bIsVersionControlled;
  513. bool m_bCheckedOut;
  514. bool m_bDefaultCheckin;
  515. bool m_bDeferredSave; // Used when deferring a re-save of the map while loading is occurring
  516. static BOOL GetBrushNumberCallback(CMapClass *pObject, void *pFindInfo);
  517. //
  518. // Serialization.
  519. //
  520. ChunkFileResult_t SaveVersionInfoVMF(CChunkFile *pFile, bool bIsAutosave = false);
  521. ChunkFileResult_t VisGroups_SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
  522. ChunkFileResult_t SaveViewSettingsVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
  523. static bool HandleLoadError(CChunkFile *pFile, const char *szChunkName, ChunkFileResult_t eError, CMapDoc *pDoc);
  524. // Cordon loading.
  525. static ChunkFileResult_t LoadCordonsCallback( CChunkFile *pFile, CMapDoc *pDoc );
  526. static ChunkFileResult_t LoadCordonsKeyCallback( const char *pszKey, const char *pszValue, CMapDoc *pDoc );
  527. static ChunkFileResult_t LoadCordonCallback(CChunkFile *pFile, CMapDoc *pDoc);
  528. static ChunkFileResult_t LoadCordonKeyCallback(const char *pszKey, const char *pszValue, Cordon_t *pCordon);
  529. static ChunkFileResult_t LoadCordonBoxCallback( CChunkFile *pFile, Cordon_t *pCordon );
  530. static ChunkFileResult_t LoadCordonBoxKeyCallback(const char *pszKey, const char *pszValue, BoundBox *pBox );
  531. static ChunkFileResult_t LoadCordonCallback_Legacy( CChunkFile *pFile, CMapDoc *pDoc );
  532. static ChunkFileResult_t LoadCordonKeyCallback_Legacy( const char *pszKey, const char *pszValue, CMapDoc *pDoc );
  533. static ChunkFileResult_t LoadEntityCallback(CChunkFile *pFile, CMapDoc *pDoc);
  534. static ChunkFileResult_t LoadHiddenCallback(CChunkFile *pFile, CMapDoc *pDoc);
  535. static ChunkFileResult_t LoadGroupKeyCallback(const char *szKey, const char *szValue, CMapGroup *pGroup);
  536. static ChunkFileResult_t LoadVersionInfoCallback(CChunkFile *pFile, CMapDoc *pDoc);
  537. static ChunkFileResult_t LoadVersionInfoKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
  538. static ChunkFileResult_t LoadAutosaveCallback(CChunkFile *pFile, CMapDoc *pDoc);
  539. static ChunkFileResult_t LoadAutosaveKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
  540. static ChunkFileResult_t LoadWorldCallback(CChunkFile *pFile, CMapDoc *pDoc);
  541. static ChunkFileResult_t LoadViewSettingsCallback(CChunkFile *pFile, CMapDoc *pDoc);
  542. static ChunkFileResult_t LoadViewSettingsKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
  543. //
  544. // Search functions.
  545. //
  546. static BOOL FindEntityByHammerIDCallback( CMapClass *pObject, FindEntityByHammerID_t *pFindInfo );
  547. static BOOL FindEntityCallback(CMapClass *pObject, FindEntity_t *pFindInfo);
  548. static BOOL FindGroupCallback(CMapGroup *pGroup, FindGroup_t *pFindInfo);
  549. void AssignToVisGroups(void);
  550. void AssignToGroups(void);
  551. void RemoveEmptyGroups(void);
  552. void CountGUIDs(void);
  553. void InitUpdateVisibilityData( UpdateVisibilityData_t &data );
  554. bool ShouldObjectBeVisible( CMapClass *pObject, UpdateVisibilityData_t *pData );
  555. static BOOL UpdateVisibilityCallback( CMapClass *pObject, UpdateVisibilityData_t *pData );
  556. static BOOL ForceVisibilityCallback(CMapClass *pObject, bool bVisibility);
  557. bool GetChildrenToHide(CMapClass *pObject, bool bSelected, CMapObjectList &List);
  558. //
  559. // Interobject dependency notification.
  560. //
  561. void ProcessNotifyList();
  562. void DispatchNotifyDependents(CUtlReference< CMapClass > pObject, Notify_Dependent_t eNotifyType);
  563. CUtlVector< NotifyListEntry_t* > m_NotifyList;
  564. CMapWorld *m_pWorld; // The world that this document represents.
  565. CMapObjectList m_UpdateList; // List of objects that have changed since the last call to Update.
  566. CString m_strLastExportFileName; // The full path that we last exported this document to.
  567. int m_nDocVersion; // A number that increments every time the doc is modified after being saved.
  568. BOOL m_bNeedsAutosave; // True if the document has been changed and needs autosaved.
  569. BOOL m_bIsAutosave;
  570. CString m_strAutosavedFrom;
  571. // Undo/Redo system.
  572. CHistory *m_pUndo;
  573. CHistory *m_pRedo;
  574. CSelection *m_pSelection; // object selection list
  575. int m_nNextMapObjectID; // The ID that will be assigned to the next CMapClass object in this document.
  576. int m_nNextLoadID; // PORTAL2 SHIP: keep track of load order to preserve it on save so that maps can be diffed.
  577. int m_nNextNodeID; // The ID that will be assigned to the next "info_node_xxx" object created in this document.
  578. // Editing prefabs data.
  579. DWORD m_dwPrefabID;
  580. DWORD m_dwPrefabLibraryID;
  581. BOOL m_bEditingPrefab;
  582. bool m_bPrefab; // true if this document IS a prefab, false if not.
  583. // Game configuration.
  584. CGameConfig *m_pGame;
  585. bool m_bShow3DGrid; // Whether to render a grid in the 3D views.
  586. bool m_bHideItems; // Whether to render point entities in all views.
  587. int m_nExternalReferenceCount; // Indicates how many external references ( instances ) are pointing to this map
  588. ShowInstance_t m_tShowInstance; // Indicates how instance contents should be displayed
  589. CManifest *m_pManifestOwner;
  590. bool m_bIsEditable;
  591. bool m_bCollapsingInstances;
  592. //
  593. // Animation.
  594. //
  595. float m_flAnimationTime; // Current time in the animation
  596. bool m_bIsAnimating;
  597. IBSPLighting *m_pBSPLighting;
  598. //
  599. // Visgroups.
  600. //
  601. CUtlVector<CVisGroup *> *m_VisGroups;
  602. CUtlVector<CVisGroup *> *m_RootVisGroups;
  603. bool m_bVisGroupUpdatesLocked;
  604. int m_SmoothingGroupVisual;
  605. int m_nLogicalPositionCount;
  606. CFoW *m_pFoW;
  607. CGridNav *m_pGridNav;
  608. //
  609. // Expands %i keyword in prefab targetnames to generate unique targetnames for this map.
  610. //
  611. bool ExpandTargetNameKeywords(char *szNewTargetName, const char *szOldTargetName, CMapWorld *pWorld);
  612. bool DoExpandKeywords(CMapClass *pObject, CMapWorld *pWorld, char *szOldKeyword, char *szNewKeyword);
  613. // Renames all named entities in pRoot
  614. void RenameEntities( CMapClass *pRoot, CMapWorld *pWorld, bool bMakeUnique, const char *pszPrefix );
  615. void CenterOriginsRecursive(CMapClass *pObject);
  616. void SnapObjectsRecursive(CMapClass *pObject);
  617. // Add all entities connected to all entities in the selection list recursively
  618. void AddConnectedNodes( CMapClass *pClass, CUtlRBTree< CMapClass*, unsigned short >& list );
  619. void DropTraceRecurse( CCullTreeNode *pCullTreeNode, const Vector &vTraceStart, CUtlVector< CMapSolid* > &objects );
  620. void DropTraceObjectRecurse( CMapClass *pObject, const Vector &vTraceStart, CUtlVector< CMapSolid* > &objects );
  621. //{{AFX_MSG(CMapDoc)
  622. afx_msg void OnEditDelete();
  623. afx_msg void OnMapSnaptogrid();
  624. afx_msg void OnMapEntityGallery();
  625. afx_msg void OnUpdateMapSnaptogrid(CCmdUI* pCmdUI);
  626. afx_msg void OnEditApplytexture();
  627. afx_msg void OnToolsSubtractselection();
  628. afx_msg void OnToolsCenterOrigins();
  629. afx_msg void OnEnableLightPreview();
  630. afx_msg void OnEnableLightPreviewCustomFilename();
  631. afx_msg void OnDisableLightPreview();
  632. afx_msg void OnToggleLightPreview();
  633. afx_msg void OnUpdateLightPreview();
  634. afx_msg void OnAbortLightCalculation();
  635. afx_msg void OnEditCopy();
  636. afx_msg void OnEditPaste();
  637. afx_msg void OnUpdateEditSelection(CCmdUI *pCmdUI);
  638. afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
  639. afx_msg void OnEditCut();
  640. afx_msg void OnEditReplace();
  641. afx_msg void OnToolsGroup();
  642. afx_msg void OnToolsUngroup();
  643. afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
  644. afx_msg void OnUpdateViewLogicalGrid(CCmdUI* pCmdUI);
  645. afx_msg void OnEditSelectall();
  646. afx_msg void OnFileSaveAs();
  647. afx_msg void OnFileSave();
  648. afx_msg void OnMapGridlower();
  649. afx_msg void OnMapGridhigher();
  650. afx_msg void OnEditToworld();
  651. afx_msg void OnEditToWorld();
  652. afx_msg void OnFileExport();
  653. afx_msg void OnFileExportAgain();
  654. afx_msg void OnEditMapproperties();
  655. afx_msg void OnFileConvertWAD();
  656. afx_msg void OnUpdateFileConvertWAD(CCmdUI* pCmdUI);
  657. afx_msg void OnFileRunmap();
  658. afx_msg void OnToolsHideitems();
  659. afx_msg void OnViewHideUnconnectedEntities();
  660. afx_msg void OnUpdateViewHideUnconnectedEntities(CCmdUI* pCmdUI);
  661. afx_msg void OnUpdateToolsSubtractselection(CCmdUI* pCmdUI);
  662. afx_msg void OnUpdateToolsHideitems(CCmdUI* pCmdUI);
  663. afx_msg void OnUpdateEditDelete(CCmdUI* pCmdUI);
  664. afx_msg void OnUpdateEditFunction(CCmdUI* pCmdUI);
  665. afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
  666. afx_msg void OnUpdateEditMapproperties(CCmdUI* pCmdUI);
  667. afx_msg void OnMapInformation();
  668. // View menu
  669. afx_msg void OnViewGrid();
  670. afx_msg void OnViewLogicalGrid();
  671. afx_msg void OnViewCenterOnSelection();
  672. afx_msg void OnViewCenter3DViewsOnSelection();
  673. afx_msg BOOL OnViewHideObjects(UINT nID);
  674. afx_msg void OnQuickHide_HideObjects();
  675. afx_msg void OnQuickHide_HideUnselectedObjects();
  676. afx_msg void OnQuickHide_Unhide();
  677. afx_msg void OnQuickHide_UpdateUnHide(CCmdUI *pCmdUI);
  678. afx_msg void OnViewDotACamera();
  679. afx_msg void OnQuickHide_CreateVisGroupFromHidden();
  680. afx_msg void OnQuickHide_UpdateCreateVisGroupFromHidden(CCmdUI *pCmdUI);
  681. afx_msg void OnViewShowconnections();
  682. afx_msg void OnViewGotoBrush(void);
  683. afx_msg void OnViewGotoCoords(void);
  684. afx_msg void OnViewShowHelpers();
  685. afx_msg void OnViewShowModelsIn2D();
  686. afx_msg void OnViewPreviewModelFade();
  687. afx_msg void OnViewPreviewGridNav();
  688. afx_msg void OnCollisionWireframe();
  689. afx_msg void OnShowDetailObjects();
  690. afx_msg void OnShowNoDrawBrushes();
  691. afx_msg void OnRadiusCulling();
  692. afx_msg void OnUpdateRadiusCulling(CCmdUI *pCmdUI);
  693. afx_msg void OnToolsHollow();
  694. afx_msg void OnEditPastespecial();
  695. afx_msg void OnUpdateEditPastespecial(CCmdUI* pCmdUI);
  696. afx_msg void OnEditSelnext();
  697. afx_msg void OnEditSelprev();
  698. afx_msg void OnEditSelnextCascading();
  699. afx_msg void OnEditSelprevCascading();
  700. afx_msg void OnLogicalMoveBlock();
  701. afx_msg void OnLogicalSelectAllCascading();
  702. afx_msg void OnLogicalSelectAllConnected();
  703. afx_msg void OnLogicalobjectLayoutgeometric();
  704. afx_msg void OnLogicalobjectLayoutdefault();
  705. afx_msg void OnLogicalobjectLayoutlogical();
  706. afx_msg void OnMapCheck();
  707. afx_msg void OnUpdateViewDotACamera(CCmdUI* pCmdUI);
  708. afx_msg void OnUpdateViewShowconnections(CCmdUI* pCmdUI);
  709. afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
  710. afx_msg void OnToolsCreateprefab();
  711. afx_msg void OnInsertprefabOriginal();
  712. afx_msg void OnEditReplacetex();
  713. afx_msg void OnToolsSnapselectedtogrid();
  714. afx_msg void OnToolsSnapSelectedToGridIndividually();
  715. afx_msg void OnUpdateToolsSplitface(CCmdUI* pCmdUI);
  716. afx_msg void OnToolsSplitface();
  717. afx_msg void OnToolsTransform();
  718. afx_msg void OnToolsToggletexlock();
  719. afx_msg void OnUpdateToolsToggletexlock(CCmdUI* pCmdUI);
  720. afx_msg void OnToolsToggletexlockScale();
  721. afx_msg void OnUpdateToolsToggletexlockScale(CCmdUI* pCmdUI);
  722. afx_msg void OnToolsTextureAlignment(void);
  723. afx_msg void OnUpdateToolsTextureAlignment(CCmdUI *pCmdUI);
  724. afx_msg void OnToggleCordon();
  725. afx_msg void OnUpdateToggleCordon(CCmdUI* pCmdUI);
  726. afx_msg void OnUpdateShowNoDrawBrushes(CCmdUI* pCmdUI);
  727. afx_msg void OnEditCordon();
  728. afx_msg void OnUpdateEditCordon(CCmdUI* pCmdUI);
  729. afx_msg void OnUpdateViewHideUnselectedObjects(CCmdUI* pCmdUI);
  730. afx_msg void OnToggleGroupignore();
  731. afx_msg void OnUpdateToggleGroupignore(CCmdUI* pCmdUI);
  732. afx_msg void OnVscaleToggle();
  733. afx_msg void OnMapEntityreport();
  734. afx_msg void OnToggleSelectbyhandle();
  735. afx_msg void OnUpdateToggleSelectbyhandle(CCmdUI* pCmdUI);
  736. afx_msg void OnToggleInfiniteselect();
  737. afx_msg void OnUpdateToggleInfiniteselect(CCmdUI* pCmdUI);
  738. afx_msg void OnFileExporttodxf();
  739. afx_msg void OnUpdateEditApplytexture(CCmdUI* pCmdUI);
  740. afx_msg void OnMapLoadpointfile();
  741. afx_msg void OnMapUnloadpointfile();
  742. afx_msg void OnMapLoadportalfile();
  743. afx_msg void OnMapUnloadportalfile();
  744. afx_msg void OnUpdate3dViewUI(CCmdUI* pCmdUI);
  745. afx_msg BOOL OnChange3dViewType(UINT nID);
  746. afx_msg void OnEditToEntity();
  747. afx_msg BOOL OnUndoRedo(UINT nID);
  748. afx_msg void OnUpdateUndoRedo(CCmdUI* pCmdUI);
  749. afx_msg void OnChangeVertexscale();
  750. afx_msg void OnUpdateGroupEditFunction(CCmdUI* pCmdUI);
  751. afx_msg void OnUpdateFileExport(CCmdUI *pCmdUI);
  752. afx_msg void OnEditClearselection();
  753. afx_msg void OnUpdateToggle3DGrid(CCmdUI* pCmdUI);
  754. afx_msg void OnMapShowSelectedBrushNumber();
  755. afx_msg void OnEditFindEntities(void);
  756. afx_msg void OnToolsHideEntityNames(void);
  757. afx_msg void OnUpdateToolsHideEntityNames(CCmdUI *pCmdUI);
  758. afx_msg void OnToggleDispSolidMask( void );
  759. afx_msg void OnUpdateToggleSolidMask(CCmdUI* pCmdUI);
  760. afx_msg void OnToggleDispDrawWalkable( void );
  761. afx_msg void OnUpdateToggleDispDrawWalkable(CCmdUI* pCmdUI);
  762. afx_msg void OnToggleDispDraw3D( void );
  763. afx_msg void OnUpdateToggleDispDraw3D(CCmdUI* pCmdUI);
  764. afx_msg void OnToggleDispDrawBuildable( void );
  765. afx_msg void OnUpdateToggleDispDrawBuildable(CCmdUI* pCmdUI);
  766. afx_msg void OnToggleDispDrawRemovedVerts( void );
  767. afx_msg void OnUpdateToggleDispDrawRemovedVerts(CCmdUI* pCmdUI);
  768. afx_msg void OnUpdateViewShowHelpers(CCmdUI *pCmdUI);
  769. afx_msg void OnUpdateViewShowModelsIn2D(CCmdUI *pCmdUI);
  770. afx_msg void OnUpdateViewPreviewModelFade(CCmdUI *pCmdUI);
  771. afx_msg void OnUpdateViewPreviewGridNav(CCmdUI *pCmdUI);
  772. afx_msg void OnUpdateCollisionWireframe(CCmdUI *pCmdUI);
  773. afx_msg void OnUpdateShowDetailObjects(CCmdUI *pCmdUI);
  774. afx_msg void OnMapDiff();
  775. afx_msg void OnToolsInstancesHide(void);
  776. afx_msg void OnUpdateToolsInstancesHide(CCmdUI *pCmdUI);
  777. afx_msg void OnToolsInstancesShowTinted(void);
  778. afx_msg void OnUpdateToolsInstancesShowTinted(CCmdUI *pCmdUI);
  779. afx_msg void OnToolsInstancesShowNormal(void);
  780. afx_msg void OnUpdateToolsInstancesShowNormal(CCmdUI *pCmdUI);
  781. afx_msg void OnInstancesHideAll( void );
  782. afx_msg void OnInstancesShowAll( void );
  783. afx_msg void OnFileVersionControlAdd( void );
  784. afx_msg void OnUpdateVersionControlAdd(CCmdUI *pCmdUI);
  785. afx_msg void OnFileVersionControlCheckOut( void );
  786. afx_msg void OnFileVersionControlCheckOutBsp( void );
  787. afx_msg void OnUpdateVersionControlCheckOut(CCmdUI *pCmdUI);
  788. afx_msg void OnUpdateVersionControlCheckOutBsp(CCmdUI *pCmdUI);
  789. afx_msg void OnFileVersionControlCheckIn( void );
  790. afx_msg void OnUpdateVersionControlCheckIn(CCmdUI *pCmdUI);
  791. afx_msg void OnFileVersionControlCheckInAll( void );
  792. afx_msg void OnUpdateVersionControlCheckInAll(CCmdUI *pCmdUI);
  793. afx_msg void OnFileVersionControlOverview( void );
  794. afx_msg void OnInstancingCreatemanifest();
  795. afx_msg void OnUpdateInstancingCreatemanifest( CCmdUI *pCmdUI );
  796. afx_msg void OnInstancingCheckinAll();
  797. afx_msg void OnUpdateInstancingCheckinAll( CCmdUI *pCmdUI );
  798. afx_msg void OnInstancingCheckOutManifest();
  799. afx_msg void OnUpdateInstancingCheckOutManifest( CCmdUI *pCmdUI );
  800. afx_msg void OnInstancingAddManifest();
  801. afx_msg void OnUpdateInstancingAddManifest( CCmdUI *pCmdUI );
  802. afx_msg void OnInstancesCollapseAll();
  803. afx_msg void OnInstancesCollapseSelection();
  804. afx_msg void OnInstancesCollapseAllRecursive();
  805. afx_msg void OnInstancesCollapseSelectionRecursive();
  806. afx_msg void OnUpdateToolsSprinkle( CCmdUI *pCmdUI );
  807. afx_msg void OnToolsSprinkle();
  808. //}}AFX_MSG
  809. DECLARE_MESSAGE_MAP()
  810. public:
  811. afx_msg void OnNewCordon();
  812. afx_msg void OnToggle3DGrid();
  813. };
  814. //-----------------------------------------------------------------------------
  815. // Purpose:
  816. // Output : inline void
  817. //-----------------------------------------------------------------------------
  818. void CMapDoc::DecrementDocVersion(void)
  819. {
  820. if (m_nDocVersion > 0)
  821. {
  822. m_nDocVersion--;
  823. }
  824. }
  825. //-----------------------------------------------------------------------------
  826. // Purpose: Returns true if we are loading, false if not.
  827. //-----------------------------------------------------------------------------
  828. bool CMapDoc::IsLoading(void)
  829. {
  830. return(m_bLoading);
  831. }
  832. //-----------------------------------------------------------------------------
  833. // Purpose: Returns the document that is currently active.
  834. //-----------------------------------------------------------------------------
  835. CMapDoc *CMapDoc::GetActiveMapDoc(void)
  836. {
  837. return(m_pMapDoc);
  838. }
  839. //-----------------------------------------------------------------------------
  840. // Purpose: Returns the manifest associated with the active document.
  841. //-----------------------------------------------------------------------------
  842. CManifest *CMapDoc::GetManifest( void )
  843. {
  844. return m_pManifest;
  845. }
  846. //-----------------------------------------------------------------------------
  847. // Purpose: Returns the current level loading depth. 0 = not loading level
  848. //-----------------------------------------------------------------------------
  849. int CMapDoc::GetInLevelLoad( )
  850. {
  851. return m_nInLevelLoad;
  852. }
  853. //-----------------------------------------------------------------------------
  854. // Purpose: Returns the current version of the document that is being worked on.
  855. //-----------------------------------------------------------------------------
  856. int CMapDoc::GetDocVersion(void)
  857. {
  858. return(m_nDocVersion);
  859. }
  860. //-----------------------------------------------------------------------------
  861. // Purpose: Returns a pointer to the game configuration for this document.
  862. //-----------------------------------------------------------------------------
  863. CGameConfig *CMapDoc::GetGame(void)
  864. {
  865. return(m_pGame);
  866. }
  867. //-----------------------------------------------------------------------------
  868. // Purpose: Returns a pointer to the Undo system for this document.
  869. //-----------------------------------------------------------------------------
  870. CHistory *CMapDoc::GetDocHistory(void)
  871. {
  872. return(m_pUndo);
  873. }
  874. //-----------------------------------------------------------------------------
  875. // Purpose: Returns the map format of the game configuration for this document.
  876. //-----------------------------------------------------------------------------
  877. MAPFORMAT CMapDoc::GetMapFormat(void)
  878. {
  879. if (m_pGame != NULL)
  880. {
  881. return(m_pGame->mapformat);
  882. }
  883. return(mfHalfLife2);
  884. }
  885. //-----------------------------------------------------------------------------
  886. // Purpose: Returns a pointer to the world that this document edits.
  887. //-----------------------------------------------------------------------------
  888. CMapWorld *CMapDoc::GetMapWorld(void)
  889. {
  890. return(m_pWorld);
  891. }
  892. //-----------------------------------------------------------------------------
  893. // Purpose: Returns a pointer to the grid nav object for this document.
  894. //-----------------------------------------------------------------------------
  895. CGridNav *CMapDoc::GetGridNav(void)
  896. {
  897. return(m_pGridNav);
  898. }
  899. //-----------------------------------------------------------------------------
  900. // Purpose: All map objects in a given document are assigned a unique ID.
  901. //-----------------------------------------------------------------------------
  902. int CMapDoc::GetNextMapObjectID(void)
  903. {
  904. return(m_nNextMapObjectID++);
  905. }
  906. //-----------------------------------------------------------------------------
  907. // PORTAL2 SHIP: keep track of load order to preserve it on save so that maps can be diffed.
  908. //-----------------------------------------------------------------------------
  909. int CMapDoc::GetNextLoadID()
  910. {
  911. return m_nNextLoadID++;
  912. }
  913. //-----------------------------------------------------------------------------
  914. // Purpose: Returns the next unique ID for an AI node. Called when an AI node
  915. // is created so that each one can have a unique ID.
  916. //
  917. // We can't use the unique object ID (above) for this because of
  918. // problems with in-engine editing of nodes and node connections.
  919. //-----------------------------------------------------------------------------
  920. int CMapDoc::GetNextNodeID(void)
  921. {
  922. return(m_nNextNodeID++);
  923. }
  924. //-----------------------------------------------------------------------------
  925. // Purpose: Sets the next unique ID for a AI node creation. Called when an AI node
  926. // is created from the shell so that node IDs continue from there.
  927. //-----------------------------------------------------------------------------
  928. void CMapDoc::SetNextNodeID(int nID)
  929. {
  930. m_nNextNodeID = nID;
  931. }
  932. //-----------------------------------------------------------------------------
  933. // Purpose: Returns whether or not grid snap is enabled. Called by the tools and
  934. // views to determine snap behavior.
  935. //-----------------------------------------------------------------------------
  936. bool CMapDoc::IsSnapEnabled(void)
  937. {
  938. return m_bSnapToGrid;
  939. }
  940. //-----------------------------------------------------------------------------
  941. //-----------------------------------------------------------------------------
  942. int CMapDoc::Cordon_GetCount()
  943. {
  944. return m_Cordons.Count();
  945. }
  946. //-----------------------------------------------------------------------------
  947. //-----------------------------------------------------------------------------
  948. Cordon_t *CMapDoc::Cordon_GetCordon( int nIndex )
  949. {
  950. return &m_Cordons.Element( nIndex );
  951. }
  952. //-----------------------------------------------------------------------------
  953. //-----------------------------------------------------------------------------
  954. bool CMapDoc::Cordon_IsCordoning()
  955. {
  956. return m_bIsCordoning;
  957. }
  958. //-----------------------------------------------------------------------------
  959. //-----------------------------------------------------------------------------
  960. bool CMapDoc::Cordon_IsEditCordon( int nCordon, int nBox )
  961. {
  962. return ( nCordon == m_nEditCordon ) && ( nBox == m_nEditCordonBox );
  963. }
  964. #endif // MAPDOC_H