PreviewDlg.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. #include "Radiant.h"
  24. #include "WaitDlg.h"
  25. #include "PreviewDlg.h"
  26. #include "CommentsDlg.h"
  27. const int PARENTID = 99999;
  28. extern HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent);
  29. // CPreviewDlg dialog
  30. IMPLEMENT_DYNAMIC(CPreviewDlg, CDialog)
  31. CPreviewDlg::CPreviewDlg(CWnd* pParent /*=NULL*/)
  32. : CDialog(CPreviewDlg::IDD, pParent)
  33. {
  34. currentMode = MODELS;
  35. disablePreview = false;
  36. }
  37. CPreviewDlg::~CPreviewDlg()
  38. {
  39. }
  40. void CPreviewDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. DDX_Control(pDX, IDC_TREE_MEDIA, treeMedia);
  44. DDX_Control(pDX, IDC_EDIT_INFO, editInfo);
  45. DDX_Control(pDX, IDC_PREVIEW, wndPreview);
  46. }
  47. BEGIN_MESSAGE_MAP(CPreviewDlg, CDialog)
  48. ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_MEDIA, OnTvnSelchangedTreeMedia)
  49. ON_BN_CLICKED(IDC_BUTTON_RELOAD, OnBnClickedButtonReload)
  50. ON_BN_CLICKED(IDC_BUTTON_ADD, OnBnClickedButtonAdd)
  51. ON_BN_CLICKED(IDC_BUTTON_PLAY, OnBnClickedButtonPlay)
  52. END_MESSAGE_MAP()
  53. // CPreviewDlg message handlers
  54. BOOL CPreviewDlg::OnInitDialog()
  55. {
  56. CDialog::OnInitDialog();
  57. m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255));
  58. treeMedia.SetImageList(&m_image, TVSIL_NORMAL);
  59. if ( disablePreview ) {
  60. wndPreview.ShowWindow( SW_HIDE );
  61. } else {
  62. wndPreview.setDrawable(&m_testDrawable);
  63. }
  64. SetMode(currentMode);
  65. BuildTree();
  66. if ( mediaName.Length() ) {
  67. HTREEITEM root = treeMedia.GetRootItem();
  68. HTREEITEM sel = FindTreeItem(&treeMedia, root, mediaName, NULL );
  69. if (sel) {
  70. treeMedia.SelectItem(sel);
  71. }
  72. }
  73. mediaName = "";
  74. return TRUE; // return TRUE unless you set the focus to a control
  75. }
  76. void CPreviewDlg::BuildTree() {
  77. CWaitCursor cursor;
  78. quickTree.Clear();
  79. treeMedia.DeleteAllItems();
  80. idFileList *files;
  81. if ( currentMode == GUIS ) {
  82. files = fileSystem->ListFilesTree( "guis", ".gui" );
  83. AddStrList( "base", files->GetList(), GUIS );
  84. fileSystem->FreeFileList( files );
  85. } else if ( currentMode == MODELS ) {
  86. files = fileSystem->ListFilesTree( "models", ".lwo" );
  87. AddStrList( "base", files->GetList(), MODELS );
  88. fileSystem->FreeFileList( files );
  89. files = fileSystem->ListFilesTree( "models", ".ase" );
  90. AddStrList( "base", files->GetList(), MODELS );
  91. fileSystem->FreeFileList( files );
  92. files = fileSystem->ListFilesTree( "models", ".ma" );
  93. AddStrList( "base", files->GetList(), MODELS );
  94. fileSystem->FreeFileList( files );
  95. } else if ( currentMode == SOUNDS ) {
  96. AddSounds( true );
  97. } else if ( currentMode == MATERIALS ) {
  98. AddMaterials( true );
  99. } else if ( currentMode == PARTICLES ) {
  100. AddParticles( true );
  101. } else if ( currentMode == SKINS ) {
  102. AddSkins( true );
  103. }
  104. }
  105. void CPreviewDlg::RebuildTree( const char *_data ) {
  106. data = _data;
  107. data.ToLower();
  108. BuildTree();
  109. }
  110. void CPreviewDlg::AddCommentedItems() {
  111. const char *buffer = NULL;
  112. const char *path;
  113. items.Clear();
  114. path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
  115. idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
  116. if (fileSystem->ReadFile(path, (void**)&buffer, NULL) && buffer) {
  117. src.LoadMemory(buffer, strlen(buffer), path);
  118. if (src.IsLoaded()) {
  119. idToken token, tok1, tok2, tok3;
  120. while( src.ReadToken( &token ) ) {
  121. if (token == "{") {
  122. // start a new commented item
  123. CommentedItem ci;
  124. if (src.ReadToken(&tok1) && src.ReadToken(&tok2) && src.ReadToken(&tok3)) {
  125. ci.Name = tok1;
  126. ci.Path = tok2;
  127. ci.Comments = tok3;
  128. items.Append(ci);
  129. }
  130. }
  131. }
  132. }
  133. fileSystem->FreeFile((void*)buffer);
  134. }
  135. commentItem = treeMedia.InsertItem("Commented");
  136. int c = items.Num();
  137. if (c) {
  138. for (int i = 0; i < c; i++) {
  139. HTREEITEM child = treeMedia.InsertItem(items[i].Name, commentItem);
  140. treeMedia.SetItemData(child, -1 - i);
  141. treeMedia.SetItemImage(child, 2, 2);
  142. }
  143. }
  144. }
  145. void CPreviewDlg::AddStrList( const char *root, const idStrList &list, int id ) {
  146. idStr out, path;
  147. HTREEITEM base = treeMedia.GetRootItem();
  148. if (base) {
  149. out = treeMedia.GetItemText(base);
  150. if (stricmp(root, out)) {
  151. base = NULL;
  152. }
  153. }
  154. if (base == NULL) {
  155. base = treeMedia.InsertItem(root);
  156. treeMedia.SetItemData(base, PARENTID);
  157. }
  158. HTREEITEM item = base;
  159. HTREEITEM add;
  160. int count = list.Num();
  161. idStr last, qt;
  162. for (int i = 0; i < count; i++) {
  163. idStr name = list[i];
  164. // now break the name down convert to slashes
  165. name.BackSlashesToSlashes();
  166. name.Strip(' ');
  167. int index;
  168. int len = last.Length();
  169. if (len == 0) {
  170. index = name.Last('/');
  171. if (index >= 0) {
  172. name.Left(index, last);
  173. }
  174. }
  175. else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
  176. name.Right(name.Length() - len - 1, out);
  177. add = treeMedia.InsertItem(out, item);
  178. qt = root;
  179. qt += "/";
  180. qt += name;
  181. quickTree.Set(qt, add);
  182. treeMedia.SetItemImage(add, 2, 2);
  183. treeMedia.SetItemData(add, id);
  184. continue;
  185. }
  186. else {
  187. last.Empty();
  188. }
  189. index = 0;
  190. item = base;
  191. path = "";
  192. while (index >= 0) {
  193. index = name.Find('/');
  194. if (index >= 0) {
  195. HTREEITEM newItem = NULL;
  196. HTREEITEM *check = NULL;
  197. name.Left( index, out );
  198. path += out;
  199. qt = root;
  200. qt += "/";
  201. qt += path;
  202. if (quickTree.Get(qt, &check)) {
  203. newItem = *check;
  204. }
  205. //HTREEITEM newItem = FindTreeItem(&treeMedia, item, name.Left(index, out), item);
  206. if (newItem == NULL) {
  207. newItem = treeMedia.InsertItem(out, item);
  208. qt = root;
  209. qt += "/";
  210. qt += path;
  211. quickTree.Set(qt, newItem);
  212. treeMedia.SetItemImage(newItem, 0, 1);
  213. treeMedia.SetItemData(newItem, PARENTID);
  214. }
  215. assert(newItem);
  216. item = newItem;
  217. name.Right(name.Length() - index - 1, out);
  218. name = out;
  219. path += "/";
  220. }
  221. else {
  222. add = treeMedia.InsertItem(name, item);
  223. qt = root;
  224. qt += "/";
  225. qt += path;
  226. qt += name;
  227. quickTree.Set(qt, add);
  228. treeMedia.SetItemImage(add, 2, 2);
  229. treeMedia.SetItemData(add, id);
  230. path = "";
  231. }
  232. }
  233. }
  234. }
  235. void CPreviewDlg::OnTvnSelchangedTreeMedia(NMHDR *pNMHDR, LRESULT *pResult)
  236. {
  237. LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
  238. HTREEITEM item = treeMedia.GetSelectedItem();
  239. mediaName = "";
  240. CWnd *add = GetDlgItem(IDC_BUTTON_ADD);
  241. if (add) {
  242. add->EnableWindow(treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS);
  243. }
  244. if (item) {
  245. editInfo.SetWindowText("No comments for this item");
  246. int id = treeMedia.GetItemData(item);
  247. if ( id == GUIS || id == MODELS || id == MATERIALS || id == WAVES || id == PARTICLES || id == SKINS ) {
  248. mediaName = treeMedia.GetItemText( item );
  249. // have to build the name back up
  250. HTREEITEM parent = treeMedia.GetParentItem( item );
  251. while ( parent != NULL ) {
  252. idStr strParent = treeMedia.GetItemText( parent );
  253. strParent += "/";
  254. strParent += mediaName;
  255. mediaName = strParent;
  256. parent = treeMedia.GetParentItem( parent );
  257. }
  258. // strip the leading "base/"
  259. if (id == MATERIALS) {
  260. mediaName.Strip("Materials/");
  261. } else if (id == WAVES) {
  262. mediaName.Strip( "Wave files/" );
  263. } else if (id == PARTICLES) {
  264. mediaName.Strip("Particles/");
  265. mediaName += ".prt";
  266. } else if ( id == SKINS ) {
  267. mediaName.Strip( "Matching Skins/" );
  268. mediaName.Strip( "Skins/" );
  269. } else {
  270. mediaName.Strip( "base/" );
  271. }
  272. } else if (id == WAVES || id == SOUNDS) {
  273. mediaName = treeMedia.GetItemText( item );
  274. } else if (id < 0) {
  275. if ( treeMedia.ItemHasChildren(item) == FALSE ) {
  276. int dw = abs(( int )treeMedia.GetItemData( item )) - 1;
  277. if ( dw < items.Num() ) {
  278. idStr work = items[dw].Path;
  279. work += "\r\n\r\n";
  280. work += items[dw].Comments;
  281. editInfo.SetWindowText( work );
  282. mediaName = items[dw].Path;
  283. }
  284. }
  285. }
  286. if ( currentMode == MODELS || currentMode == SKINS ) {
  287. idStr modelMedia;
  288. if ( currentMode == MODELS ) {
  289. modelMedia = mediaName;
  290. } else {
  291. modelMedia = data;
  292. }
  293. if ( modelMedia.Length() ) {
  294. int size = fileSystem->ReadFile( modelMedia, NULL, NULL );
  295. int lsize;
  296. if ( strstr( modelMedia, ".lwo" ) ) {
  297. lsize = 128 * 1024;
  298. }
  299. else {
  300. lsize = 768 * 1024;
  301. }
  302. if ( size > lsize ) {
  303. if ( MessageBox("Model appears to be quite large, are you sure you want to preview it?", "High Poly Model?", MB_YESNO ) == IDNO ) {
  304. *pResult = 0;
  305. return;
  306. }
  307. }
  308. m_drawModel.setMedia( modelMedia );
  309. if ( currentMode == SKINS ) {
  310. m_drawModel.SetSkin( mediaName );
  311. }
  312. }
  313. m_drawModel.SetRealTime(0);
  314. wndPreview.setDrawable( &m_drawModel );
  315. wndPreview.Invalidate();
  316. wndPreview.RedrawWindow();
  317. RedrawWindow();
  318. }
  319. else if ( currentMode == PARTICLES ) {
  320. m_drawModel.setMedia( mediaName );
  321. m_drawModel.SetRealTime(50);
  322. wndPreview.setDrawable( &m_drawModel );
  323. wndPreview.Invalidate();
  324. wndPreview.RedrawWindow();
  325. RedrawWindow();
  326. } else if ( currentMode == GUIS ) {
  327. const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
  328. mat->SetGui(mediaName);
  329. m_drawMaterial.setMedia("guisurfs/guipreview");
  330. m_drawMaterial.setScale(4.4f);
  331. wndPreview.setDrawable(&m_drawMaterial);
  332. wndPreview.Invalidate();
  333. wndPreview.RedrawWindow();
  334. idUserInterface *gui = uiManager->FindGui( mediaName, false, false, true );
  335. if ( gui ) {
  336. idStr str = gui->Comment();
  337. str.Replace( "\n", "\r\n" );
  338. if ( str != "" ) {
  339. editInfo.SetWindowText( str );
  340. }
  341. }
  342. RedrawWindow();
  343. } else if (currentMode == MATERIALS) {
  344. m_drawMaterial.setMedia(mediaName);
  345. m_drawMaterial.setScale(1.0);
  346. wndPreview.setDrawable(&m_drawMaterial);
  347. wndPreview.Invalidate();
  348. wndPreview.RedrawWindow();
  349. RedrawWindow();
  350. }
  351. //m_drawGui.setMedia(matName);
  352. //wndPreview.setDrawable(&m_drawMaterial);
  353. //wndPreview.RedrawWindow();
  354. }
  355. *pResult = 0;
  356. }
  357. BOOL CPreviewDlg::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
  358. {
  359. BOOL b = CDialog::Create(lpszTemplateName, pParentWnd);
  360. ShowWindow(SW_SHOW);
  361. return b;
  362. }
  363. void CPreviewDlg::OnCancel()
  364. {
  365. if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
  366. GetParent()->EnableWindow(TRUE);
  367. g_qeglobals.sw->StopAllSounds();
  368. ShowWindow(SW_HIDE);
  369. } else {
  370. CDialog::OnCancel();
  371. }
  372. returnCode = IDCANCEL;
  373. }
  374. void CPreviewDlg::OnOK()
  375. {
  376. if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
  377. GetParent()->EnableWindow(TRUE);
  378. g_qeglobals.sw->StopAllSounds();
  379. ShowWindow(SW_HIDE);
  380. } else {
  381. CDialog::OnOK();
  382. }
  383. returnCode = IDOK;
  384. }
  385. bool CPreviewDlg::Waiting() {
  386. AfxGetApp()->PumpMessage();
  387. return (returnCode == -1);
  388. }
  389. void CPreviewDlg::SetModal() {
  390. returnCode = -1;
  391. }
  392. void CPreviewDlg::OnBnClickedButtonReload()
  393. {
  394. BuildTree();
  395. g_qeglobals.sw->StopAllSounds();
  396. }
  397. void CPreviewDlg::OnBnClickedButtonAdd()
  398. {
  399. HTREEITEM item = treeMedia.GetSelectedItem();
  400. if (treeMedia.ItemHasChildren(item) == FALSE && (treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS)) {
  401. CCommentsDlg dlg;
  402. dlg.strPath = mediaName;
  403. if (dlg.DoModal()) {
  404. CommentedItem ci;
  405. ci.Name = dlg.strName;
  406. ci.Path = dlg.strPath;
  407. ci.Comments = dlg.strComments;
  408. items.Append(ci);
  409. item = treeMedia.InsertItem(ci.Name, commentItem);
  410. treeMedia.SetItemData(item, -1 - (items.Num() + 1));
  411. treeMedia.SetItemImage(item, 2, 2);
  412. const char *path;
  413. path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
  414. idStr str;
  415. void *buffer;
  416. fileSystem->ReadFile( path, &buffer );
  417. str = (char *) buffer;
  418. fileSystem->FreeFile( buffer );
  419. str += "\r\n\r\n{\r\n\t\"";
  420. str += ci.Name;
  421. str += "\"\r\n\t\"";
  422. str += ci.Path;
  423. str += "\"\r\n\t\"";
  424. str += ci.Comments;
  425. str += "\"\r\n}\r\n";
  426. fileSystem->WriteFile(path, (void*)&str[0], str.Length(), "fs_devpath");
  427. }
  428. }
  429. }
  430. void CPreviewDlg::AddSounds(bool rootItems) {
  431. int i, j;
  432. idStrList list(1024);
  433. idStrList list2(1024);
  434. HTREEITEM base = treeMedia.InsertItem("Sound Shaders");
  435. for( i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++ ) {
  436. const idSoundShader *poo = declManager->SoundByIndex( i, false );
  437. list.AddUnique( poo->GetFileName() );
  438. }
  439. list.Sort();
  440. for ( i = 0; i < list.Num(); i++ ) {
  441. HTREEITEM child = treeMedia.InsertItem(list[i], base);
  442. treeMedia.SetItemData(child, SOUNDPARENT);
  443. treeMedia.SetItemImage(child, 0, 1);
  444. list2.Clear();
  445. for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) {
  446. const idSoundShader *poo = declManager->SoundByIndex( j, false );
  447. if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) {
  448. list2.Append( poo->GetName() );
  449. }
  450. }
  451. list2.Sort();
  452. for (j = 0; j < list2.Num(); j++) {
  453. HTREEITEM child2 = treeMedia.InsertItem( list2[j], child );
  454. treeMedia.SetItemData(child2, SOUNDS);
  455. treeMedia.SetItemImage(child2, 2, 2);
  456. }
  457. }
  458. idFileList *files;
  459. files = fileSystem->ListFilesTree( "sound", ".wav" );
  460. AddStrList( "Wave files", files->GetList(), WAVES );
  461. fileSystem->FreeFileList( files );
  462. }
  463. void CPreviewDlg::SetMode( int mode, const char *preSelect ) {
  464. currentMode = mode;
  465. if ( preSelect ) {
  466. mediaName = preSelect;
  467. }
  468. if (GetSafeHwnd() == NULL) {
  469. return;
  470. }
  471. CWnd *wnd;
  472. switch (currentMode) {
  473. case GUIS :
  474. case SKINS :
  475. case MODELS :
  476. case PARTICLES :
  477. wndPreview.ShowWindow(SW_SHOW);
  478. wnd = GetDlgItem(IDC_BUTTON_PLAY);
  479. if (wnd) {
  480. wnd->ShowWindow(SW_HIDE);
  481. }
  482. wnd = GetDlgItem(IDC_BUTTON_ADD);
  483. if (wnd) {
  484. wnd->ShowWindow(SW_SHOW);
  485. }
  486. wnd = GetDlgItem(IDC_EDIT_INFO);
  487. if (wnd) {
  488. wnd->ShowWindow(SW_SHOW);
  489. }
  490. break;
  491. case MATERIALS :
  492. wndPreview.ShowWindow(SW_SHOW);
  493. wnd = GetDlgItem(IDC_BUTTON_PLAY);
  494. if (wnd) {
  495. wnd->ShowWindow(SW_HIDE);
  496. }
  497. wnd = GetDlgItem(IDC_BUTTON_ADD);
  498. if (wnd) {
  499. wnd->ShowWindow(SW_HIDE);
  500. }
  501. wnd = GetDlgItem(IDC_EDIT_INFO);
  502. if (wnd) {
  503. wnd->ShowWindow(SW_HIDE);
  504. }
  505. break;
  506. case SOUNDS :
  507. case WAVES :
  508. wndPreview.ShowWindow(SW_HIDE);
  509. wnd = GetDlgItem(IDC_BUTTON_PLAY);
  510. if (wnd) {
  511. wnd->ShowWindow(SW_SHOW);
  512. }
  513. wnd = GetDlgItem(IDC_BUTTON_ADD);
  514. if (wnd) {
  515. wnd->ShowWindow(SW_HIDE);
  516. }
  517. wnd = GetDlgItem(IDC_EDIT_INFO);
  518. if (wnd) {
  519. wnd->ShowWindow(SW_HIDE);
  520. }
  521. break;
  522. }
  523. }
  524. void CPreviewDlg::OnBnClickedButtonPlay() {
  525. g_qeglobals.sw->PlayShaderDirectly(mediaName);
  526. }
  527. void CPreviewDlg::AddMaterials(bool rootItems) {
  528. idStrList list(1024);
  529. //char temp[2048];
  530. int count = declManager->GetNumDecls( DECL_MATERIAL );
  531. if (count > 0) {
  532. for (int i = 0; i < count; i++) {
  533. const idMaterial *mat = declManager->MaterialByIndex(i, false);
  534. if (!rootItems) {
  535. if (strchr(mat->GetName(), '/') == NULL && strchr(mat->GetName(), '\\') == NULL) {
  536. continue;
  537. }
  538. }
  539. list.Append(mat->GetName());
  540. }
  541. list.Sort();
  542. AddStrList("Materials", list, MATERIALS);
  543. }
  544. }
  545. void CPreviewDlg::AddParticles(bool rootItems) {
  546. idStrList list(1024);
  547. int count = declManager->GetNumDecls( DECL_PARTICLE );
  548. if (count > 0) {
  549. for (int i = 0; i < count; i++) {
  550. const idDecl *ips = declManager->DeclByIndex( DECL_PARTICLE, i );
  551. if (!rootItems) {
  552. if (strchr(ips->GetName(), '/') == NULL && strchr(ips->GetName(), '\\') == NULL) {
  553. continue;
  554. }
  555. }
  556. list.Append(ips->GetName());
  557. }
  558. list.Sort();
  559. AddStrList("Particles", list, PARTICLES);
  560. }
  561. }
  562. void CPreviewDlg::AddSkins( bool rootItems ) {
  563. idStrList list(1024);
  564. idStrList list2(1024);
  565. idStr str;
  566. int count = declManager->GetNumDecls( DECL_SKIN );
  567. if (count > 0) {
  568. for (int i = 0; i < count; i++) {
  569. const idDeclSkin *skin = declManager->SkinByIndex(i);
  570. if (!rootItems) {
  571. if (strchr(skin->GetName(), '/') == NULL && strchr(skin->GetName(), '\\') == NULL) {
  572. continue;
  573. }
  574. }
  575. if ( data.Length() ) {
  576. for ( int j = 0; j < skin->GetNumModelAssociations(); j++ ){
  577. str = skin->GetAssociatedModel( j );
  578. str.ToLower();
  579. if ( data.Cmp(str) == 0 ) {
  580. list.Append(skin->GetName());
  581. }
  582. }
  583. }
  584. list2.Append(skin->GetName());
  585. }
  586. list.Sort();
  587. list2.Sort();
  588. AddStrList( "Matching Skins", list, SKINS );
  589. AddStrList( "Skins", list2, SKINS );
  590. }
  591. }
  592. void CPreviewDlg::OnShowWindow( BOOL bShow, UINT status ) {
  593. if ( bShow && AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
  594. GetParent()->EnableWindow( FALSE );
  595. }
  596. }