-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFusionTabControls.cpp
323 lines (277 loc) · 7.89 KB
/
FusionTabControls.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
/****************************************************************************************/
/* FusionTabControls.cpp */
/* */
/* Author: Jim Mischel, Ken Baird, Jeff Lomax, John Moore */
/* Description: Tab control ui stuff */
/* */
/* The contents of this file are subject to the Genesis3D Public License */
/* Version 1.01 (the "License"); you may not use this file except in */
/* compliance with the License. You may obtain a copy of the License at */
/* http://www.genesis3d.com */
/* */
/* Software distributed under the License is distributed on an "AS IS" */
/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
/* the License for the specific language governing rights and limitations */
/* under the License. */
/* */
/* The Original Code is Genesis3D, released March 25, 1999. */
/*Genesis3D Version 1.1 released November 15, 1999 */
/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */
/* */
/****************************************************************************************/
/* This class will handle all coordination between the user tab interface
and the current document. If the user clicks on a tab, it has to update
itself using information from the current document. If the user makes
changes in the tab, it has to make sure that the current document is
updated in return... */
#include "stdafx.h"
#include "FusionTabControls.h"
#include "BrushEntityDialog.h"
#include "TextureDialog.h"
#include "ChildFrm.h"
#include "brushgroupdialog.h"
#include "FusionDoc.h"
#include "Model.h"
#include "ModelDialog.h"
#include "SkyDialog.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFusionTabControls
CFusionTabControls::CFusionTabControls( CDialogBar* pDBar)
{
// Create a pointer to the main window...
m_pMainFrame =(CMainFrame *)AfxGetMainWnd();
LastView =(CMainFrame *)AfxGetMainWnd();
m_pBrushEntityDialog=NULL;
m_pTextureDialog =NULL;
ConTab =NULL;
GrpTab =NULL;
ModelTab =NULL;
SkyTab =NULL;
// Create a pointer to the main window's CDialogBar...
m_pDialogBar =pDBar;
}
CFusionTabControls::~CFusionTabControls()
{
if( m_pBrushEntityDialog )
{
delete m_pBrushEntityDialog;
m_pBrushEntityDialog = NULL;
}
if( m_pTextureDialog )
{
delete m_pTextureDialog;
m_pTextureDialog = NULL;
}
if(ConTab)
{
delete ConTab;
ConTab=NULL;
}
if(GrpTab)
{
delete GrpTab;
GrpTab=NULL;
}
if( ModelTab)
{
delete ModelTab ;
ModelTab = NULL ;
}
if (SkyTab)
{
delete SkyTab;
SkyTab = NULL;
}
}/* ~CFusionTabControls */
BEGIN_MESSAGE_MAP(CFusionTabControls, CTabCtrl)
//{{AFX_MSG_MAP(CFusionTabControls)
ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelchange)
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFusionTabControls message handlers
struct TabItem
{
UINT WhichTab;
char *Text;
};
static const TabItem Tabs[] =
{
{BRUSH_ENTITY_TAB, "Template"},
{TEXTURE_TAB, "Textures"},
{GROUP_TAB, "Groups"},
{CONSOLE_TAB, "Console"},
{MODEL_TAB, "Models"},
{SKY_TAB, "Sky"}
};
static const int NumTabs = sizeof (Tabs) / sizeof (TabItem);
BOOL CFusionTabControls::CreateTabs()
{
int tab;
for (tab = 0; tab < NumTabs; ++tab)
{
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = Tabs[tab].Text;
InsertItem (Tabs[tab].WhichTab, &item);
}
m_CurrentTab = GetCurSel();
return TRUE;
}
#pragma warning (disable:4100)
void CFusionTabControls::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult)
{
// Which tab is now currently selected?
m_CurrentTab = GetCurSel();
UpdateTabs();
*pResult = 0;
}
#pragma warning (default:4100)
// This handles overall tab updates. NEEDS TO BE CALLED RIGHT AFTER DOCUMENT CREATION!
void CFusionTabControls::UpdateTabs()
{
CFusionDoc * pDoc = NULL;
CChildFrame * pActiveChild ;
int UpdateBrushEntity =1;
int UpdateTexture =1;
pActiveChild = (CChildFrame *)m_pMainFrame->MDIGetActive() ;
if(pActiveChild != NULL)
{
pDoc = (CFusionDoc*) pActiveChild->GetActiveDocument() ;
}
if (pActiveChild == NULL || pDoc == NULL )
{ // There are no open documents right now...
return; // command failed
}
// Let's create the tab dialogs for the first time if not done so...
if( m_pBrushEntityDialog == NULL )
{
m_pBrushEntityDialog = new CBrushEntityDialog( this, pDoc );
UpdateBrushEntity = 0;
}
else
{
// Let's make it invisible...
m_pBrushEntityDialog->ShowWindow( SW_HIDE );
}
if( m_pTextureDialog == NULL )
{
m_pTextureDialog = new CTextureDialog( this, pDoc );
UpdateTexture = 0;
}
if(ConTab==NULL)
{
ConTab=new CConsoleTab(this, pDoc);
}
if(GrpTab==NULL)
{
GrpTab=new CBrushGroupDialog(this, pDoc);
}
if( ModelTab==NULL )
{
ModelTab=new CModelDialog( this ) ;
ModelTab->Create( IDD_MODELKEY, this ) ;
}
if (SkyTab == NULL)
{
SkyTab = new CSkyDialog (this, pDoc);
}
ConTab->ShowWindow(SW_HIDE);
ConTab->SetConHwnd();
GrpTab->ShowWindow(SW_HIDE);
ModelTab->ShowWindow(SW_HIDE);
SkyTab->ShowWindow (SW_HIDE);
// This one should always be invisible. Even to start out with...
m_pTextureDialog->ShowWindow( SW_HIDE );
// Update all tabs...
ModelTab->Update(pDoc, Level_GetModelInfo (pDoc->pLevel)) ;
m_pBrushEntityDialog->Update( pDoc );
m_pTextureDialog->Update( pDoc );
GrpTab->UpdateTabDisplay(pDoc);
SkyTab->Update (pDoc);
// Which tab do we show..?
switch( m_CurrentTab )
{
case BRUSH_ENTITY_TAB:
if( UpdateBrushEntity )
{
// Make it visible...
m_pBrushEntityDialog->ShowWindow( SW_SHOW );
}
break;
case TEXTURE_TAB:
if( UpdateTexture )
{
// Make it visible...
m_pTextureDialog->ShowWindow( SW_SHOW );
}
break;
case GROUP_TAB:
GrpTab->ShowWindow(SW_SHOW);
break;
case CONSOLE_TAB:
ConTab->ShowWindow( SW_SHOW );
break;
case MODEL_TAB:
ModelTab->ShowWindow( SW_SHOW ) ;
break ;
case SKY_TAB :
SkyTab->ShowWindow (SW_SHOW);
break;
}
}
const char *CFusionTabControls::GetCurrentTexture()
{
return m_pTextureDialog->GetCurrentTexture();
}
void CFusionTabControls::SelectTexture(int SelNum)
{
if(m_CurrentTab != TEXTURE_TAB)
{
m_CurrentTab =TEXTURE_TAB;
SetCurSel (TEXTURE_TAB);
UpdateTabs();
}
m_pTextureDialog->SelectTexture(SelNum);
}
void CFusionTabControls::UpdateTextures (void)
{
m_pTextureDialog->m_TxlibChanged = true;
if (m_CurrentTab == TEXTURE_TAB)
{
UpdateTabs ();
}
}
// Use this whenever the user closes all documents...
void CFusionTabControls::DisableAllTabDialogs()
{
if( m_pBrushEntityDialog )
m_pBrushEntityDialog->ShowWindow( SW_HIDE );
if(ConTab)
ConTab->ShowWindow(SW_HIDE);
if(GrpTab)
ConTab->ShowWindow(SW_HIDE);
if(ModelTab)
ModelTab->ShowWindow(SW_HIDE);
if( m_pTextureDialog )
{
m_pTextureDialog->Update( NULL );
m_pTextureDialog->ShowWindow( SW_HIDE );
}
if (SkyTab != NULL)
{
SkyTab->ShowWindow (SW_HIDE);
}
}/* CFusionTabControls::DisableAllTabDialogs */
void CFusionTabControls::OnSetFocus(CWnd* pOldWnd)
{
// CTabCtrl::OnSetFocus(pOldWnd);
LastView=pOldWnd;
}