Counter Strike : Global Offensive Source Code
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.

735 lines
18 KiB

  1. //========= Copyright � 1996-2005, 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_EXPLORE_SOURCE, OnExploreToSource)
  51. ON_BN_CLICKED(IDC_TEXTURES_RELOAD, OnReload)
  52. ON_MESSAGE(TWN_SELCHANGED, OnTexturewindowSelchange)
  53. ON_MESSAGE(TWN_LBUTTONDBLCLK, OnTextureWindowDblClk)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. //-----------------------------------------------------------------------------
  57. // Purpose:
  58. // Input : pParent -
  59. //-----------------------------------------------------------------------------
  60. CTextureBrowser::CTextureBrowser(CWnd* pParent)
  61. : CDialog(IDD, pParent)
  62. {
  63. m_szNameFilter[0] = '\0';
  64. szInitialTexture[0] = '\0';
  65. m_bFilterChanged = FALSE;
  66. m_uLastFilterChange = 0xffffffff;
  67. m_bUsed = FALSE;
  68. m_szLastKeywords[0] = '\0';
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose: Handles resize messages. Moves the child windows to the proper positions.
  72. // Input : nType -
  73. // cx -
  74. // cy -
  75. //-----------------------------------------------------------------------------
  76. void CTextureBrowser::OnSize(UINT nType, int cx, int cy)
  77. {
  78. if (nType == SIZE_MINIMIZED || !IsWindow(m_cTextureWindow.m_hWnd))
  79. {
  80. CDialog::OnSize(nType, cx, cy);
  81. return;
  82. }
  83. // reposition controls
  84. CRect clientrect;
  85. GetClientRect(&clientrect);
  86. CRect CtrlRect;
  87. GetDlgItem(IDC_CONTROLHEIGHT)->GetWindowRect(&CtrlRect);
  88. int iControlHeight = (CtrlRect.bottom - CtrlRect.top);
  89. int iThisCtrlHeight;
  90. //
  91. // Resize the texture window.
  92. //
  93. CtrlRect = clientrect;
  94. CtrlRect.bottom -= iControlHeight;
  95. m_cTextureWindow.MoveWindow(CtrlRect);
  96. clientrect.top = (clientrect.bottom - iControlHeight) + 4;
  97. //
  98. // Move the top row of controls to the correct vertical position,
  99. // leaving their horizontal position as it was set up in the dialog.
  100. //
  101. int iIDList[] =
  102. {
  103. IDC_TEXTURESIZE,
  104. IDC_SIZEPROMPT,
  105. IDC_FILTERPROMPT,
  106. IDC_FILTER,
  107. IDC_CURNAME,
  108. IDC_FILTER_OPAQUE,
  109. IDC_FILTER_SELFILLUM,
  110. IDC_SHOW_ERROR,
  111. IDC_TEXTURES_OPEN_SOURCE,
  112. IDC_TEXTURES_EXPLORE_SOURCE,
  113. -1
  114. };
  115. for (int i = 0; iIDList[i] != -1; i++)
  116. {
  117. CWnd *pWnd = GetDlgItem(iIDList[i]);
  118. Assert(pWnd != NULL);
  119. if (pWnd != NULL)
  120. {
  121. pWnd->GetWindowRect(&CtrlRect);
  122. ScreenToClient(CtrlRect);
  123. iThisCtrlHeight = CtrlRect.bottom - CtrlRect.top;
  124. CtrlRect.top = clientrect.top;
  125. CtrlRect.bottom = CtrlRect.top + iThisCtrlHeight;
  126. pWnd->MoveWindow(CtrlRect);
  127. }
  128. }
  129. //
  130. // Move the middle row of controls to the correct vertical position,
  131. // leaving their horizontal position as it was set up in the dialog.
  132. //
  133. int iIDList2[] =
  134. {
  135. IDC_KEYWORDS_TEXT,
  136. IDC_KEYWORDS,
  137. IDC_USED,
  138. IDC_MARK,
  139. IDC_REPLACE,
  140. IDC_CURDESCRIPTION,
  141. IDC_FILTER_TRANSLUCENT,
  142. IDC_FILTER_ENVMASK,
  143. IDC_TEXTURES_RELOAD,
  144. -1
  145. };
  146. for (int i = 0; iIDList2[i] != -1; i++)
  147. {
  148. CWnd *pWnd = GetDlgItem(iIDList2[i]);
  149. Assert(pWnd != NULL);
  150. if (pWnd != NULL)
  151. {
  152. pWnd->GetWindowRect(&CtrlRect);
  153. ScreenToClient(CtrlRect);
  154. iThisCtrlHeight = CtrlRect.bottom - CtrlRect.top;
  155. CtrlRect.top = clientrect.top + iControlHeight / 2 + 2;
  156. CtrlRect.bottom = CtrlRect.top + iThisCtrlHeight;
  157. pWnd->MoveWindow(CtrlRect);
  158. }
  159. }
  160. CDialog::OnSize(nType, cx, cy);
  161. }
  162. //-----------------------------------------------------------------------------
  163. // Purpose:
  164. // Input : bUsed -
  165. //-----------------------------------------------------------------------------
  166. void CTextureBrowser::SetUsed(BOOL bUsed)
  167. {
  168. m_bUsed = bUsed;
  169. if (m_bUsed)
  170. {
  171. CUsedTextureList Used;
  172. GetActiveWorld()->GetUsedTextures(Used);
  173. m_TextureSubList.RemoveAll();
  174. for (int i = 0; i < Used.Count(); i++)
  175. {
  176. TextureWindowTex_t Tex;
  177. Tex.pTex = Used.Element(i).pTex;
  178. Tex.nUsageCount = Used.Element(i).nUsageCount;
  179. m_TextureSubList.AddToTail(Tex);
  180. }
  181. m_cTextureWindow.SetSpecificList(&m_TextureSubList);
  182. }
  183. else
  184. {
  185. m_cTextureWindow.SetSpecificList(NULL);
  186. }
  187. }
  188. //-----------------------------------------------------------------------------
  189. // Purpose:
  190. //-----------------------------------------------------------------------------
  191. void CTextureBrowser::OnClose(void)
  192. {
  193. WriteSettings();
  194. SaveAndExit();
  195. CDialog::OnCancel();
  196. }
  197. //-----------------------------------------------------------------------------
  198. // Purpose:
  199. //-----------------------------------------------------------------------------
  200. void CTextureBrowser::OnCancel()
  201. {
  202. WriteSettings();
  203. SaveAndExit();
  204. CDialog::OnCancel();
  205. }
  206. //-----------------------------------------------------------------------------
  207. // Purpose:
  208. //-----------------------------------------------------------------------------
  209. void CTextureBrowser::OnUsed()
  210. {
  211. if(!GetActiveWorld())
  212. return;
  213. SetUsed(m_cUsed.GetCheck());
  214. }
  215. //-----------------------------------------------------------------------------
  216. // Purpose:
  217. // Input : pszTexture -
  218. //-----------------------------------------------------------------------------
  219. void CTextureBrowser::SetInitialTexture(LPCTSTR pszTexture)
  220. {
  221. strcpy(szInitialTexture, pszTexture);
  222. }
  223. //-----------------------------------------------------------------------------
  224. // Purpose:
  225. //-----------------------------------------------------------------------------
  226. void CTextureBrowser::OnSelendokTexturesize()
  227. {
  228. // change size of textures the texutre window displays
  229. int iCurSel = m_cSizeList.GetCurSel();
  230. switch(iCurSel)
  231. {
  232. case 0:
  233. m_cTextureWindow.SetDisplaySize(128);
  234. break;
  235. case 1:
  236. m_cTextureWindow.SetDisplaySize(256);
  237. break;
  238. case 2:
  239. m_cTextureWindow.SetDisplaySize(512);
  240. break;
  241. }
  242. }
  243. //-----------------------------------------------------------------------------
  244. // Purpose:
  245. //-----------------------------------------------------------------------------
  246. BOOL CTextureBrowser::OnInitDialog()
  247. {
  248. CDialog::OnInitDialog();
  249. // Iterate all the active textures for debugging.
  250. //int nCount = g_Textures.GetActiveTextureCount();
  251. //for (int nTexture = 0; nTexture < nCount; nTexture++)
  252. //{
  253. // IEditorTexture *pTexture = g_Textures.GetActiveTexture(nTexture);
  254. // const char *pszName = pTexture->GetName();
  255. // DBG("%d: %s\n", nTexture, pszName);
  256. //}
  257. m_cSizeList.SubclassDlgItem(IDC_TEXTURESIZE, this);
  258. m_cFilter.SubclassDlgItem(IDC_FILTER, this);
  259. m_cKeywords.SubclassDlgItem(IDC_KEYWORDS, this);
  260. m_cCurName.SubclassDlgItem(IDC_CURNAME, this);
  261. m_cCurDescription.SubclassDlgItem(IDC_CURDESCRIPTION, this);
  262. m_cUsed.SubclassDlgItem(IDC_USED, this);
  263. m_FilterOpaque.SubclassDlgItem(IDC_FILTER_OPAQUE, this);
  264. m_FilterTranslucent.SubclassDlgItem(IDC_FILTER_TRANSLUCENT, this);
  265. m_FilterSelfIllum.SubclassDlgItem(IDC_FILTER_SELFILLUM, this);
  266. m_FilterEnvMask.SubclassDlgItem(IDC_FILTER_ENVMASK, this);
  267. m_ShowErrors.SubclassDlgItem(IDC_SHOW_ERROR, this);
  268. m_FilterOpaque.SetCheck( true );
  269. m_FilterTranslucent.SetCheck( true );
  270. m_FilterSelfIllum.SetCheck( true );
  271. m_FilterEnvMask.SetCheck( true );
  272. m_ShowErrors.SetCheck( true );
  273. //
  274. // Create CTextureWindow that takes up area of dummy control.
  275. //
  276. RECT r;
  277. GetDlgItem(IDC_BROWSERDUMMY)->GetClientRect(&r);
  278. m_cTextureWindow.Create(this, r);
  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. CRect 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. //-----------------------------------------------------------------------------
  540. // Explores to the source file:
  541. //-----------------------------------------------------------------------------
  542. void CTextureBrowser::OnExploreToSource()
  543. {
  544. if ( m_cTextureWindow.szCurTexture[0] )
  545. {
  546. g_Textures.ExploreToSource( m_cTextureWindow.szCurTexture );
  547. }
  548. }
  549. void CTextureBrowser::OnReload()
  550. {
  551. if ( m_cTextureWindow.szCurTexture[0] )
  552. {
  553. g_Textures.ReloadTextures( m_cTextureWindow.szCurTexture );
  554. m_cTextureWindow.Invalidate();
  555. if (GetMainWnd())
  556. {
  557. GetMainWnd()->m_TextureBar.NotifyGraphicsChanged();
  558. GetMainWnd()->m_pFaceEditSheet->NotifyGraphicsChanged();
  559. }
  560. }
  561. }
  562. //-----------------------------------------------------------------------------
  563. // Purpose:
  564. //-----------------------------------------------------------------------------
  565. void CTextureBrowser::OnMark(void)
  566. {
  567. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  568. if (pDoc != NULL)
  569. {
  570. pDoc->ReplaceTextures(m_cTextureWindow.szCurTexture, "", TRUE, 0x100, FALSE, FALSE);
  571. EndDialog(IDOK);
  572. }
  573. }
  574. //-----------------------------------------------------------------------------
  575. // Purpose: Invokes the replace texture dialog.
  576. //-----------------------------------------------------------------------------
  577. void CTextureBrowser::OnReplace(void)
  578. {
  579. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  580. if(!pDoc)
  581. return;
  582. CReplaceTexDlg dlg(pDoc->GetSelection()->GetCount());
  583. dlg.m_strFind = m_cTextureWindow.szCurTexture;
  584. if(dlg.DoModal() != IDOK)
  585. return;
  586. // mark undo position
  587. GetHistory()->MarkUndoPosition(pDoc->GetSelection()->GetList(), "Replace Textures");
  588. if(dlg.m_bMarkOnly)
  589. {
  590. pDoc->SelectObject(NULL, scClear); // clear selection first
  591. }
  592. dlg.DoReplaceTextures();
  593. //EndDialog(IDOK);
  594. if (m_bUsed)
  595. {
  596. SetUsed(TRUE);
  597. }
  598. }
  599. //-----------------------------------------------------------------------------
  600. // Purpose: Sets the texture format for browsing. Only textures of the given
  601. // format will be visible in the browse window. By default, this
  602. // format will be the same as the current active texture format.
  603. // Input : eTextureFormat - Texture format to use for browsing.
  604. //-----------------------------------------------------------------------------
  605. void CTextureBrowser::SetTextureFormat(TEXTUREFORMAT eTextureFormat)
  606. {
  607. m_cTextureWindow.SetTextureFormat(eTextureFormat);
  608. }