File: PreviewDlg.cpp

package info (click to toggle)
dhewm3 1.5.1~pre%2Bgit20200905%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye
  • size: 21,664 kB
  • sloc: cpp: 408,868; ansic: 1,188; objc: 1,034; python: 330; sh: 94; makefile: 11
file content (670 lines) | stat: -rw-r--r-- 18,002 bytes parent folder | download
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
/*
===========================================================================

Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.

This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").

Doom 3 Source Code 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.

Doom 3 Source Code 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 Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.

In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.

If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.

===========================================================================
*/

#include "tools/edit_gui_common.h"


#include "qe3.h"
#include "Radiant.h"
#include "WaitDlg.h"
#include "PreviewDlg.h"
#include "CommentsDlg.h"

const int PARENTID = 99999;

extern HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent);

// CPreviewDlg dialog

IMPLEMENT_DYNAMIC(CPreviewDlg, CDialog)
CPreviewDlg::CPreviewDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPreviewDlg::IDD, pParent)
{
	currentMode = MODELS;
	disablePreview = false;
}

CPreviewDlg::~CPreviewDlg()
{
}

void CPreviewDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE_MEDIA, treeMedia);
	DDX_Control(pDX, IDC_EDIT_INFO, editInfo);
	DDX_Control(pDX, IDC_PREVIEW, wndPreview);
}


BEGIN_MESSAGE_MAP(CPreviewDlg, CDialog)
	ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_MEDIA, OnTvnSelchangedTreeMedia)
	ON_BN_CLICKED(IDC_BUTTON_RELOAD, OnBnClickedButtonReload)
	ON_BN_CLICKED(IDC_BUTTON_ADD, OnBnClickedButtonAdd)
	ON_BN_CLICKED(IDC_BUTTON_PLAY, OnBnClickedButtonPlay)
END_MESSAGE_MAP()


// CPreviewDlg message handlers

BOOL CPreviewDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255));
	treeMedia.SetImageList(&m_image, TVSIL_NORMAL);
	if ( disablePreview ) {
		wndPreview.ShowWindow( SW_HIDE );
	} else {
		wndPreview.setDrawable(&m_testDrawable);
	}

	SetMode(currentMode);
	BuildTree();

	if ( mediaName.Length() ) {
		HTREEITEM root = treeMedia.GetRootItem();
		HTREEITEM sel = FindTreeItem(&treeMedia, root, mediaName, NULL );
		if (sel) {
			treeMedia.SelectItem(sel);
		}
	}
	mediaName = "";
	return TRUE;  // return TRUE unless you set the focus to a control

}

void CPreviewDlg::BuildTree() {

	CWaitCursor cursor;
	quickTree.Clear();
	treeMedia.DeleteAllItems();

	idFileList *files;

	if ( currentMode == GUIS ) {
		files = fileSystem->ListFilesTree( "guis", ".gui" );
		AddStrList( "base", files->GetList(), GUIS );
		fileSystem->FreeFileList( files );
	} else if ( currentMode == MODELS ) {
		files = fileSystem->ListFilesTree( "models", ".lwo" );
		AddStrList( "base", files->GetList(), MODELS );
		fileSystem->FreeFileList( files );
		files = fileSystem->ListFilesTree( "models", ".ase" );
		AddStrList( "base", files->GetList(), MODELS );
		fileSystem->FreeFileList( files );
		files = fileSystem->ListFilesTree( "models", ".ma" );
		AddStrList( "base", files->GetList(), MODELS );
		fileSystem->FreeFileList( files );
	} else if ( currentMode == SOUNDS ) {
		AddSounds( true );
	} else if ( currentMode == MATERIALS ) {
		AddMaterials( true );
	} else if ( currentMode == PARTICLES ) {
		AddParticles( true );
	} else if ( currentMode == SKINS ) {
		AddSkins( true );
	}
}

void CPreviewDlg::RebuildTree( const char *_data ) {
	data = _data;
	data.ToLower();
	BuildTree();
}

