-
Notifications
You must be signed in to change notification settings - Fork 0
/
InfoSheet.cpp
335 lines (303 loc) · 8.86 KB
/
InfoSheet.cpp
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
// InfoSheet.cpp : implementation file
//
#include "StdH.h"
#include "InfoSheet.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInfoSheet
#if SE1_TERRAINS
#define CALLACTIVEPAGE_TERRAIN(function, parameter) if (pgActivPage == &m_PgTerrain) m_PgTerrain.function(parameter);
#else
#define CALLACTIVEPAGE_TERRAIN(function, parameter)
#endif
#define CALLACTIVEPAGE(function, parameter) \
if( pgActivPage == &m_PgGlobal) \
m_PgGlobal.function( parameter); \
CALLACTIVEPAGE_TERRAIN(function, parameter); \
if( pgActivPage == &m_PgPosition) \
m_PgPosition.function( parameter); \
if( pgActivPage == &m_PgRenderingStatistics) \
m_PgRenderingStatistics.function( parameter); \
if( pgActivPage == &m_PgPolygon) \
m_PgPolygon.function( parameter); \
if( pgActivPage == &m_PgShadow) \
m_PgShadow.function( parameter); \
if( pgActivPage == &m_PgSector) \
m_PgSector.function( parameter); \
if( pgActivPage == &m_PgTexture) \
m_PgTexture.function( parameter); \
if( pgActivPage == &m_PgPrimitive) \
m_PgPrimitive.function( parameter);
IMPLEMENT_DYNAMIC(CInfoSheet, CPropertySheet)
CInfoSheet::CInfoSheet(CWnd* pWndParent)
: CPropertySheet(AFX_IDS_APP_TITLE, pWndParent)
{
// Add all pages so frame could get bounding sizes of all of them
AddPage( &m_PgGlobal);
#if SE1_TERRAINS
AddPage( &m_PgTerrain);
#endif
AddPage( &m_PgPosition);
AddPage( &m_PgPrimitive);
//AddPage( &m_PgRenderingStatistics);
AddPage( &m_PgPolygon);
AddPage( &m_PgShadow);
AddPage( &m_PgSector);
AddPage( &m_PgTexture);
SoftSetActivePage(0);
// set mode that will be discarded on first OnIdle()
m_ModeID = INFO_MODE_ALL;
}
CInfoSheet::~CInfoSheet()
{
}
// don't take focus
void CInfoSheet::SoftSetActivePage( INDEX iActivePage)
{
// get active view
CWorldEditorView *pWorldEditorView = theApp.GetActiveView();
SetActivePage( iActivePage);
if( pWorldEditorView != NULL)
{
// pWorldEditorView->SetFocus();
}
}
BEGIN_MESSAGE_MAP(CInfoSheet, CPropertySheet)
//{{AFX_MSG_MAP(CInfoSheet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInfoSheet message handlers
void CInfoSheet::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage *pgActivPage = GetActivePage();
CALLACTIVEPAGE(UpdateData, pDX->m_bSaveAndValidate);
CPropertySheet::DoDataExchange(pDX);
}
void CInfoSheet::DeleteAllPages()
{
// disable data exchange
theApp.m_bDisableDataExchange = TRUE;
INDEX iPagesCt, i;
iPagesCt = GetPageCount();
for( i=0; i<iPagesCt; i++)
RemovePage( 0);
// enable data exchange
theApp.m_bDisableDataExchange = FALSE;
}
void CInfoSheet::SetInfoModeGlobal(void)
{
m_ModeID = INFO_MODE_GLOBAL;
DeleteAllPages();
AddPage( &m_PgGlobal);
//AddPage( &m_PgRenderingStatistics);
SoftSetActivePage(0);
}
void CInfoSheet::SetInfoModePosition(void)
{
m_ModeID = INFO_MODE_POSITION;
DeleteAllPages();
AddPage( &m_PgGlobal);
//AddPage( &m_PgRenderingStatistics);
AddPage( &m_PgPosition);
SoftSetActivePage(1);
}
void CInfoSheet::SetInfoModePrimitive(void)
{
m_ModeID = INFO_MODE_PRIMITIVE;
DeleteAllPages();
AddPage( &m_PgGlobal);
//AddPage( &m_PgRenderingStatistics);
AddPage( &m_PgPosition);
AddPage( &m_PgPrimitive);
SoftSetActivePage(2);
}
INDEX _iLastActivePgInPolygonMode = 1;
void CInfoSheet::SetInfoModePolygon(void)
{
m_ModeID = INFO_MODE_POLYGON;
DeleteAllPages();
AddPage( &m_PgGlobal);
//AddPage( &m_PgRenderingStatistics);
AddPage( &m_PgPolygon);
AddPage( &m_PgShadow);
AddPage( &m_PgTexture);
SoftSetActivePage( _iLastActivePgInPolygonMode);
}
void CInfoSheet::SetInfoModeSector(void)
{
m_ModeID = INFO_MODE_SECTOR;
DeleteAllPages();
AddPage( &m_PgGlobal);
//AddPage( &m_PgRenderingStatistics);
AddPage( &m_PgSector);
SoftSetActivePage(1);
}
#if SE1_TERRAINS
void CInfoSheet::SetInfoModeTerrain(void)
{
m_ModeID = INFO_MODE_TERRAIN;
DeleteAllPages();
AddPage( &m_PgGlobal);
AddPage( &m_PgTerrain);
SoftSetActivePage(1);
}
#endif
BOOL CInfoSheet::OnIdle(LONG lCount)
{
// get active view
CWorldEditorView *pWorldEditorView = theApp.GetActiveView();
// get active document
CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
// if we don't have view
if( pDoc == NULL)
{
// force info mode: INFO_MODE_GLOBAL
if( m_ModeID != INFO_MODE_GLOBAL)
{
SetInfoModeGlobal();
CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
pMainFrame->SetFocus();
}
}
else
{
// if CSG is on
if( pDoc->m_iMode == CSG_MODE)
{
ASSERT(pDoc->m_pwoSecondLayer != NULL);
// if CSG is done with primitive force info mode: INFO_MODE_PRIMITIVE
if( pDoc->m_bPrimitiveMode)
{
if( m_ModeID != INFO_MODE_PRIMITIVE)
{
// primitive mode includes position page
SetInfoModePrimitive();
}
}
// else force info mode: INFO_MODE_POSITION
else
{
if( m_ModeID != INFO_MODE_POSITION)
{
// no primitive page, only position page
SetInfoModePosition();
}
}
}
// else if we are in entity mode and only one entity is selected,
// force info mode: INFO_MODE_POSITION
else if( (pDoc->m_iMode == ENTITY_MODE) && (pDoc->m_selEntitySelection.Count() == 1) )
{
if( m_ModeID != INFO_MODE_POSITION)
{
SetInfoModePosition();
}
}
// else if we are in polygon mode
else if( pDoc->m_iMode == POLYGON_MODE)
{
if( m_ModeID == INFO_MODE_POLYGON)
{
if( GetActivePage() == &m_PgTexture) _iLastActivePgInPolygonMode = 1;
else if( GetActivePage() == &m_PgShadow)_iLastActivePgInPolygonMode = 2;
else _iLastActivePgInPolygonMode = 3;
}
if( m_ModeID != INFO_MODE_POLYGON)
{
SetInfoModePolygon();
}
}
// else if we are in sector mode
else if( pDoc->m_iMode == SECTOR_MODE)
{
if( m_ModeID != INFO_MODE_SECTOR)
{
SetInfoModeSector();
}
}
#if SE1_TERRAINS
// else if we are in terrain mode
else if( pDoc->m_iMode == TERRAIN_MODE)
{
if( m_ModeID != INFO_MODE_TERRAIN)
{
SetInfoModeTerrain();
}
}
#endif
// we are not in CSG mode nor in single entity mode, force info mode: INFO_MODE_GLOBAL
else
{
if( m_ModeID != INFO_MODE_GLOBAL)
{
SetInfoModeGlobal();
}
}
}
// call OnIdle() for active page
CPropertyPage *pgActivPage = GetActivePage();
CALLACTIVEPAGE(OnIdle, lCount);
return TRUE;
}
void CInfoSheet::PostNcDestroy()
{
CPropertySheet::PostNcDestroy();
delete this;
}
BOOL CInfoSheet::PreTranslateMessage(MSG* pMsg)
{
CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
BOOL bAlt = (GetKeyState( VK_MENU)&0x8000) != 0;
if(pMsg->message==WM_KEYDOWN)
{
// get active document
BOOL bSectorNameTyping = FALSE;
CPropertyPage *pgActivPage = GetActivePage();
if(pgActivPage == &m_PgSector)
{
bSectorNameTyping = m_PgSector.GetDlgItem( IDC_SECTOR_NAME) == CWnd::GetFocus();
}
if( (pMsg->wParam==VK_SPACE) && !bSectorNameTyping)
{
// don't translate message
return TRUE;
}
// if we have valid document
if( (pDoc != NULL) && !bSectorNameTyping)
{
if( (pMsg->wParam==VK_ADD) ||
(pMsg->wParam==VK_SUBTRACT) ||
(pMsg->wParam=='E') ||
(pMsg->wParam=='S') ||
(pMsg->wParam=='P') ||
(pMsg->wParam=='Z') ||
(pMsg->wParam=='Q') ||
(pMsg->wParam== VK_DECIMAL) )
{
// post this message to main frame
::PostMessage( pMainFrame->m_hWnd, WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
// don't translate message
return TRUE;
}
}
}
return CPropertySheet::PreTranslateMessage(pMsg);
}