WorldBuilderDoc.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // WorldBuilderDoc.h : interface of the CWorldBuilderDoc class
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #if !defined(AFX_WORLDBUILDERDOC_H__FBA4134D_2826_11D5_8CE0_00010297BBAC__INCLUDED_)
  22. #define AFX_WORLDBUILDERDOC_H__FBA4134D_2826_11D5_8CE0_00010297BBAC__INCLUDED_
  23. #if _MSC_VER > 1000
  24. #pragma once
  25. #endif // _MSC_VER > 1000
  26. #include "lib/BaseType.h"
  27. #include "Common/MapObject.h"
  28. #include "Tool.h"
  29. class CWorldBuilderView;
  30. class WbView3d;
  31. class WorldHeightMapEdit;
  32. class Undoable;
  33. class DataChunkInput;
  34. struct DataChunkInfo;
  35. #define MAX_UNDOS 15
  36. #define MIN_CELL_SIZE 1
  37. #define MAX_CELL_SIZE 64
  38. class CWorldBuilderDoc : public CDocument
  39. {
  40. friend class COptionsPanel;
  41. enum {MAX_WAYPOINTS=16000}; ///@todo - make it dynamic. jba.
  42. protected: // create from serialization only
  43. CWorldBuilderDoc();
  44. DECLARE_DYNCREATE(CWorldBuilderDoc)
  45. protected:
  46. WorldHeightMapEdit *m_heightMap;
  47. Undoable *m_undoList; ///< Head of undo/redo list.
  48. int m_maxUndos;
  49. int m_curRedo; ///< 0 means no redos available.
  50. Bool m_linkCenters; ///< Flag whether the centers of the 2d and 3d views track together.
  51. Bool m_needAutosave; ///< True if changes have been made since last autosave.
  52. Int m_curWaypointID;
  53. protected:
  54. std::vector<ICoord2D> m_boundaries;
  55. protected: // waypoint stuff.
  56. MapObject *m_waypointTable[MAX_WAYPOINTS];
  57. Bool m_waypointTableNeedsUpdate;
  58. struct {
  59. Int waypoint1;
  60. Int waypoint2;
  61. Bool processedFlag;
  62. } m_waypointLinks[MAX_WAYPOINTS];
  63. Int m_numWaypointLinks;
  64. protected:
  65. void updateWaypointTable(void);
  66. void compressWaypointIds(void);
  67. void updateLWL(MapObject *pWay, MapObject *pSrcWay);
  68. public:
  69. void addWaypointLink(Int waypointID1, Int waypointID2);
  70. void removeWaypointLink(Int waypointID1, Int waypointID2);
  71. MapObject *getWaypointByID(Int waypointID);
  72. Int getNumWaypointLinks(void) {return m_numWaypointLinks;};
  73. void getWaypointLink(Int ndx, Int *waypoint1, Int *waypointID2);
  74. Bool waypointLinkExists(Int waypointID1, Int waypointID2);
  75. Bool isWaypointLinked(MapObject *pWay);
  76. void updateLinkedWaypointLabels(MapObject *pWay);
  77. // Boundary stuff
  78. Int getNumBoundaries(void) const ;
  79. void getBoundary(Int ndx, ICoord2D* border) const;
  80. void addBoundary(ICoord2D* boundaryToAdd);
  81. void changeBoundary(Int ndx, ICoord2D *border);
  82. void removeLastBoundary(void);
  83. // outNdx must not be NULL, but outHandle can be.
  84. // outHandle: 0 means BL, 1 means TL, 2 means TR, 3 means BR
  85. void findBoundaryNear(Coord3D *pt, float okDistance, Int *outNdx, Int *outHandle);
  86. static Bool ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  87. Bool ParseWaypointData(DataChunkInput &file, DataChunkInfo *info, void *userData);
  88. public: // overridden
  89. virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace = TRUE);
  90. virtual BOOL DoFileSave();
  91. // Attributes
  92. public:
  93. WorldHeightMapEdit *GetHeightMap() {return m_heightMap;}
  94. void SetHeightMap(WorldHeightMapEdit *pMap, Bool doUpdate);
  95. void Create2DView();
  96. void Create3DView();
  97. CWorldBuilderView *Get2DView();
  98. WbView3d *Get3DView();
  99. static CWorldBuilderDoc *GetActiveDoc();
  100. static CWorldBuilderView *GetActive2DView();
  101. static WbView3d *GetActive3DView();
  102. void invalObject(MapObject *pMapObj);
  103. void invalCell(int xIndex, int yIndex);
  104. void updateAllViews();
  105. void updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange);
  106. /// Gets an xy index into the height map from a pixel location.
  107. Bool getCellIndexFromCoord(Coord3D pt, CPoint *ndxP);
  108. void getCoordFromCellIndex(CPoint ndx, Coord3D* pt);
  109. /// Gets a real xy location from a pixel point.
  110. Bool getCellPositionFromCoord(Coord3D pt, Coord3D *locP);
  111. /// Gets all of the indices within widthOutside of the rectangle and places them into
  112. /// allIndices
  113. Bool getAllIndexesInRect(const Coord3D* bl, const Coord3D* br,
  114. const Coord3D* tl, const Coord3D* tr,
  115. Int widthOutside, VecHeightMapIndexes* allIndices);
  116. /// Gets the arrow point location.
  117. void getObjArrowPoint(MapObject *pObj, Coord3D *location);
  118. void syncViewCenters(Real x, Real y);
  119. Bool needAutoSave(void) {return m_needAutosave;};
  120. Int getNextWaypointID(void) { return ++m_curWaypointID;};
  121. void setNextWaypointID(Int newMax) { if (newMax>m_curWaypointID) m_curWaypointID = newMax;};
  122. void autoSave(void);
  123. void validate(void);
  124. // Operations
  125. public:
  126. // Overrides
  127. // ClassWizard generated virtual function overrides
  128. //{{AFX_VIRTUAL(CWorldBuilderDoc)
  129. public:
  130. virtual BOOL OnNewDocument();
  131. virtual void Serialize(CArchive& ar);
  132. virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  133. virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
  134. //}}AFX_VIRTUAL
  135. // Implementation
  136. public:
  137. virtual ~CWorldBuilderDoc();
  138. #ifdef _DEBUG
  139. virtual void AssertValid() const;
  140. virtual void Dump(CDumpContext& dc) const;
  141. #endif
  142. void AddAndDoUndoable(Undoable *pUndo);
  143. // Generated message map functions
  144. protected:
  145. //{{AFX_MSG(CWorldBuilderDoc)
  146. afx_msg void OnEditRedo();
  147. afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
  148. afx_msg void OnEditUndo();
  149. afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
  150. afx_msg void OnTsInfo();
  151. afx_msg void OnTsCanonical();
  152. afx_msg void OnUpdateTsCanonical(CCmdUI* pCmdUI);
  153. afx_msg void OnFileResize();
  154. afx_msg void OnJumpToGame();
  155. afx_msg void OnTsRemap();
  156. afx_msg void OnEditLinkCenters();
  157. afx_msg void OnUpdateEditLinkCenters(CCmdUI* pCmdUI);
  158. afx_msg void OnViewTimeOfDay();
  159. afx_msg void OnWindow2dwindow();
  160. afx_msg void OnUpdateWindow2dwindow(CCmdUI* pCmdUI);
  161. afx_msg void OnViewReloadtextures();
  162. afx_msg void OnEditScripts();
  163. afx_msg void OnViewHome();
  164. afx_msg void OnTexturesizingTile4x4();
  165. afx_msg void OnUpdateTexturesizingTile4x4(CCmdUI* pCmdUI);
  166. afx_msg void OnTexturesizingTile6x6();
  167. afx_msg void OnUpdateTexturesizingTile6x6(CCmdUI* pCmdUI);
  168. afx_msg void OnTexturesizingTile8x8();
  169. afx_msg void OnUpdateTexturesizingTile8x8(CCmdUI* pCmdUI);
  170. afx_msg void OnDumpDocToText();
  171. afx_msg void OnRemoveclifftexmapping();
  172. afx_msg void OnTogglePitchAndRotation();
  173. //}}AFX_MSG
  174. DECLARE_MESSAGE_MAP()
  175. };
  176. /////////////////////////////////////////////////////////////////////////////
  177. //{{AFX_INSERT_LOCATION}}
  178. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  179. #endif // !defined(AFX_WORLDBUILDERDOC_H__FBA4134D_2826_11D5_8CE0_00010297BBAC__INCLUDED_)