wbview.h 8.9 KB

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