WorldBuilderView.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. // WorldBuilderView.h : interface of the CWorldBuilderView class
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #if !defined(AFX_WORLDBUILDERVIEW_H__FBA4134F_2826_11D5_8CE0_00010297BBAC__INCLUDED_)
  22. #define AFX_WORLDBUILDERVIEW_H__FBA4134F_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 "W3DDevice/GameClient/WorldHeightMap.h"
  28. #include "WbView.h"
  29. //#include "WW3D_SimpleWindow.h"
  30. #define MIN_GRID_SIZE 4
  31. class MapObject;
  32. class CWorldBuilderDoc;
  33. class CWorldBuilderView : public WbView
  34. {
  35. protected: // create from serialization only
  36. CWorldBuilderView();
  37. DECLARE_DYNCREATE(CWorldBuilderView)
  38. // Operations
  39. public:
  40. // Overrides
  41. // ClassWizard generated virtual function overrides
  42. //{{AFX_VIRTUAL(CWorldBuilderView)
  43. public:
  44. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  45. protected:
  46. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  47. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  48. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  49. virtual void OnDraw(CDC* pDC);
  50. //}}AFX_VIRTUAL
  51. // Implementation
  52. public:
  53. virtual ~CWorldBuilderView();
  54. #ifdef _DEBUG
  55. virtual void AssertValid() const;
  56. virtual void Dump(CDumpContext& dc) const;
  57. #endif
  58. protected:
  59. Int m_cellSize; ///< Size of a height map cell in pixels when drawn in the 2d view.
  60. Bool m_showContours; ///< Flag whether contours are drawn in the 2d view.
  61. Bool m_showTexture; ///< Flag whether textures are drawn in the 2d view.
  62. Bool mShowGrid; ///< Flag whether the gray grid is drawn in the 2d view.
  63. Int mXScrollOffset; ///< The x offset to the upper left corner of the screen.
  64. Int mYScrollOffset; ///< The y offset to the upper left corner of the screen.
  65. CPoint m_scrollMin; ///< The minimum scrollbar positions.
  66. CPoint m_scrollMax; ///< The maximum scroll bar positions.
  67. protected:
  68. /// Draw a texture bitmap in a rectangle in the dc.
  69. void drawMyTexture(CDC *pDc, CRect *pRect, Int width, UnsignedByte *rgbData);
  70. /// Get a color for a height value.
  71. DWORD getColorForHeight(UnsignedByte ht);
  72. /// Draw the contours for the height map in the dc.
  73. void drawContours(CDC *pDc, CRgn *pRgn, Int minX, Int maxX, Int minY, Int maxY);
  74. /// Compound boolean expression.
  75. static inline Bool isBetween(Int cur, Int first, Int second) {
  76. Bool is = false;
  77. if (cur>=first && cur<=second) is = true;
  78. if (cur<=first && cur>=second) is = true;
  79. return(is);
  80. }
  81. /// Interpolate the point at a given height between 2 points.
  82. void interpolate(CPoint *pt, Int ht, CPoint pt1, Int ht1, CPoint pt2, Int ht2);
  83. /// Draw the object's icon in the dc at a given point.
  84. void drawObjectInView(CDC *pDc, MapObject *pMapObj);
  85. public:
  86. /// Get the current draw size in pixels in the 2d window of one height map cell.
  87. Int getCellSize(void) {return m_cellSize;}
  88. /// Sets the current draw size.
  89. void setCellSize(Int cellSize);
  90. /// Set whether contours are drawn.
  91. Bool getShowContours(void) {return m_showContours;}
  92. /// Set whether contours are drawn.
  93. void setShowContours(Bool show);
  94. /// Update the center to match a center point from the 3d view.
  95. void updateCenterFromMapPoint(Real x, Real y);
  96. protected:
  97. public:
  98. virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain);
  99. virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt);
  100. /// Set the center for display.
  101. virtual void setCenterInView(Real x, Real y);
  102. /// the doc has changed size; readjust view as necessary.
  103. virtual void adjustDocSize();
  104. /// Invalidates an object. Pass NULL to inval all objects.
  105. virtual void invalObjectInView(MapObject *pObj);
  106. /// Invalidates the area of one height map cell in the 2d view.
  107. virtual void invalidateCellInView(int xIndex, int yIndex);
  108. /// Scrolls the window by this amount (doc coords).
  109. virtual void scrollInView(Real x, Real y, Bool end);
  110. // Generated message map functions
  111. protected:
  112. //{{AFX_MSG(CWorldBuilderView)
  113. afx_msg void OnPaint();
  114. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  115. afx_msg void OnSize(UINT nType, int cx, int cy);
  116. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  117. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  118. afx_msg void OnShowGrid();
  119. afx_msg void OnUpdateShowGrid(CCmdUI* pCmdUI);
  120. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  121. afx_msg void OnViewShowtexture();
  122. afx_msg void OnUpdateViewShowtexture(CCmdUI* pCmdUI);
  123. // afx_msg void OnViewShowcontours();
  124. // afx_msg void OnUpdateViewShowcontours(CCmdUI* pCmdUI);
  125. //}}AFX_MSG
  126. DECLARE_MESSAGE_MAP()
  127. };
  128. /////////////////////////////////////////////////////////////////////////////
  129. //{{AFX_INSERT_LOCATION}}
  130. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  131. #endif // !defined(AFX_WORLDBUILDERVIEW_H__FBA4134F_2826_11D5_8CE0_00010297BBAC__INCLUDED_)