void CPreviewDlg::AddCommentedItems() {
	const char *buffer = NULL;
	const char *path;
	items.Clear();
	path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
	idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
	if (fileSystem->ReadFile(path, (void**)&buffer, NULL) && buffer) {
		src.LoadMemory(buffer, strlen(buffer), path);
		if (src.IsLoaded()) {
			idToken token, tok1, tok2, tok3;
			while( src.ReadToken( &token ) ) {
				if (token == "{") {
					// start a new commented item
					CommentedItem ci;
					if (src.ReadToken(&tok1) && src.ReadToken(&tok2) && src.ReadToken(&tok3)) {
						ci.Name = tok1;
						ci.Path = tok2;
						ci.Comments = tok3;
						items.Append(ci);
					}
				}
			}
		}
		fileSystem->FreeFile((void*)buffer);
	}
	commentItem = treeMedia.InsertItem("Commented");
	int c = items.Num();
	if (c) {
		for (int i = 0; i < c; i++) {
			HTREEITEM child = treeMedia.InsertItem(items[i].Name, commentItem);
			treeMedia.SetItemData(child, -1 - i);
			treeMedia.SetItemImage(child, 2, 2);
		}
	}
}



void CPreviewDlg::AddStrList( const char *root, const idStrList &list, int id ) {
	idStr		out, path;
	HTREEITEM	base = treeMedia.GetRootItem();
	if (base) {
		out = treeMedia.GetItemText(base);
		if (stricmp(root, out)) {
			base = NULL;
		}
	}

	if (base == NULL) {
		base = treeMedia.InsertItem(root);
		treeMedia.SetItemData(base, PARENTID);
	}

	HTREEITEM	item = base;
	HTREEITEM	add;

	int		count = list.Num();

	idStr	last, qt;
	for (int i = 0; i < count; i++) {
		idStr name = list[i];

		// now break the name down convert to slashes
		name.BackSlashesToSlashes();
		name.Strip(' ');

		int index;
		int len = last.Length();
		if (len == 0) {
			index = name.Last('/');
			if (index >= 0) {
				name.Left(index, last);
			}
		}
		else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
			name.Right(name.Length() - len - 1, out);
			add = treeMedia.InsertItem(out, item);
			qt = root;
			qt += "/";
			qt += name;
			quickTree.Set(qt, add);
			treeMedia.SetItemImage(add, 2, 2);
			treeMedia.SetItemData(add, id);
			continue;
		}
		else {
			last.Empty();
		}

		index = 0;
		item = base;
		path = "";
		while (index >= 0) {
			index = name.Find('/');
			if (index >= 0) {
				HTREEITEM newItem = NULL;
				HTREEITEM *check = NULL;
				name.Left( index, out );
				path += out;
				qt = root;
				qt += "/";
				qt += path;
				if (quickTree.Get(qt, &check)) {
					newItem = *check;
				}
				//HTREEITEM	newItem = FindTreeItem(&treeMedia, item, name.Left(index, out), item);
				if (newItem == NULL) {
					newItem = treeMedia.InsertItem(out, item);
					qt = root;
					qt += "/";
					qt += path;
					quickTree.Set(qt, newItem);
					treeMedia.SetItemImage(newItem, 0, 1);
					treeMedia.SetItemData(newItem, PARENTID);
				}

				assert(newItem);
				item = newItem;
				name.Right(name.Length() - index - 1, out);
				name = out;
				path += "/";
			}
			else {
				add = treeMedia.InsertItem(name, item);
				qt = root;
				qt += "/";
				qt += path;
				qt += name;
				quickTree.Set(qt, add);
				treeMedia.SetItemImage(add, 2, 2);
				treeMedia.SetItemData(add, id);
				path = "";
			}
		}
	}

}

