/
mainframe.cpp
372 lines (313 loc) · 10.1 KB
/
mainframe.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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2009 Warzone Resurrection Project
Warzone 2100 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 2 of the License, or
(at your option) any later version.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
$Revision: 6617 $
$Id: mainframe.cpp 6617 2009-02-10 18:01:48Z devurandom $
$HeadURL: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk/tools/editworld/src/mainframe.cpp $
*/
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "btedit.h"
#include "mainframe.h"
#include "bteditdoc.h"
#include "bteditview.h"
//#include "dbview.h"
#include "tdview.h"
#include "textureview.h"
#include "wfview.h"
extern int g_MaxXRes; // 3d view size.
extern int g_MaxYRes;
int g_DispXRes;
int g_DispYRes;
// Splitter layout, 0,1 or 2.
#define LAYOUT 1
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_INITMENU()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_SEPARATOR, // status line indicator
ID_SEPARATOR, // status line indicator
// ID_INDICATOR_CAPS,
// ID_INDICATOR_NUM,
// ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar2.Create(this) ||
!m_wndToolBar2.LoadToolBar(IDR_TILEFLAGS))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar3.Create(this) ||
!m_wndToolBar3.LoadToolBar(IDR_OBJECTSTATS))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
m_wndToolBar2.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar2); //,AFX_IDW_DOCKBAR_LEFT);
m_wndToolBar3.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar3.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar3,AFX_IDW_DOCKBAR_LEFT);
return 0;
}
#if LAYOUT == 0
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// Split the window in two vertically.
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
m_wndSplitter.SetColumnInfo(0,640, 0);
m_wndSplitter.SetRowInfo(0,480, 0);
// Now split the first pane in two horizontaly for the 3d and 2d views.
if (!m_wndSplitter3.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 0)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}
// Attach the 3d edit view class to the top pane.
if (!m_wndSplitter3.CreateView(0, 0,
RUNTIME_CLASS(CBTEditView), CSize(640, 480), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// And attach the 2d edit view to the bottom pane.
if (!m_wndSplitter3.CreateView(1, 0,
RUNTIME_CLASS(CWFView), CSize(640, 64), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CTextureView), CSize(20, 20), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
//// The second horizontal split.
// if (!m_wndSplitter2.CreateStatic(
// &m_wndSplitter, // our parent window is the first splitter
// 2, 1, // the new splitter is 2 rows, 1 column
// WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
// m_wndSplitter.IdFromRowCol(0, 1)
// // new splitter is in the first row, 2nd column of first splitter
// ))
// {
// TRACE0("Failed to create nested splitter\n");
// return FALSE;
// }
//
// if (!m_wndSplitter2.CreateView(0, 0,
// RUNTIME_CLASS(CDBView), CSize(20, 128), pContext))
// {
// TRACE0("Failed to create second pane\n");
// return FALSE;
// }
//// The second horizontal split.
// if (!m_wndSplitter2.CreateStatic(
// &m_wndSplitter, // our parent window is the first splitter
// 2, 1, // the new splitter is 2 rows, 1 column
// WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
// m_wndSplitter.IdFromRowCol(0, 1)
// // new splitter is in the first row, 2nd column of first splitter
// ))
// {
// TRACE0("Failed to create nested splitter\n");
// return FALSE;
// }
//
// if (!m_wndSplitter2.CreateView(0, 0,
// RUNTIME_CLASS(CDBView), CSize(20, 128), pContext))
// {
// TRACE0("Failed to create second pane\n");
// return FALSE;
// }
//
// if (!m_wndSplitter2.CreateView(1, 0,
// RUNTIME_CLASS(CTextureView), CSize(20, 20), pContext))
// {
// TRACE0("Failed to create second pane\n");
// return FALSE;
// }
return TRUE;
}
#elif LAYOUT == 1
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// Split the window in two vertically.
if (!m_wndSplitter.CreateStatic(this, 1, 2)) // One row, 2 columns.
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
m_wndSplitter.SetColumnInfo(0,640, 0);
m_wndSplitter.SetRowInfo(0,480, 0);
// Now split the first pane in two horizontaly for the 3d and 2d views.
if (!m_wndSplitter3.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}
// Attach the 3d edit view class to the top pane.
if (!m_wndSplitter3.CreateView(0, 0,
RUNTIME_CLASS(CBTEditView), CSize(g_MaxXRes,g_MaxYRes), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// And attach the 2d edit view to the bottom pane.
if (!m_wndSplitter3.CreateView(1, 0,
RUNTIME_CLASS(CWFView), CSize(g_MaxXRes, 64), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CTextureView), CSize(g_DispXRes-g_MaxXRes, 20), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
return TRUE;
}
#elif LAYOUT == 2
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// Split the window in two vertically.
if (!m_wndSplitter.CreateStatic(this, 1, 2)) // One row, 2 columns.
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
m_wndSplitter.SetColumnInfo(0,640, 0);
m_wndSplitter.SetRowInfo(0,480, 0);
// Now split the first pane in two horizontaly for the 3d and 2d views.
if (!m_wndSplitter3.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
1, 2, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}
// Attach the 3d edit view class to the top pane.
if (!m_wndSplitter3.CreateView(0, 0,
RUNTIME_CLASS(CBTEditView), CSize(800, 800), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// And attach the 2d edit view to the bottom pane.
if (!m_wndSplitter3.CreateView(0, 1,
RUNTIME_CLASS(CWFView), CSize(640, 64), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CTextureView), CSize(128, 20), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
return TRUE;
}
#endif
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_MAXIMIZE;
// Set the window screen size and center it
cs.cy = ::GetSystemMetrics(SM_CYMAXIMIZED);
cs.cx = ::GetSystemMetrics(SM_CXMAXIMIZED);
cs.y = ((cs.cy) - cs.cy) / 2;
cs.x = ((cs.cx) - cs.cx) / 2;
g_DispXRes = cs.cx;
g_DispYRes = cs.cy;
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnInitMenu(CMenu* pMenu)
{
CFrameWnd::OnInitMenu(pMenu);
int Ret = pMenu->EnableMenuItem(ID_FILE_EXPORTWARZONESCENARIOEXPAND,MF_GRAYED);
}