Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

724 lines
18 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "stdafx.h"
  7. #include <oleauto.h>
  8. #include <oaidl.h>
  9. #if _MSC_VER < 1300
  10. #include <afxpriv.h>
  11. #endif
  12. #include "CustomMessages.h"
  13. #include "GlobalFunctions.h"
  14. #include "History.h"
  15. #include "FaceEditSheet.h"
  16. #include "IEditorTexture.h"
  17. #include "MainFrm.h"
  18. #include "MapDoc.h"
  19. #include "MapWorld.h"
  20. #include "ReplaceTexDlg.h"
  21. #include "TextureBrowser.h"
  22. #include "TextureSystem.h"
  23. #include "hammer.h"
  24. #include "Selection.h"
  25. // memdbgon must be the last include file in a .cpp file!!!
  26. #include <tier0/memdbgon.h>
  27. static LPCTSTR pszIniSection = "Texture Browser";
  28. CStringArray CTextureBrowser::m_FilterHistory;
  29. int CTextureBrowser::m_nFilterHistory;
  30. char CTextureBrowser::m_szLastKeywords[MAX_PATH];
  31. BEGIN_MESSAGE_MAP(CTextureBrowser, CDialog)
  32. //{{AFX_MSG_MAP(CTextureBrowser)
  33. ON_WM_SIZE()
  34. ON_CBN_SELENDOK(IDC_TEXTURESIZE, OnSelendokTexturesize)
  35. ON_WM_CLOSE()
  36. ON_WM_TIMER()
  37. ON_CBN_EDITCHANGE(IDC_FILTER, OnChangeFilterOrKeywords)
  38. ON_CBN_SELENDOK(IDC_FILTER, OnUpdateFiltersNOW)
  39. ON_CBN_EDITCHANGE(IDC_KEYWORDS, OnChangeFilterOrKeywords)
  40. ON_CBN_SELENDOK(IDC_KEYWORDS, OnUpdateKeywordsNOW)
  41. ON_BN_CLICKED(IDC_FILTER_OPAQUE, OnFilterOpaque)
  42. ON_BN_CLICKED(IDC_FILTER_TRANSLUCENT, OnFilterTranslucent)
  43. ON_BN_CLICKED(IDC_FILTER_SELFILLUM, OnFilterSelfIllum)
  44. ON_BN_CLICKED(IDC_FILTER_ENVMASK, OnFilterEnvmask)
  45. ON_BN_CLICKED(IDC_SHOW_ERROR, OnShowErrors)
  46. ON_BN_CLICKED(IDC_USED, OnUsed)
  47. ON_BN_CLICKED(IDC_MARK, OnMark)
  48. ON_BN_CLICKED(IDC_REPLACE, OnReplace)
  49. ON_BN_CLICKED(IDC_TEXTURES_OPEN_SOURCE, OnOpenSource)
  50. ON_BN_CLICKED(IDC_TEXTURES_RELOAD, OnReload)
  51. ON_MESSAGE(TWN_SELCHANGED, OnTexturewindowSelchange)
  52. ON_MESSAGE(TWN_LBUTTONDBLCLK, OnTextureWindowDblClk)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. // Input : pParent -
  58. //-----------------------------------------------------------------------------
  59. CTextureBrowser::CTextureBrowser(CWnd* pParent)
  60. : CDialog(IDD, pParent)
  61. {
  62. m_szNameFilter[0] = '\0';
  63. szInitialTexture[0] = '\0';
  64. m_bFilterChanged = FALSE;
  65. m_uLastFilterChange = 0xffffffff;
  66. m_bUsed = FALSE;
  67. m_szLastKeywords[0] = '\0';
  68. }
  69. //-----------------------------------------------------------------------------
  70. // Purpose: Handles resize messages. Moves the child windows to the proper positions.
  71. // Input : nType -
  72. // cx -
  73. // cy -
  74. //-----------------------------------------------------------------------------
  75. void CTextureBrowser::OnSize(UINT nType, int cx, int cy)
  76. {
  77. if (nType == SIZE_MINIMIZED || !IsWindow(m_cTextureWindow.m_hWnd))
  78. {
  79. CDialog::OnSize(nType, cx, cy);
  80. return;
  81. }
  82. // reposition controls
  83. CRect clientrect;
  84. GetClientRect(&clientrect);
  85. CRect CtrlRect;
  86. GetDlgItem(IDC_CONTROLHEIGHT)->GetWindowRect(&CtrlRect);
  87. int iControlHeight = (CtrlRect.bottom - CtrlRect.top);
  88. int iThisCtrlHeight;
  89. //
  90. // Resize the texture window.
  91. //
  92. CtrlRect = clientrect;
  93. CtrlRect.bottom -= iControlHeight;
  94. m_cTextureWindow.MoveWindow(CtrlRect);
  95. clientrect.top = (clientrect.bottom - iControlHeight) + 4;
  96. //
  97. // Move the top row of controls to the correct vertical position,
  98. // leaving their horizontal position as it was set up in the dialog.
  99. //
  100. int iIDList[] =
  101. {
  102. IDC_TEXTURESIZE,
  103. IDC_SIZEPROMPT,
  104. IDC_FILTERPROMPT,
  105. IDC_FILTER,
  106. IDC_CURNAME,
  107. IDC_FILTER_OPAQUE,
  108. IDC_FILTER_SELFILLUM,
  109. IDC_SHOW_ERROR,
  110. IDC_TEXTURES_OPEN_SOURCE,
  111. -1
  112. };
  113. for (int i = 0; iIDList[i] != -1; i++)
  114. {
  115. CWnd *pWnd = GetDlgItem(iIDList[i]);
  116. Assert(pWnd != NULL);
  117. if (pWnd != NULL)
  118. {
  119. pWnd->GetWindowRect(&CtrlRect);
  120. ScreenToClient(CtrlRect);
  121. iThisCtrlHeight = CtrlRect.bottom - CtrlRect.top;
  122. CtrlRect.top = clientrect.top;
  123. CtrlRect.bottom = CtrlRect.top + iThisCtrlHeight;
  124. pWnd->MoveWindow(CtrlRect);
  125. }
  126. }
  127. //
  128. // Move the middle row of controls to the correct vertical position,
  129. // leaving their horizontal position as it was set up in the dialog.
  130. //
  131. int iIDList2[] =
  132. {
  133. IDC_KEYWORDS_TEXT,
  134. IDC_KEYWORDS,
  135. IDC_USED,
  136. IDC_MARK,
  137. IDC_REPLACE,
  138. IDC_CURDESCRIPTION,
  139. IDC_FILTER_TRANSLUCENT,
  140. IDC_FILTER_ENVMASK,
  141. IDC_TEXTURES_RELOAD,
  142. -1
  143. };
  144. for (int i = 0; iIDList2[i] != -1; i++)
  145. {
  146. CWnd *pWnd = GetDlgItem(iIDList2[i]);
  147. Assert(pWnd != NULL);
  148. if (pWnd != NULL)
  149. {
  150. pWnd->GetWindowRect(&CtrlRect);
  151. ScreenToClient(CtrlRect);
  152. iThisCtrlHeight = CtrlRect.bottom - CtrlRect.top;
  153. CtrlRect.top = clientrect.top + iControlHeight / 2 + 2;
  154. CtrlRect.bottom = CtrlRect.top + iThisCtrlHeight;
  155. pWnd->MoveWindow(CtrlRect);
  156. }
  157. }
  158. CDialog::OnSize(nType, cx, cy);
  159. }
  160. //-----------------------------------------------------------------------------
  161. // Purpose:
  162. // Input : bUsed -
  163. //-----------------------------------------------------------------------------
  164. void CTextureBrowser::SetUsed(BOOL bUsed)
  165. {
  166. m_bUsed = bUsed;
  167. if (m_bUsed)
  168. {
  169. CUsedTextureList Used;
  170. GetActiveWorld()->GetUsedTextures(Used);
  171. m_TextureSubList.RemoveAll();
  172. for (int i = 0; i < Used.Count(); i++)
  173. {
  174. TextureWindowTex_t Tex;
  175. Tex.pTex = Used.Element(i).pTex;
  176. Tex.nUsageCount = Used.Element(i).nUsageCount;
  177. m_TextureSubList.AddToTail(Tex);
  178. }
  179. m_cTextureWindow.SetSpecificList(&m_TextureSubList);
  180. }
  181. else
  182. {
  183. m_cTextureWindow.SetSpecificList(NULL);
  184. }
  185. }
  186. //-----------------------------------------------------------------------------
  187. // Purpose:
  188. //-----------------------------------------------------------------------------
  189. void CTextureBrowser::OnClose(void)
  190. {
  191. WriteSettings();
  192. SaveAndExit();
  193. CDialog::OnCancel();
  194. }
  195. //-----------------------------------------------------------------------------
  196. // Purpose:
  197. //-----------------------------------------------------------------------------
  198. void CTextureBrowser::OnCancel()
  199. {
  200. WriteSettings();
  201. SaveAndExit();
  202. CDialog::OnCancel();
  203. }
  204. //-----------------------------------------------------------------------------
  205. // Purpose:
  206. //-----------------------------------------------------------------------------
  207. void CTextureBrowser::OnUsed()
  208. {
  209. if(!GetActiveWorld())
  210. return;
  211. SetUsed(m_cUsed.GetCheck());
  212. }
  213. //-----------------------------------------------------------------------------
  214. // Purpose:
  215. // Input : pszTexture -
  216. //-----------------------------------------------------------------------------
  217. void CTextureBrowser::SetInitialTexture(LPCTSTR pszTexture)
  218. {
  219. strcpy(szInitialTexture, pszTexture);
  220. }
  221. //-----------------------------------------------------------------------------
  222. // Purpose:
  223. //-----------------------------------------------------------------------------
  224. void CTextureBrowser::OnSelendokTexturesize()
  225. {
  226. // change size of textures the texutre window displays
  227. int iCurSel = m_cSizeList.GetCurSel();
  228. switch(iCurSel)
  229. {
  230. case 0:
  231. m_cTextureWindow.SetDisplaySize(128);
  232. break;
  233. case 1:
  234. m_cTextureWindow.SetDisplaySize(256);
  235. break;
  236. case 2:
  237. m_cTextureWindow.SetDisplaySize(512);
  238. break;
  239. }
  240. }
  241. //-----------------------------------------------------------------------------
  242. // Purpose:
  243. //-----------------------------------------------------------------------------
  244. BOOL CTextureBrowser::OnInitDialog()
  245. {
  246. CDialog::OnInitDialog();
  247. // Iterate all the active textures for debugging.
  248. //int nCount = g_Textures.GetActiveTextureCount();
  249. //for (int nTexture = 0; nTexture < nCount; nTexture++)
  250. //{
  251. // IEditorTexture *pTexture = g_Textures.GetActiveTexture(nTexture);
  252. // const char *pszName = pTexture->GetName();
  253. // DBG("%d: %s\n", nTexture, pszName);
  254. //}
  255. m_cSizeList.SubclassDlgItem(IDC_TEXTURESIZE, this);
  256. m_cFilter.SubclassDlgItem(IDC_FILTER, this);
  257. m_cKeywords.SubclassDlgItem(IDC_KEYWORDS, this);
  258. m_cCurName.SubclassDlgItem(IDC_CURNAME, this);
  259. m_cCurDescription.SubclassDlgItem(IDC_CURDESCRIPTION, this);
  260. m_cUsed.SubclassDlgItem(IDC_USED, this);
  261. m_FilterOpaque.SubclassDlgItem(IDC_FILTER_OPAQUE, this);
  262. m_FilterTranslucent.SubclassDlgItem(IDC_FILTER_TRANSLUCENT, this);
  263. m_FilterSelfIllum.SubclassDlgItem(IDC_FILTER_SELFILLUM, this);
  264. m_FilterEnvMask.SubclassDlgItem(IDC_FILTER_ENVMASK, this);
  265. m_ShowErrors.SubclassDlgItem(IDC_SHOW_ERROR, this);
  266. m_FilterOpaque.SetCheck( true );
  267. m_FilterTranslucent.SetCheck( true );
  268. m_FilterSelfIllum.SetCheck( true );
  269. m_FilterEnvMask.SetCheck( true );
  270. m_ShowErrors.SetCheck( true );
  271. //
  272. // Create CTextureWindow that takes up area of dummy control.
  273. //
  274. {
  275. RECT r;
  276. GetDlgItem( IDC_BROWSERDUMMY )->GetClientRect( &r );
  277. m_cTextureWindow.Create( this, r );
  278. }
  279. // Show everything initially
  280. m_cTextureWindow.SetTypeFilter( ~0, true );
  281. //
  282. // Add latest history to the filter combo.
  283. //
  284. for (int i = 0; i < m_nFilterHistory; i++)
  285. {
  286. m_cFilter.AddString(m_FilterHistory[i]);
  287. }
  288. //
  289. // Set the name filter unless one was explicitly specified.
  290. //
  291. if (m_szNameFilter[0] == '\0')
  292. {
  293. //
  294. // No name filter specified. Use whatever is on top of the history.
  295. //
  296. if (m_cFilter.GetCount() > 0)
  297. {
  298. m_cFilter.GetLBText(0, m_szNameFilter);
  299. m_cFilter.SetCurSel(0);
  300. }
  301. }
  302. m_cFilter.SetWindowText(m_szNameFilter);
  303. m_cTextureWindow.SetNameFilter(m_szNameFilter);
  304. //
  305. // Done with the name filter; clear it for next time.
  306. //
  307. m_szNameFilter[0] = '\0';
  308. // Add the global list of keywords to the keywords combo.
  309. for( int i=0; i< g_Textures.GetNumKeywords(); i++ )
  310. {
  311. m_cKeywords.AddString( g_Textures.GetKeyword(i) );
  312. }
  313. //
  314. // Set the keyword filter.
  315. //
  316. m_cKeywords.SetWindowText(m_szLastKeywords);
  317. m_cTextureWindow.SetKeywords(m_szLastKeywords);
  318. m_cUsed.SetCheck(m_bUsed);
  319. // Refresh the list of used textures if enabled.
  320. if (m_bUsed)
  321. {
  322. SetUsed(TRUE);
  323. }
  324. CWinApp *pApp = AfxGetApp();
  325. CString str = pApp->GetProfileString(pszIniSection, "Position");
  326. if (!str.IsEmpty())
  327. {
  328. RECT r;
  329. sscanf(str, "%d %d %d %d", &r.left, &r.top, &r.right, &r.bottom);
  330. if (r.left < 0)
  331. {
  332. ShowWindow(SW_SHOWMAXIMIZED);
  333. }
  334. else
  335. {
  336. MoveWindow(r.left, r.top, r.right-r.left, r.bottom-r.top, FALSE);
  337. }
  338. }
  339. int iSize = pApp->GetProfileInt(pszIniSection, "ShowSize", 0);
  340. m_cSizeList.SetCurSel(iSize);
  341. OnSelendokTexturesize();
  342. if (szInitialTexture[0])
  343. {
  344. m_cTextureWindow.SelectTexture(szInitialTexture);
  345. }
  346. m_cTextureWindow.ShowWindow(SW_SHOW);
  347. SetTimer(1, 500, NULL);
  348. m_cFilter.SetFocus();
  349. return(FALSE);
  350. }
  351. //-----------------------------------------------------------------------------
  352. // Purpose: Called when either the filter combo or the keywords combo text changes.
  353. //-----------------------------------------------------------------------------
  354. void CTextureBrowser::OnChangeFilterOrKeywords()
  355. {
  356. //
  357. // Start a timer to repaint the texture window using the new filters.
  358. //
  359. m_uLastFilterChange = time(NULL);
  360. m_bFilterChanged = TRUE;
  361. }
  362. //-----------------------------------------------------------------------------
  363. // Purpose:
  364. //-----------------------------------------------------------------------------
  365. void CTextureBrowser::OnUpdateFiltersNOW()
  366. {
  367. m_uLastFilterChange = time(NULL);
  368. m_bFilterChanged = FALSE;
  369. CString str;
  370. int iSel = m_cFilter.GetCurSel();
  371. m_cFilter.GetLBText(iSel, str);
  372. m_cTextureWindow.SetNameFilter(str);
  373. }
  374. //-----------------------------------------------------------------------------
  375. // Purpose:
  376. //-----------------------------------------------------------------------------
  377. void CTextureBrowser::OnUpdateKeywordsNOW()
  378. {
  379. m_uLastFilterChange = time(NULL);
  380. m_bFilterChanged = FALSE;
  381. CString str;
  382. int iSel = m_cKeywords.GetCurSel();
  383. m_cKeywords.GetLBText(iSel, str);
  384. m_cTextureWindow.SetKeywords(str);
  385. }
  386. //-----------------------------------------------------------------------------
  387. // Purpose: Timer used to control updates when the filter terms change.
  388. // Input : nIDEvent -
  389. //-----------------------------------------------------------------------------
  390. void CTextureBrowser::OnTimer(UINT nIDEvent)
  391. {
  392. if (!m_bFilterChanged)
  393. {
  394. return;
  395. }
  396. if ((time(NULL) - m_uLastFilterChange) > 0)
  397. {
  398. KillTimer(nIDEvent);
  399. m_bFilterChanged = FALSE;
  400. m_cTextureWindow.EnableUpdate(false);
  401. CString str;
  402. m_cFilter.GetWindowText(str);
  403. m_cTextureWindow.SetNameFilter(str);
  404. m_cTextureWindow.EnableUpdate(true);
  405. m_cKeywords.GetWindowText(str);
  406. m_cTextureWindow.SetKeywords(str);
  407. SetTimer(nIDEvent, 500, NULL);
  408. }
  409. CDialog::OnTimer(nIDEvent);
  410. }
  411. //-----------------------------------------------------------------------------
  412. // Purpose:
  413. // Input : wParam -
  414. // lParam -
  415. // Output : LRESULT
  416. //-----------------------------------------------------------------------------
  417. LRESULT CTextureBrowser::OnTextureWindowDblClk(WPARAM wParam, LPARAM lParam)
  418. {
  419. WriteSettings();
  420. SaveAndExit();
  421. return(0);
  422. }
  423. //-----------------------------------------------------------------------------
  424. // Purpose:
  425. // Input : wParam -
  426. // lParam -
  427. // Output : LRESULT
  428. //-----------------------------------------------------------------------------
  429. LRESULT CTextureBrowser::OnTexturewindowSelchange(WPARAM wParam, LPARAM lParam)
  430. {
  431. IEditorTexture *pTex = g_Textures.FindActiveTexture(m_cTextureWindow.szCurTexture);
  432. CString str;
  433. char szName[MAX_PATH];
  434. if (pTex != NULL)
  435. {
  436. // create description of texture
  437. str.Format("%dx%d", pTex->GetWidth(), pTex->GetHeight());
  438. pTex->GetShortName(szName);
  439. }
  440. else
  441. {
  442. szName[0] = '\0';
  443. }
  444. m_cCurName.SetWindowText(szName);
  445. m_cCurDescription.SetWindowText(str);
  446. return(0);
  447. }
  448. //-----------------------------------------------------------------------------
  449. // Purpose:
  450. //-----------------------------------------------------------------------------
  451. void CTextureBrowser::WriteSettings()
  452. {
  453. // write position information
  454. CWinApp *pApp = AfxGetApp();
  455. CString str;
  456. CRect r;
  457. GetWindowRect(r);
  458. str.Format("%d %d %d %d", r.left, r.top, r.right, r.bottom);
  459. pApp->WriteProfileString(pszIniSection, "Position", str);
  460. pApp->WriteProfileInt(pszIniSection, "ShowSize", m_cSizeList.GetCurSel());
  461. }
  462. //-----------------------------------------------------------------------------
  463. // Purpose:
  464. //-----------------------------------------------------------------------------
  465. void CTextureBrowser::SaveAndExit()
  466. {
  467. // save current filter string
  468. CString str;
  469. m_cFilter.GetWindowText(str);
  470. int i;
  471. for(i = 0; i < m_nFilterHistory; i++)
  472. {
  473. if(!m_FilterHistory[i].CompareNoCase(str))
  474. break;
  475. }
  476. if(i != m_nFilterHistory) // delete first
  477. {
  478. m_FilterHistory.RemoveAt(i);
  479. --m_nFilterHistory;
  480. }
  481. m_FilterHistory.InsertAt(0, str);
  482. ++m_nFilterHistory;
  483. m_cKeywords.GetWindowText(m_szLastKeywords, sizeof(m_szLastKeywords));
  484. EndDialog(IDOK);
  485. }
  486. //-----------------------------------------------------------------------------
  487. // Purpose: Sets a name filter that will override whatever is in the history
  488. // for this browser session.
  489. //-----------------------------------------------------------------------------
  490. void CTextureBrowser::SetFilter(const char *pszFilter)
  491. {
  492. if (pszFilter)
  493. {
  494. strcpy(m_szNameFilter, pszFilter);
  495. }
  496. else
  497. {
  498. m_szNameFilter[0] = '\0';
  499. }
  500. }
  501. //-----------------------------------------------------------------------------
  502. // Filter buttons
  503. //-----------------------------------------------------------------------------
  504. void CTextureBrowser::OnFilterOpaque(void)
  505. {
  506. bool checked = m_FilterOpaque.GetCheck( ) != 0;
  507. m_cTextureWindow.SetTypeFilter( CTextureWindow::TYPEFILTER_OPAQUE, checked );
  508. }
  509. void CTextureBrowser::OnFilterTranslucent(void)
  510. {
  511. bool checked = m_FilterTranslucent.GetCheck( ) != 0;
  512. m_cTextureWindow.SetTypeFilter( CTextureWindow::TYPEFILTER_TRANSLUCENT, checked );
  513. }
  514. void CTextureBrowser::OnFilterSelfIllum(void)
  515. {
  516. bool checked = m_FilterSelfIllum.GetCheck( ) != 0;
  517. m_cTextureWindow.SetTypeFilter( CTextureWindow::TYPEFILTER_SELFILLUM, checked );
  518. }
  519. void CTextureBrowser::OnFilterEnvmask(void)
  520. {
  521. bool checked = m_FilterEnvMask.GetCheck( ) != 0;
  522. m_cTextureWindow.SetTypeFilter( CTextureWindow::TYPEFILTER_ENVMASK, checked );
  523. }
  524. void CTextureBrowser::OnShowErrors(void)
  525. {
  526. bool checked = m_ShowErrors.GetCheck( ) != 0;
  527. m_cTextureWindow.ShowErrors( checked );
  528. }
  529. //-----------------------------------------------------------------------------
  530. // Opens the source file:
  531. //-----------------------------------------------------------------------------
  532. void CTextureBrowser::OnOpenSource()
  533. {
  534. if ( m_cTextureWindow.szCurTexture[0] )
  535. {
  536. g_Textures.OpenSource( m_cTextureWindow.szCurTexture );
  537. }
  538. }
  539. void CTextureBrowser::OnReload()
  540. {
  541. if ( m_cTextureWindow.szCurTexture[0] )
  542. {
  543. g_Textures.ReloadTextures( m_cTextureWindow.szCurTexture );
  544. m_cTextureWindow.Invalidate();
  545. if (GetMainWnd())
  546. {
  547. GetMainWnd()->m_TextureBar.NotifyGraphicsChanged();
  548. GetMainWnd()->m_pFaceEditSheet->NotifyGraphicsChanged();
  549. }
  550. }
  551. }
  552. //-----------------------------------------------------------------------------
  553. // Purpose:
  554. //-----------------------------------------------------------------------------
  555. void CTextureBrowser::OnMark(void)
  556. {
  557. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  558. if (pDoc != NULL)
  559. {
  560. pDoc->ReplaceTextures(m_cTextureWindow.szCurTexture, "", TRUE, 0x100, FALSE, FALSE);
  561. EndDialog(IDOK);
  562. }
  563. }
  564. //-----------------------------------------------------------------------------
  565. // Purpose: Invokes the replace texture dialog.
  566. //-----------------------------------------------------------------------------
  567. void CTextureBrowser::OnReplace(void)
  568. {
  569. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  570. if(!pDoc)
  571. return;
  572. CReplaceTexDlg dlg(pDoc->GetSelection()->GetCount());
  573. dlg.m_strFind = m_cTextureWindow.szCurTexture;
  574. if(dlg.DoModal() != IDOK)
  575. return;
  576. // mark undo position
  577. GetHistory()->MarkUndoPosition(pDoc->GetSelection()->GetList(), "Replace Textures");
  578. if(dlg.m_bMarkOnly)
  579. {
  580. pDoc->SelectObject(NULL, scClear); // clear selection first
  581. }
  582. dlg.DoReplaceTextures();
  583. //EndDialog(IDOK);
  584. if (m_bUsed)
  585. {
  586. SetUsed(TRUE);
  587. }
  588. }
  589. //-----------------------------------------------------------------------------
  590. // Purpose: Sets the texture format for browsing. Only textures of the given
  591. // format will be visible in the browse window. By default, this
  592. // format will be the same as the current active texture format.
  593. // Input : eTextureFormat - Texture format to use for browsing.
  594. //-----------------------------------------------------------------------------
  595. void CTextureBrowser::SetTextureFormat(TEXTUREFORMAT eTextureFormat)
  596. {
  597. m_cTextureWindow.SetTextureFormat(eTextureFormat);
  598. }