void CPreviewDlg::OnTvnSelchangedTreeMedia(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
	HTREEITEM item = treeMedia.GetSelectedItem();
	mediaName = "";
	CWnd *add = GetDlgItem(IDC_BUTTON_ADD);
	if (add) {
		add->EnableWindow(treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS);
	}
	if (item) {

		editInfo.SetWindowText("No comments for this item");
		int id = treeMedia.GetItemData(item);
		if ( id == GUIS || id == MODELS || id == MATERIALS || id == WAVES || id == PARTICLES || id == SKINS ) {
			mediaName = treeMedia.GetItemText( item );

			// have to build the name back up
			HTREEITEM parent = treeMedia.GetParentItem( item );
			while ( parent != NULL ) {
				idStr strParent = treeMedia.GetItemText( parent );
				strParent += "/";
				strParent += mediaName;
				mediaName = strParent;
				parent = treeMedia.GetParentItem( parent );
			}
			// strip the leading "base/"
			if (id == MATERIALS) {
				mediaName.Strip("Materials/"); // FIXME: SteelStorm2 has a _v1 suffix here
			} else if (id == WAVES) {
				mediaName.Strip( "Wave files/" );
			} else if (id == PARTICLES) {
				mediaName.Strip("Particles/");
				mediaName += ".prt";
			} else if ( id == SKINS ) {
				mediaName.Strip( "Matching Skins/" );
				mediaName.Strip( "Skins/" );
			} else {
				mediaName.Strip( "base/" );
			}

		} else if (id == WAVES || id == SOUNDS) {
			mediaName = treeMedia.GetItemText( item );
		} else if (id < 0) {
			if ( treeMedia.ItemHasChildren(item) == FALSE ) {
				int dw = abs(( int )treeMedia.GetItemData( item )) - 1;
				if ( dw < items.Num() ) {
					idStr work = items[dw].Path;
					work += "\r\n\r\n";
					work += items[dw].Comments;
					editInfo.SetWindowText( work );
					mediaName = items[dw].Path;
				}
			}
		}

		if ( currentMode == MODELS || currentMode == SKINS ) {
			idStr modelMedia;
			if ( currentMode == MODELS ) {
				modelMedia = mediaName;
			} else {
				modelMedia = data;
			}
			if ( modelMedia.Length() ) {
				int size = fileSystem->ReadFile( modelMedia, NULL, NULL );
				int lsize;
				if ( strstr( modelMedia, ".lwo" ) ) {
					lsize = 128 * 1024;
				}
				else {
					lsize = 768 * 1024;
				}
				if ( size > lsize ) {
					if ( MessageBox("Model appears to be quite large, are you sure you want to preview it?", "High Poly Model?", MB_YESNO ) == IDNO ) {
						*pResult = 0;
						return;
					}
				}
				m_drawModel.setMedia( modelMedia );
				if ( currentMode == SKINS ) {
					m_drawModel.SetSkin( mediaName );
				}
			}
			m_drawModel.SetRealTime(0);
			wndPreview.setDrawable( &m_drawModel );
			wndPreview.Invalidate();
			wndPreview.RedrawWindow();
			RedrawWindow();
		}
		else if ( currentMode == PARTICLES ) {
			m_drawModel.setMedia( mediaName );
			m_drawModel.SetRealTime(50);
			wndPreview.setDrawable( &m_drawModel );
			wndPreview.Invalidate();
			wndPreview.RedrawWindow();
			RedrawWindow();
		} else if ( currentMode == GUIS ) {
			const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
			mat->SetGui(mediaName);
			m_drawMaterial.setMedia("guisurfs/guipreview");
			m_drawMaterial.setScale(4.4f);
			wndPreview.setDrawable(&m_drawMaterial);
			wndPreview.Invalidate();
			wndPreview.RedrawWindow();
			idUserInterface *gui = uiManager->FindGui( mediaName, false, false, true );
			if ( gui ) {
				idStr str = gui->Comment();
				str.Replace( "\n", "\r\n" );
				if ( str != "" ) {
					editInfo.SetWindowText( str );
				}
			}
			RedrawWindow();
		} else if (currentMode == MATERIALS) {
			m_drawMaterial.setMedia(mediaName);
			m_drawMaterial.setScale(1.0);
			wndPreview.setDrawable(&m_drawMaterial);
			wndPreview.Invalidate();
			wndPreview.RedrawWindow();
			RedrawWindow();
		}

		//m_drawGui.setMedia(matName);
		//wndPreview.setDrawable(&m_drawMaterial);
		//wndPreview.RedrawWindow();
	}

	*pResult = 0;
}


