forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathWorldBuilderView.h
More file actions
165 lines (131 loc) · 5.51 KB
/
WorldBuilderView.h
File metadata and controls
165 lines (131 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// WorldBuilderView.h : interface of the CWorldBuilderView class
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Lib/BaseType.h"
#include "W3DDevice/GameClient/WorldHeightMap.h"
#include "wbview.h"
//#include "WW3D_SimpleWindow.h"
#define MIN_GRID_SIZE 4
class MapObject;
class CWorldBuilderDoc;
class CWorldBuilderView : public WbView
{
protected: // create from serialization only
CWorldBuilderView();
DECLARE_DYNCREATE(CWorldBuilderView)
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWorldBuilderView)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnDraw(CDC* pDC);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CWorldBuilderView();
#ifdef RTS_DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
Int m_cellSize; ///< Size of a height map cell in pixels when drawn in the 2d view.
Bool m_showContours; ///< Flag whether contours are drawn in the 2d view.
Bool m_showTexture; ///< Flag whether textures are drawn in the 2d view.
Bool mShowGrid; ///< Flag whether the gray grid is drawn in the 2d view.
Int mXScrollOffset; ///< The x offset to the upper left corner of the screen.
Int mYScrollOffset; ///< The y offset to the upper left corner of the screen.
CPoint m_scrollMin; ///< The minimum scrollbar positions.
CPoint m_scrollMax; ///< The maximum scroll bar positions.
HintDrawState m_brushHintState; ///< Flicker reduction state for brush mode hint
protected:
/// Draw a texture bitmap in a rectangle in the dc.
void drawMyTexture(CDC *pDc, CRect *pRect, Int width, UnsignedByte *rgbData);
/// Get a color for a height value.
DWORD getColorForHeight(UnsignedByte ht);
/// Draw the contours for the height map in the dc.
void drawContours(CDC *pDc, CRgn *pRgn, Int minX, Int maxX, Int minY, Int maxY);
/// Compound boolean expression.
static inline Bool isBetween(Int cur, Int first, Int second) {
Bool is = false;
if (cur>=first && cur<=second) is = true;
if (cur<=first && cur>=second) is = true;
return(is);
}
/// Interpolate the point at a given height between 2 points.
void interpolate(CPoint *pt, Int ht, CPoint pt1, Int ht1, CPoint pt2, Int ht2);
/// Draw the object's icon in the dc at a given point.
void drawObjectInView(CDC *pDc, MapObject *pMapObj);
/// Draw brush mode hint on canvas
void drawBrushModeHint(CDC *pDc, CRgn *pUpdateRgn = NULL);
/// Clears the brush mode hint state
void clearBrushModeHintState();
public:
/// Get the current draw size in pixels in the 2d window of one height map cell.
Int getCellSize(void) {return m_cellSize;}
/// Sets the current draw size.
void setCellSize(Int cellSize);
/// Set whether contours are drawn.
Bool getShowContours(void) {return m_showContours;}
/// Set whether contours are drawn.
void setShowContours(Bool show);
/// Update the center to match a center point from the 3d view.
void updateCenterFromMapPoint(Real x, Real y);
protected:
public:
virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain);
virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt);
/// Set the center for display.
virtual void setCenterInView(Real x, Real y);
/// the doc has changed size; readjust view as necessary.
virtual void adjustDocSize();
/// Invalidates an object. Pass NULL to inval all objects.
virtual void invalObjectInView(MapObject *pObj);
/// Invalidates the area of one height map cell in the 2d view.
virtual void invalidateCellInView(int xIndex, int yIndex);
/// Scrolls the window by this amount (doc coords).
virtual void scrollInView(Real x, Real y, Bool end);
// Generated message map functions
protected:
//{{AFX_MSG(CWorldBuilderView)
afx_msg void OnPaint();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnShowGrid();
afx_msg void OnUpdateShowGrid(CCmdUI* pCmdUI);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnViewShowtexture();
afx_msg void OnUpdateViewShowtexture(CCmdUI* pCmdUI);
// afx_msg void OnViewShowcontours();
// afx_msg void OnUpdateViewShowcontours(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.