TextureSettingsDialog.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/W3DView/TextureSettingsDialog.cpp $Modtime:: $*
  25. * *
  26. * $Revision:: 6 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #include "StdAfx.H"
  32. #include "Texture.H"
  33. #include "W3DView.H"
  34. #include "TextureSettingsDialog.H"
  35. #include "Utils.H"
  36. #include "AssetMgr.H"
  37. /*#ifdef _DEBUG
  38. #define new DEBUG_NEW
  39. #undef THIS_FILE
  40. static char THIS_FILE[] = __FILE__;
  41. #endif*/
  42. /////////////////////////////////////////////////////////////////////////////
  43. //
  44. // Local data types
  45. //
  46. typedef enum
  47. {
  48. TYPE_LOOP = 0,
  49. TYPE_ONCE,
  50. TYPE_PING_PONG,
  51. TYPE_MANUAL,
  52. TYPE_COUNT
  53. } ANIM_TYPES;
  54. #ifdef WW3D_DX8
  55. /////////////////////////////////////////////////////////////////////////////
  56. //
  57. // TextureSettingsDialogClass
  58. //
  59. TextureSettingsDialogClass::TextureSettingsDialogClass
  60. (
  61. IndirectTextureClass *ptexture,
  62. IndirectTextureClass *poriginal_texture,
  63. CWnd *pParent
  64. )
  65. : m_pTexture (NULL),
  66. m_pOriginalTexture (NULL),
  67. m_pStartingTexture (NULL),
  68. m_hThumbnail (NULL),
  69. m_bWereSettingsModified (false),
  70. CDialog(TextureSettingsDialogClass::IDD, pParent)
  71. {
  72. //{{AFX_DATA_INIT(TextureSettingsDialogClass)
  73. //}}AFX_DATA_INIT
  74. MEMBER_ADD (m_pTexture, ptexture);
  75. MEMBER_ADD (m_pOriginalTexture, poriginal_texture);
  76. return ;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. //
  80. // ~TextureSettingsDialogClass
  81. //
  82. TextureSettingsDialogClass::~TextureSettingsDialogClass (void)
  83. {
  84. SR_RELEASE (m_pTexture);
  85. SR_RELEASE (m_pOriginalTexture);
  86. SR_RELEASE (m_pStartingTexture);
  87. return ;
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. //
  91. // DoDataExchange
  92. //
  93. void
  94. TextureSettingsDialogClass::DoDataExchange (CDataExchange *pDX)
  95. {
  96. CDialog::DoDataExchange(pDX);
  97. //{{AFX_DATA_MAP(TextureSettingsDialogClass)
  98. DDX_Control(pDX, IDC_TYPE_COMBO, m_TypeCombo);
  99. DDX_Control(pDX, IDC_FPS_SPIN, m_FrameRateSpin);
  100. DDX_Control(pDX, IDC_FRAME_COUNT_SPIN, m_FrameCountSpin);
  101. //}}AFX_DATA_MAP
  102. return ;
  103. }
  104. BEGIN_MESSAGE_MAP(TextureSettingsDialogClass, CDialog)
  105. //{{AFX_MSG_MAP(TextureSettingsDialogClass)
  106. ON_BN_CLICKED(IDC_ANIMATION_CHECK, OnAnimationCheck)
  107. ON_WM_DESTROY()
  108. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton)
  109. ON_BN_CLICKED(IDC_RESTORE, OnRestore)
  110. ON_BN_CLICKED(IDC_APPLY, OnApply)
  111. //}}AFX_MSG_MAP
  112. END_MESSAGE_MAP()
  113. /////////////////////////////////////////////////////////////////////////////
  114. //
  115. // OnInitDialog
  116. //
  117. BOOL
  118. TextureSettingsDialogClass::OnInitDialog (void)
  119. {
  120. // Allow the base class to process this message
  121. CDialog::OnInitDialog ();
  122. ASSERT (m_pTexture != NULL);
  123. ASSERT (m_pTexture->getClassID () == ID_INDIRECT_TEXTURE_CLASS);
  124. // Determine what the starting texture was so we can restore on cancel (if necessary)
  125. m_pStartingTexture = m_pTexture->Get_Texture ();
  126. //m_pStartingTexture->addReference ();
  127. // Set the range of the spin controls
  128. m_FrameCountSpin.SetRange (1, 10000);
  129. m_FrameRateSpin.SetRange (1, 10000);
  130. // Remove the border from around our child window
  131. HWND hchild_wnd = ::GetDlgItem (m_hWnd, IDC_TEXTURE_THUMBNAIL);
  132. LONG style = ::GetWindowLong (hchild_wnd, GWL_STYLE);
  133. ::SetWindowLong (hchild_wnd, GWL_STYLE, style & (~WS_BORDER));
  134. // Enable or disable the 'restore' button based on whether or not we
  135. // have an original texture to switch to...
  136. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_RESTORE), (m_pOriginalTexture != NULL));
  137. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), FALSE);
  138. // Fill the dialog controls with data from the texture
  139. Load_Texture_Settings ();
  140. return TRUE;
  141. }
  142. ////////////////////////////////////////////////////////////////////////////
  143. //
  144. // Load_Texture_Settings
  145. //
  146. void
  147. TextureSettingsDialogClass::Load_Texture_Settings (void)
  148. {
  149. // Free the old thumbnail (if there was one)
  150. if (m_hThumbnail != NULL) {
  151. DeleteObject (m_hThumbnail);
  152. m_hThumbnail = NULL;
  153. }
  154. // Get the actual texture...
  155. TextureClass *ptexture = m_pTexture->Get_Texture ();
  156. // Refresh the preview window
  157. m_hThumbnail = Make_Bitmap_From_Texture (*ptexture, 96, 96);
  158. Paint_Thumbnail ();
  159. // Fill the controls using the texture pointer
  160. Fill_Controls (ptexture);
  161. Fill_Animation_Controls (ptexture);
  162. OnAnimationCheck ();
  163. // Release our hold on the texture
  164. SR_RELEASE (ptexture);
  165. return ;
  166. }
  167. /////////////////////////////////////////////////////////////////////////////
  168. //
  169. // Fill_Controls
  170. //
  171. void
  172. TextureSettingsDialogClass::Fill_Controls (TextureClass *ptexture)
  173. {
  174. srTexture *psource = NULL;
  175. // What type of texture is this?
  176. switch (ptexture->getClassID ())
  177. {
  178. case srClass::ID_TEXTURE_FILE:
  179. psource = (srTextureFile *)ptexture;
  180. SetDlgItemText (IDC_FILENAME_EDIT, ptexture->getName ());
  181. break;
  182. case ID_MANUAL_ANIM_TEXTURE_INSTANCE_CLASS:
  183. case ID_TIME_ANIM_TEXTURE_INSTANCE_CLASS:
  184. case ID_RESIZEABLE_TEXTURE_INSTANCE_CLASS:
  185. SendDlgItemMessage (IDC_RESIZEABLE_CHECK, BM_SETCHECK, (WPARAM)TRUE);
  186. psource = ((ResizeableTextureInstanceClass *)ptexture)->Peek_Source();
  187. // Fill the 'filename' edit control
  188. if (psource != NULL && (psource->getClassID () == ID_FILE_LIST_TEXTURE_CLASS)) {
  189. FileListTextureClass *pfile_list = static_cast<FileListTextureClass *>(psource);
  190. SetDlgItemText (IDC_FILENAME_EDIT, pfile_list->Get_Filename (0));
  191. }
  192. break;
  193. default:
  194. ASSERT (0);
  195. break;
  196. }
  197. // Set the checkboxes
  198. ASSERT (psource != NULL);
  199. if (psource != NULL) {
  200. SendDlgItemMessage (IDC_MIPMAP_OFF_CHECK, BM_SETCHECK, (WPARAM)(psource->getMipmap () == srTextureIFace::MIPMAP_NONE));
  201. SendDlgItemMessage (IDC_ALPHA_CHECK, BM_SETCHECK, (WPARAM)(psource->isHintEnabled(srTextureIFace::HINT_ALPHA_BITMASK)));
  202. SendDlgItemMessage (IDC_CLAMPU_CHECK, BM_SETCHECK, (WPARAM)(psource->Get_U_Addr_Mode() == TextureClass::TEXTURE_ADDRESS_CLAMP));
  203. SendDlgItemMessage (IDC_CLAMPV_CHECK, BM_SETCHECK, (WPARAM)(psource->Get_V_Addr_Mode() == TextureClass::TEXTURE_ADDRESS_CLAMP));
  204. }
  205. return ;
  206. }
  207. /////////////////////////////////////////////////////////////////////////////
  208. //
  209. // Fill_Animation_Controls
  210. //
  211. void
  212. TextureSettingsDialogClass::Fill_Animation_Controls (TextureClass *ptexture)
  213. {
  214. bool banimated = false;
  215. int frame_count = 0;
  216. float frames_per_sec = 0;
  217. ANIM_TYPES type = TYPE_ONCE;
  218. // What type is the texture?
  219. switch (ptexture->getClassID ())
  220. {
  221. case ID_MANUAL_ANIM_TEXTURE_INSTANCE_CLASS:
  222. {
  223. ManualAnimTextureInstanceClass *anim_texture = (ManualAnimTextureInstanceClass *)ptexture;
  224. frame_count = anim_texture->Get_Num_Frames ();
  225. frames_per_sec = 15.0F;
  226. type = TYPE_MANUAL;
  227. banimated = true;
  228. }
  229. break;
  230. case ID_TIME_ANIM_TEXTURE_INSTANCE_CLASS:
  231. {
  232. // What mode is this animated texture using
  233. TimeAnimTextureInstanceClass *anim_texture = (TimeAnimTextureInstanceClass *)ptexture;
  234. switch (anim_texture->Get_Mode ())
  235. {
  236. case TimeAnimTextureInstanceClass::ONE_TIME:
  237. type = TYPE_ONCE;
  238. break;
  239. case TimeAnimTextureInstanceClass::LOOP:
  240. type = TYPE_LOOP;
  241. break;
  242. case TimeAnimTextureInstanceClass::PINGPONG:
  243. type = TYPE_PING_PONG;
  244. break;
  245. };
  246. // Get the texture's frame rate and count
  247. frame_count = anim_texture->Get_Num_Frames ();
  248. frames_per_sec = anim_texture->Get_Frame_Rate ();
  249. banimated = true;
  250. }
  251. break;
  252. }
  253. // Check or uncheck the animation box depending on if it was an animated texture
  254. SendDlgItemMessage (IDC_ANIMATION_CHECK, BM_SETCHECK, (WPARAM)banimated);
  255. // Was this an animated texture?
  256. if (banimated == true) {
  257. // Pass the frame count onto the control
  258. frame_count = (frame_count > 0) ? frame_count : 1;
  259. SetDlgItemInt (IDC_FRAME_COUNT_EDIT, frame_count);
  260. m_FrameCountSpin.SetPos (frame_count);
  261. // Pass the frame rate onto the control
  262. frames_per_sec = (frames_per_sec > 0) ? frames_per_sec : 1;
  263. SetDlgItemInt (IDC_FPS_EDIT, (int)frames_per_sec);
  264. m_FrameRateSpin.SetPos (frames_per_sec);
  265. // Select the type in the combobox
  266. m_TypeCombo.SetCurSel ((int)type);
  267. } else {
  268. m_TypeCombo.SetCurSel (0);
  269. }
  270. return ;
  271. }
  272. /////////////////////////////////////////////////////////////////////////////
  273. //
  274. // OnOK
  275. //
  276. void
  277. TextureSettingsDialogClass::OnOK (void)
  278. {
  279. // Force the new settings to take effect
  280. OnApply ();
  281. // Allow the base class to process this message
  282. CDialog::OnOK ();
  283. return ;
  284. }
  285. /////////////////////////////////////////////////////////////////////////////
  286. //
  287. // OnCancel
  288. //
  289. void
  290. TextureSettingsDialogClass::OnCancel (void)
  291. {
  292. // Reuse the starting texture
  293. m_pTexture->Set_Texture (m_pStartingTexture);
  294. // Allow the base class to process this message
  295. CDialog::OnCancel ();
  296. return ;
  297. }
  298. /////////////////////////////////////////////////////////////////////////////
  299. //
  300. // OnAnimationCheck
  301. //
  302. void
  303. TextureSettingsDialogClass::OnAnimationCheck (void)
  304. {
  305. bool benable = (SendDlgItemMessage (IDC_ANIMATION_CHECK, BM_GETCHECK) == 1);
  306. // Enable or disable the controls based on the animation checkbox-state
  307. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_FRAME_COUNT_EDIT), benable);
  308. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_FPS_EDIT), benable);
  309. ::EnableWindow (m_TypeCombo, benable);
  310. ::EnableWindow (m_FrameRateSpin, benable);
  311. ::EnableWindow (m_FrameCountSpin, benable);
  312. return ;
  313. }
  314. /////////////////////////////////////////////////////////////////////////////
  315. //
  316. // WindowProc
  317. //
  318. LRESULT
  319. TextureSettingsDialogClass::WindowProc
  320. (
  321. UINT message,
  322. WPARAM wParam,
  323. LPARAM lParam
  324. )
  325. {
  326. if (message == WM_PAINT) {
  327. Paint_Thumbnail ();
  328. } else if (message == WM_COMMAND) {
  329. // What control sent us this notification?
  330. switch (LOWORD (wParam))
  331. {
  332. case IDC_FRAME_COUNT_EDIT:
  333. case IDC_FPS_EDIT:
  334. case IDC_FILENAME_EDIT:
  335. if ((HIWORD (wParam) == EN_UPDATE) ||
  336. (HIWORD (wParam) == EN_CHANGE)) {
  337. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), TRUE);
  338. }
  339. break;
  340. case IDC_MIPMAP_OFF_CHECK:
  341. case IDC_CLAMPU_CHECK:
  342. case IDC_CLAMPV_CHECK:
  343. case IDC_ALPHA_CHECK:
  344. case IDC_RESIZEABLE_CHECK:
  345. case IDC_ANIMATION_CHECK:
  346. if (HIWORD (wParam) == BN_CLICKED) {
  347. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), TRUE);
  348. }
  349. break;
  350. case IDC_TYPE_COMBO:
  351. if (HIWORD (wParam) == CBN_SELCHANGE) {
  352. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), TRUE);
  353. }
  354. break;
  355. }
  356. }
  357. // Allow the base class to process this message
  358. return CDialog::WindowProc (message, wParam, lParam);
  359. }
  360. /////////////////////////////////////////////////////////////////////////////
  361. //
  362. // OnDestroy
  363. //
  364. void
  365. TextureSettingsDialogClass::OnDestroy (void)
  366. {
  367. if (m_hThumbnail != NULL) {
  368. ::DeleteObject (m_hThumbnail);
  369. m_hThumbnail = NULL;
  370. }
  371. // Allow the base class to process this message
  372. CDialog::OnDestroy ();
  373. return ;
  374. }
  375. /////////////////////////////////////////////////////////////////////////////
  376. //
  377. // OnBrowseButton
  378. //
  379. void
  380. TextureSettingsDialogClass::OnBrowseButton (void)
  381. {
  382. // Get the current filename to display
  383. CString filename;
  384. GetDlgItemText (IDC_FILENAME_EDIT, filename);
  385. CFileDialog dialog (TRUE,
  386. ".tga",
  387. filename,
  388. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  389. "Targa files (*.tga)|*.tga||",
  390. this);
  391. // Ask the user what Targa file they wish to load
  392. if (dialog.DoModal () == IDOK) {
  393. WW3D::Add_Search_Path (::Strip_Filename_From_Path (dialog.GetFileName ()));
  394. // Set the text of the filename combobox control
  395. SetDlgItemText (IDC_FILENAME_EDIT, dialog.GetFileName ());
  396. SendDlgItemMessage (IDC_FILENAME_EDIT, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  397. // Enable the apply button
  398. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), TRUE);
  399. }
  400. return ;
  401. }
  402. /////////////////////////////////////////////////////////////////////////////
  403. //
  404. // Paint_Thumbnail
  405. //
  406. void
  407. TextureSettingsDialogClass::Paint_Thumbnail (void)
  408. {
  409. // Paint the thumbnail
  410. if (m_hThumbnail != NULL) {
  411. // Get the misc crap windows requries before we can
  412. // paint to the screen
  413. HWND hchild_wnd = ::GetDlgItem (m_hWnd, IDC_TEXTURE_THUMBNAIL);
  414. HDC hdc = ::GetDC (hchild_wnd);
  415. HDC hmem_dc = ::CreateCompatibleDC (NULL);
  416. HBITMAP hold_bmp = (HBITMAP)::SelectObject (hmem_dc, m_hThumbnail);
  417. // Paint the thumbnail onto the dialog
  418. CRect rect;
  419. ::GetClientRect (hchild_wnd, &rect);
  420. ::BitBlt (hdc,
  421. rect.left + (rect.Width () >> 1) - 48,
  422. rect.top + (rect.Height () >> 1) - 48,
  423. 96,
  424. 96,
  425. hmem_dc,
  426. 0,
  427. 0,
  428. SRCCOPY);
  429. // Release the misc windows crap
  430. ::SelectObject (hmem_dc, hold_bmp);
  431. ::ReleaseDC (hchild_wnd, hmem_dc);
  432. ::DeleteDC (hmem_dc);
  433. ::ValidateRect (hchild_wnd, NULL);
  434. }
  435. return ;
  436. }
  437. /////////////////////////////////////////////////////////////////////////////
  438. //
  439. // OnRestore
  440. //
  441. void
  442. TextureSettingsDialogClass::OnRestore (void)
  443. {
  444. if (m_pOriginalTexture != NULL) {
  445. // Get the original texture
  446. TextureClass *pnew_texture = m_pOriginalTexture->Get_Texture ();
  447. m_pTexture->Set_Texture (pnew_texture);
  448. MEMBER_RELEASE (pnew_texture);
  449. // Reload the dialog control settings
  450. Load_Texture_Settings ();
  451. // Disable the apply button because we just did...
  452. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), FALSE);
  453. }
  454. return ;
  455. }
  456. /////////////////////////////////////////////////////////////////////////////
  457. //
  458. // OnApply
  459. //
  460. void
  461. TextureSettingsDialogClass::OnApply (void)
  462. {
  463. // Get the current texture name from the edit control
  464. CString texture_name;
  465. GetDlgItemText (IDC_FILENAME_EDIT, texture_name);
  466. // Determine some of the texture settings
  467. TextureClass *pnew_texture = new TimeAnimTextureInstanceClass;
  468. bool resizeable = (SendDlgItemMessage (IDC_RESIZEABLE_CHECK, BM_GETCHECK) == TRUE);
  469. int frame_count = GetDlgItemInt (IDC_FRAME_COUNT_EDIT);
  470. int frame_rate = GetDlgItemInt (IDC_FPS_EDIT);
  471. // Does the user want this to be an animated texture?
  472. if (SendDlgItemMessage (IDC_ANIMATION_CHECK, BM_GETCHECK) == 1) {
  473. // What type of animated texture is this?
  474. switch ((ANIM_TYPES)m_TypeCombo.GetCurSel ())
  475. {
  476. case TYPE_LOOP:
  477. pnew_texture = new TimeAnimTextureInstanceClass (*(WW3DAssetManager::Get_Instance ()),
  478. texture_name,
  479. frame_count,
  480. (float)frame_rate,
  481. TimeAnimTextureInstanceClass::LOOP,
  482. TimeAnimTextureInstanceClass::FORWARD);
  483. break;
  484. case TYPE_ONCE:
  485. pnew_texture = new TimeAnimTextureInstanceClass (*(WW3DAssetManager::Get_Instance ()),
  486. texture_name,
  487. frame_count,
  488. (float)frame_rate,
  489. TimeAnimTextureInstanceClass::ONE_TIME,
  490. TimeAnimTextureInstanceClass::FORWARD);
  491. break;
  492. case TYPE_PING_PONG:
  493. pnew_texture = new TimeAnimTextureInstanceClass (*(WW3DAssetManager::Get_Instance ()),
  494. texture_name,
  495. frame_count,
  496. (float)frame_rate,
  497. TimeAnimTextureInstanceClass::PINGPONG,
  498. TimeAnimTextureInstanceClass::FORWARD);
  499. break;
  500. case TYPE_MANUAL:
  501. pnew_texture = new ManualAnimTextureInstanceClass (*(WW3DAssetManager::Get_Instance ()),
  502. texture_name,
  503. frame_count);
  504. break;
  505. }
  506. } else {
  507. // Should we allocate a resizeable texture or a normal one?
  508. /*if (resizeable) {
  509. pnew_texture = new ResizeableTextureInstanceClass (*(WW3DAssetManager::Get_Instance ()), texture_name);
  510. } else {*/
  511. // Normal texture, simply load it from file
  512. pnew_texture = WW3DAssetManager::Get_Instance ()->Get_Texture (texture_name);
  513. //}
  514. }
  515. ASSERT (pnew_texture != NULL);
  516. if (pnew_texture != NULL) {
  517. // Turn mipmapping off if necessary
  518. if (SendDlgItemMessage (IDC_MIPMAP_OFF_CHECK, BM_GETCHECK) == 1) {
  519. ::MipMapping_Off (pnew_texture);
  520. }
  521. // Compress the alpha channel to 1 bit if necessary
  522. if (SendDlgItemMessage (IDC_ALPHA_CHECK, BM_GETCHECK) == 1) {
  523. ::Set_Alpha_Bitmap (pnew_texture);
  524. }
  525. // Clamp the UVs if necessary
  526. ::Set_Clamping (pnew_texture,
  527. (SendDlgItemMessage (IDC_CLAMPU_CHECK, BM_GETCHECK) == 1),
  528. (SendDlgItemMessage (IDC_CLAMPV_CHECK, BM_GETCHECK) == 1));
  529. // Pass the new texture on, and free the old texture
  530. m_pTexture->Set_Texture (pnew_texture);
  531. // We now have a new starting texture... (used for cancel operations)
  532. SR_RELEASE (m_pStartingTexture);
  533. m_pStartingTexture = pnew_texture;
  534. // Reload any controls we might need to display changes...
  535. Load_Texture_Settings ();
  536. m_bWereSettingsModified = true;
  537. } else {
  538. MessageBox ("Unable to create the requested texture.", "Texture Error", MB_ICONERROR | MB_OK);
  539. }
  540. // Disable the apply button because we just did...
  541. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), FALSE);
  542. return ;
  543. }
  544. #endif //WW3D_DX8