BOOL CPreviewDlg::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
	BOOL b =  CDialog::Create(lpszTemplateName, pParentWnd);
	ShowWindow(SW_SHOW);
	return b;
}

void CPreviewDlg::OnCancel()
{
	if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
		GetParent()->EnableWindow(TRUE);
		g_qeglobals.sw->StopAllSounds();
		ShowWindow(SW_HIDE);
	} else {
		CDialog::OnCancel();
	}
	returnCode = IDCANCEL;
}

void CPreviewDlg::OnOK()
{
	if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
		GetParent()->EnableWindow(TRUE);
		g_qeglobals.sw->StopAllSounds();
		ShowWindow(SW_HIDE);
	} else {
		CDialog::OnOK();
	}
	returnCode = IDOK;
}

bool CPreviewDlg::Waiting() {
	AfxGetApp()->PumpMessage();
	return (returnCode == -1);
}

void CPreviewDlg::SetModal() {
	returnCode = -1;
}
void CPreviewDlg::OnBnClickedButtonReload()
{
	BuildTree();
	if(g_qeglobals.sw != NULL)
		g_qeglobals.sw->StopAllSounds();
}

void CPreviewDlg::OnBnClickedButtonAdd()
{
	HTREEITEM item = treeMedia.GetSelectedItem();
	if (treeMedia.ItemHasChildren(item) == FALSE && (treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS)) {
		CCommentsDlg dlg;
		dlg.strPath = mediaName;
		if (dlg.DoModal()) {
			CommentedItem ci;
			ci.Name = dlg.strName;
			ci.Path = dlg.strPath;
			ci.Comments = dlg.strComments;
			items.Append(ci);
			item = treeMedia.InsertItem(ci.Name, commentItem);
			treeMedia.SetItemData(item, -1 - (items.Num() + 1));
			treeMedia.SetItemImage(item, 2, 2);
			const char *path;
			path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
			idStr str;
			void *buffer;
			fileSystem->ReadFile( path, &buffer );
			str = (char *) buffer;
			fileSystem->FreeFile( buffer );
			str += "\r\n\r\n{\r\n\t\"";
			str += ci.Name;
			str += "\"\r\n\t\"";
			str += ci.Path;
			str += "\"\r\n\t\"";
			str += ci.Comments;
			str += "\"\r\n}\r\n";
			fileSystem->WriteFile(path, (void*)&str[0], str.Length(), "fs_devpath");

		}
	}
}


void CPreviewDlg::AddSounds(bool rootItems) {
	int i, j;
	idStrList list(1024);
	idStrList list2(1024);
	HTREEITEM base = treeMedia.InsertItem("Sound Shaders");

	for( i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++ ) {
		const idSoundShader *poo = declManager->SoundByIndex( i, false );
		list.AddUnique( poo->GetFileName() );
	}
	list.Sort();

	for ( i = 0; i < list.Num(); i++ ) {
		HTREEITEM child = treeMedia.InsertItem(list[i], base);
		treeMedia.SetItemData(child, SOUNDPARENT);
		treeMedia.SetItemImage(child, 0, 1);
		list2.Clear();
		for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) {
			const idSoundShader *poo = declManager->SoundByIndex( j, false );
			if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) {
				list2.Append( poo->GetName() );
			}
		}
		list2.Sort();
		for (j = 0; j < list2.Num(); j++) {
			HTREEITEM child2 = treeMedia.InsertItem( list2[j], child );
			treeMedia.SetItemData(child2, SOUNDS);
			treeMedia.SetItemImage(child2, 2, 2);
		}
	}

	idFileList *files;
	files = fileSystem->ListFilesTree( "sound", ".wav" );
	AddStrList( "Wave files", files->GetList(), WAVES );
	fileSystem->FreeFileList( files );
}

