wbview.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. #if !defined(AFX_WBVIEW_H__875234A1_8815_11D5_8CE0_00010297BBAC__INCLUDED_)
  19. #define AFX_WBVIEW_H__875234A1_8815_11D5_8CE0_00010297BBAC__INCLUDED_
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif // _MSC_VER > 1000
  23. #include "Lib/BaseType.h"
  24. #include "Tool.h"
  25. #include "Common/Debug.h"
  26. #include "Common/ThingSort.h"
  27. class CWorldBuilderDoc;
  28. class BuildListInfo;
  29. // wbview.h : header file
  30. //
  31. enum TPickedStatus {
  32. PICK_NONE,
  33. PICK_CENTER,
  34. PICK_ARROW
  35. };
  36. enum RulerTypeEnum {
  37. RULER_NONE,
  38. RULER_LINE,
  39. RULER_CIRCLE,
  40. };
  41. /////////////////////////////////////////////////////////////////////////////
  42. // WbView view
  43. class WbView : public CView
  44. {
  45. protected:
  46. WbView(); // protected constructor used by dynamic creation
  47. DECLARE_DYNCREATE(WbView)
  48. TTrackingMode m_trackingMode;
  49. Vector3 m_centerPt;
  50. void mouseDown(TTrackingMode m, CPoint viewPt);
  51. void mouseMove(TTrackingMode m, CPoint viewPt);
  52. void mouseUp(TTrackingMode m, CPoint viewPt);
  53. void constrainCenterPt();
  54. WorldHeightMapEdit *getTrackingHeightMap();
  55. static Bool m_snapToGrid;
  56. Bool m_showObjects; ///< Flag whether object icons are drawn in the 2d and 3d view.
  57. Bool m_showModels; ///< Flag whether models are drawn in the 2d and 3d view.
  58. Bool m_showNames; ///< Flag whether names are drawn in the 2d and 3d view.
  59. Bool m_showGarrisoned;
  60. Bool m_showWaypoints;
  61. Bool m_showPolygonTriggers;
  62. Bool m_showTerrain; ///< Flag whether terrain is rendered or not. (Useful for debugging)
  63. Real m_hysteresis;
  64. Bool m_lockAngle; ///< Reflects the ui button.
  65. //Bool m_lockVertical; ///< Reflects the ui button.
  66. Bool m_doLockAngle; ///< True if we are currently locking.
  67. //Bool m_doLockVertical; ///< True if we are currently locking.
  68. CPoint m_mouseDownPoint;
  69. Coord3D m_mouseDownDocPoint;
  70. // Box feedback.
  71. RECT m_feedbackBox;
  72. Bool m_doRectFeedback;
  73. int m_doRulerFeedback;
  74. Coord3D m_rulerPoints[2];
  75. Real m_rulerLength;
  76. // Light direction feedback
  77. Coord3D m_lightDirection[3]; //direction of all 3 lights
  78. Bool m_doLightFeedback;
  79. EditorSortingType m_pickConstraint;
  80. // Attributes
  81. public:
  82. void doRectFeedback(Bool doFeedback, RECT &rect) {m_feedbackBox=rect;m_doRectFeedback = doFeedback;};
  83. void doRulerFeedback(int doRulerFeedback) {m_doRulerFeedback = doRulerFeedback;}
  84. void rulerFeedbackInfo(Coord3D &point1, Coord3D &point2, Real dist);
  85. void doLightFeedback(Bool doFeedback, Coord3D direction, Int lightIndex) { m_doLightFeedback=doFeedback; if (m_doLightFeedback) m_lightDirection[lightIndex]=direction;}
  86. virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrained=true) { DEBUG_CRASH(("should not call")); newPt->zero(); return false; }
  87. virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt) { DEBUG_CRASH(("should not call")); return false; }
  88. virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z) { return viewToDocCoords(curPt, newPt, false); }
  89. /// Set the center for display.
  90. virtual void setCenterInView(Real x, Real y) { }
  91. /// Update the height map in the 3d window.
  92. virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) { }
  93. /// the doc has changed size; readjust view as necessary.
  94. virtual void adjustDocSize() { }
  95. /// Scrolls the window by this amount.
  96. virtual void scrollInView(Real x, Real y, Bool end) { DEBUG_CRASH(("should not call")); }
  97. /// Invalidates an object. Pass NULL to inval all objects.
  98. virtual void invalObjectInView(MapObject *pObj) { }
  99. /// Invalidates the area of one height map cell in the 2d view.
  100. virtual void invalidateCellInView(int xIndex, int yIndex) { }
  101. virtual void setDefaultCamera() { }
  102. virtual void rotateCamera(Real delta) { }
  103. virtual void pitchCamera(Real delta) { }
  104. virtual Int getPickPixels(void) {return 4;}
  105. virtual EditorSortingType GetPickConstraint(void) {return m_pickConstraint;}
  106. public:
  107. CWorldBuilderDoc *WbDoc() { return ((CWorldBuilderDoc*)GetDocument()); }
  108. void snapPoint(Coord3D *thePt) {if (m_snapToGrid || m_lockAngle) {thePt->x = MAP_XY_FACTOR*floor(thePt->x/MAP_XY_FACTOR+0.5); thePt->y = MAP_XY_FACTOR*floor(thePt->y/MAP_XY_FACTOR+0.5);};};
  109. virtual TPickedStatus picked(MapObject *pObj, Coord3D docPt);
  110. virtual MapObject *picked3dObjectInView(CPoint viewPt) {return NULL;};
  111. virtual BuildListInfo *pickedBuildObjectInView(CPoint viewPt) {return NULL;};
  112. Bool isPolygonTriggerVisible(void) {return m_showPolygonTriggers;};
  113. Bool isWaypointVisible(void) {return m_showWaypoints;};
  114. Bool isNamesVisible(void) {return m_showNames;};
  115. void setShowModels(Bool show) {m_showModels = show;}
  116. Bool getShowModels(void) { return m_showModels;}
  117. Bool getShowTerrain(void) { return m_showTerrain;}
  118. void setShowGarrisoned(Bool show) {m_showGarrisoned = show;}
  119. Bool getShowGarrisoned(void) { return m_showGarrisoned;}
  120. virtual Bool isDoingPitch( void ) { return false; }
  121. // Operations
  122. public:
  123. // Overrides
  124. // ClassWizard generated virtual function overrides
  125. //{{AFX_VIRTUAL(WbView)
  126. protected:
  127. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  128. //}}AFX_VIRTUAL
  129. // Implementation
  130. protected:
  131. virtual ~WbView();
  132. #ifdef _DEBUG
  133. virtual void AssertValid() const;
  134. virtual void Dump(CDumpContext& dc) const;
  135. #endif
  136. // Generated message map functions
  137. protected:
  138. //{{AFX_MSG(WbView)
  139. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  140. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  141. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  142. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  143. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  144. afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  145. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  146. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  147. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  148. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  149. afx_msg void OnEditDelete();
  150. afx_msg void OnEditCopy();
  151. afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
  152. afx_msg void OnEditCut();
  153. afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
  154. afx_msg void OnEditPaste();
  155. afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
  156. afx_msg void OnViewSnaptogrid();
  157. afx_msg void OnUpdateViewSnaptogrid(CCmdUI* pCmdUI);
  158. afx_msg void OnViewShowObjects();
  159. afx_msg void OnUpdateViewShowObjects(CCmdUI* pCmdUI);
  160. afx_msg void OnEditSelectdup();
  161. afx_msg void OnEditSelectsimilar();
  162. afx_msg void OnEditSelectinvalidteam();
  163. afx_msg void OnEditReplace();
  164. afx_msg void OnObjectpropertiesReflectsinmirror();
  165. afx_msg void OnLockHorizontal();
  166. afx_msg void OnUpdateLockHorizontal(CCmdUI* pCmdUI);
  167. afx_msg void OnLockVertical();
  168. afx_msg void OnUpdateLockVertical(CCmdUI* pCmdUI);
  169. afx_msg void OnEditGloballightoptions();
  170. afx_msg void OnViewShowwaypoints();
  171. afx_msg void OnUpdateViewShowwaypoints(CCmdUI* pCmdUI);
  172. afx_msg void OnViewShowpolygontriggers();
  173. afx_msg void OnUpdateViewShowpolygontriggers(CCmdUI* pCmdUI);
  174. afx_msg void OnEditPlayerlist();
  175. afx_msg void OnEditWorldinfo();
  176. afx_msg void OnEditTeamlist();
  177. afx_msg void OnUpdateObjectpropertiesReflectsinmirror(CCmdUI* pCmdUI);
  178. afx_msg void OnPickStructures();
  179. afx_msg void OnUpdatePickStructures(CCmdUI* pCmdUI);
  180. afx_msg void OnPickInfantry();
  181. afx_msg void OnUpdatePickInfantry(CCmdUI* pCmdUI);
  182. afx_msg void OnPickVehicles();
  183. afx_msg void OnUpdatePickVehicles(CCmdUI* pCmdUI);
  184. afx_msg void OnPickShrubbery();
  185. afx_msg void OnUpdatePickShrubbery(CCmdUI* pCmdUI);
  186. afx_msg void OnPickManMade();
  187. afx_msg void OnUpdatePickManMade(CCmdUI* pCmdUI);
  188. afx_msg void OnPickNatural();
  189. afx_msg void OnUpdatePickNatural(CCmdUI* pCmdUI);
  190. afx_msg void OnPickDebris();
  191. afx_msg void OnUpdatePickDebris(CCmdUI* pCmdUI);
  192. afx_msg void OnPickAnything();
  193. afx_msg void OnUpdatePickAnything(CCmdUI* pCmdUI);
  194. afx_msg void OnPickWaypoints();
  195. afx_msg void OnUpdatePickWaypoints(CCmdUI* pCmdUI);
  196. afx_msg void OnPickRoads();
  197. afx_msg void OnUpdatePickRoads(CCmdUI* pCmdUI);
  198. afx_msg void OnPickSounds();
  199. afx_msg void OnUpdatePickSounds(CCmdUI* pCmdUI);
  200. afx_msg void OnShowNames();
  201. afx_msg void OnUpdateShowNames(CCmdUI* pCmdUI);
  202. afx_msg void OnValidationFixTeams();
  203. afx_msg void OnShowTerrain();
  204. afx_msg void OnUpdateShowTerrain(CCmdUI* pCmdUI);
  205. afx_msg int OnCreate(LPCREATESTRUCT lpcs);
  206. //}}AFX_MSG
  207. DECLARE_MESSAGE_MAP()
  208. };
  209. /////////////////////////////////////////////////////////////////////////////
  210. //{{AFX_INSERT_LOCATION}}
  211. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  212. #endif // !defined(AFX_WBVIEW_H__875234A1_8815_11D5_8CE0_00010297BBAC__INCLUDED_)