void CPreviewDlg::SetMode( int mode, const char *preSelect ) {

	currentMode = mode;
	if ( preSelect ) {
		mediaName = preSelect;
	}

	if (GetSafeHwnd() == NULL) {
		return;
	}

	CWnd *wnd;
	switch (currentMode) {
		case GUIS :
		case SKINS :
		case MODELS :
		case PARTICLES :
				wndPreview.ShowWindow(SW_SHOW);
				wnd = GetDlgItem(IDC_BUTTON_PLAY);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
				wnd = GetDlgItem(IDC_BUTTON_ADD);
				if (wnd) {
					wnd->ShowWindow(SW_SHOW);
				}
				wnd = GetDlgItem(IDC_EDIT_INFO);
				if (wnd) {
					wnd->ShowWindow(SW_SHOW);
				}
			break;
		case MATERIALS :
				wndPreview.ShowWindow(SW_SHOW);
				wnd = GetDlgItem(IDC_BUTTON_PLAY);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
				wnd = GetDlgItem(IDC_BUTTON_ADD);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
				wnd = GetDlgItem(IDC_EDIT_INFO);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
				break;
		case SOUNDS :
		case WAVES :
				wndPreview.ShowWindow(SW_HIDE);
				wnd = GetDlgItem(IDC_BUTTON_PLAY);
				if (wnd) {
					wnd->ShowWindow(SW_SHOW);
				}
				wnd = GetDlgItem(IDC_BUTTON_ADD);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
				wnd = GetDlgItem(IDC_EDIT_INFO);
				if (wnd) {
					wnd->ShowWindow(SW_HIDE);
				}
			break;
	}
}

void CPreviewDlg::OnBnClickedButtonPlay() {
	g_qeglobals.sw->PlayShaderDirectly(mediaName);
}

void CPreviewDlg::AddMaterials(bool rootItems) {
	idStrList list(1024);
	//char temp[2048];
	int count = declManager->GetNumDecls( DECL_MATERIAL );
	if (count > 0) {
		for (int i = 0; i < count; i++) {
			const idMaterial *mat = declManager->MaterialByIndex(i, false);
			if (!rootItems) {
				if (strchr(mat->GetName(), '/') == NULL && strchr(mat->GetName(), '\\') == NULL) {
					continue;
				}
			}
			list.Append(mat->GetName());
		}
		list.Sort();
		AddStrList("Materials", list, MATERIALS); // FIXME: SteelStorm2 has a _v1 suffix here
	}

}

void CPreviewDlg::AddParticles(bool rootItems) {
	idStrList list(1024);
	int count = declManager->GetNumDecls( DECL_PARTICLE );
	if (count > 0) {
		for (int i = 0; i < count; i++) {
			const idDecl *ips = declManager->DeclByIndex( DECL_PARTICLE, i );
			if (!rootItems) {
				if (strchr(ips->GetName(), '/') == NULL && strchr(ips->GetName(), '\\') == NULL) {
					continue;
				}
			}
			list.Append(ips->GetName());
		}
		list.Sort();
		AddStrList("Particles", list, PARTICLES);
	}
}

void CPreviewDlg::AddSkins( bool rootItems ) {
	idStrList list(1024);
	idStrList list2(1024);
	idStr str;
	int count = declManager->GetNumDecls( DECL_SKIN );
	if (count > 0) {
		for (int i = 0; i < count; i++) {
			const idDeclSkin *skin = declManager->SkinByIndex(i);
			if (!rootItems) {
				if (strchr(skin->GetName(), '/') == NULL && strchr(skin->GetName(), '\\') == NULL) {
					continue;
				}
			}
			if ( data.Length() ) {
				for ( int j = 0; j < skin->GetNumModelAssociations(); j++ ){
					str = skin->GetAssociatedModel( j );
					str.ToLower();
					if ( data.Cmp(str) == 0 ) {
						list.Append(skin->GetName());
					}
				}
			}
			list2.Append(skin->GetName());
		}
		list.Sort();
		list2.Sort();
		AddStrList( "Matching Skins", list, SKINS );
		AddStrList( "Skins", list2, SKINS );
	}
}

void CPreviewDlg::OnShowWindow( BOOL bShow, UINT status ) {
	if ( bShow && AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
		GetParent()->EnableWindow( FALSE );
	}
}