DlgPgTexture.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // DlgPgTexture.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "DlgPgTexture.h"
  16. #ifdef _DEBUG
  17. #undef new
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. #define DIFFERENT_TEXTURE "Different\ntextures"
  23. #define NO_TEXTURE "No texture"
  24. #define NO_SELECTION "Empty\nselection"
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDlgPgTexture property page
  27. IMPLEMENT_DYNCREATE(CDlgPgTexture, CPropertyPage)
  28. CDlgPgTexture::CDlgPgTexture() : CPropertyPage(CDlgPgTexture::IDD)
  29. {
  30. //{{AFX_DATA_INIT(CDlgPgTexture)
  31. m_strTextureFile = _T("");
  32. m_fOffsetV = 0.0f;
  33. m_fOffsetU = 0.0f;
  34. m_radioTexture = -1;
  35. m_fRotationU = 0.0f;
  36. m_fRotationV = 0.0f;
  37. m_fStretchU = 0.0f;
  38. m_fStretchV = 0.0f;
  39. m_strTextureDim = _T("");
  40. //}}AFX_DATA_INIT
  41. m_ctrlCombineColor.SetPickerType( CColoredButton::PT_MFC);
  42. }
  43. CDlgPgTexture::~CDlgPgTexture()
  44. {
  45. }
  46. void CDlgPgTexture::DoDataExchange(CDataExchange* pDX)
  47. {
  48. if( theApp.m_bDisableDataExchange) return;
  49. CPropertyPage::DoDataExchange(pDX);
  50. // mark that property page has been modified
  51. SetModified( TRUE);
  52. // obtain document
  53. CWorldEditorDoc* pDoc = theApp.GetDocument();
  54. if( pDoc == NULL) return;
  55. // polygon mode must be on
  56. if( pDoc->GetEditingMode() != POLYGON_MODE) return;
  57. // if dialog is receiving data and control windows are valid
  58. if( (pDX->m_bSaveAndValidate == FALSE) && IsWindow( m_comboScroll.m_hWnd) )
  59. {
  60. m_comboScroll.ResetContent();
  61. for(INDEX iScroll=0; iScroll<256; iScroll++)
  62. {
  63. CTString strScrollName = pDoc->m_woWorld.wo_attTextureTransformations[iScroll].tt_strName;
  64. if( strScrollName != CTString("") ) m_comboScroll.AddString( CString(strScrollName));
  65. }
  66. m_comboBlend.ResetContent();
  67. for(INDEX iBlend=0; iBlend<256; iBlend++)
  68. {
  69. CTString strBlendName = pDoc->m_woWorld.wo_atbTextureBlendings[iBlend].tb_strName;
  70. if( strBlendName != CTString("") ) m_comboBlend.AddString( CString(strBlendName));
  71. }
  72. m_radioTexture = pDoc->m_iTexture;
  73. m_udTextureData.MarkUpdated();
  74. BOOL bSelectionExists = pDoc->m_selPolygonSelection.Count() != 0;
  75. // controls for editing polygon mapping can exist only while one polygon is selected
  76. GetDlgItem( IDC_STATIC_ROTATION_SHEAR)->EnableWindow( bSelectionExists);
  77. GetDlgItem( IDC_STATIC_STRETCH)->EnableWindow( bSelectionExists);
  78. GetDlgItem( IDC_ROTATION_U)->EnableWindow( bSelectionExists);
  79. GetDlgItem( IDC_ROTATION_V)->EnableWindow( bSelectionExists);
  80. GetDlgItem( IDC_STATIC_OFFSET)->EnableWindow( bSelectionExists);
  81. GetDlgItem( IDC_OFFSET_U)->EnableWindow( bSelectionExists);
  82. GetDlgItem( IDC_OFFSET_V)->EnableWindow( bSelectionExists);
  83. GetDlgItem( IDC_STRETCH_U)->EnableWindow( bSelectionExists);
  84. GetDlgItem( IDC_STRETCH_V)->EnableWindow( bSelectionExists);
  85. GetDlgItem( IDC_STATIC_BLEND)->EnableWindow( bSelectionExists);
  86. GetDlgItem( IDC_BLEND_TYPE)->EnableWindow( bSelectionExists);
  87. GetDlgItem( IDC_STATIC_SCROLL)->EnableWindow( bSelectionExists);
  88. GetDlgItem( IDC_SCROLL_COMBO)->EnableWindow( bSelectionExists);
  89. GetDlgItem( IDC_TEXTURE_FILE_T)->EnableWindow( bSelectionExists);
  90. GetDlgItem( IDC_BROWSE_TEXTURE)->EnableWindow( bSelectionExists);
  91. GetDlgItem( IDC_REMOVE_TEXTURE)->EnableWindow( bSelectionExists);
  92. GetDlgItem( IDC_CLAMP_U)->EnableWindow( bSelectionExists);
  93. GetDlgItem( IDC_CLAMP_V)->EnableWindow( bSelectionExists);
  94. GetDlgItem( IDC_REFLECTIVE)->EnableWindow( bSelectionExists);
  95. GetDlgItem( IDC_AFTER_SHADOW)->EnableWindow( bSelectionExists);
  96. GetDlgItem( IDC_PREVIEW_FRAME)->EnableWindow( bSelectionExists);
  97. m_ctrlCombineColor.EnableWindow( bSelectionExists);
  98. m_comboScroll.EnableWindow( bSelectionExists);
  99. m_comboBlend.EnableWindow( bSelectionExists);
  100. GetDlgItem( IDC_RADIO_TEXTURE)->EnableWindow( TRUE);
  101. GetDlgItem( IDC_TEXTURE_2)->EnableWindow( TRUE);
  102. GetDlgItem( IDC_TEXTURE_3)->EnableWindow( TRUE);
  103. if( !bSelectionExists)
  104. {
  105. m_strTextureFile = NO_SELECTION;
  106. m_strTextureDim = "";
  107. }
  108. else
  109. {
  110. UBYTE ubFirstScroll;
  111. BOOL bSameScroll = TRUE;
  112. UBYTE ubFirstBlend;
  113. BOOL bSameBlend = TRUE;
  114. UBYTE ubFlagsOn = MAX_UBYTE;
  115. UBYTE ubFlagsOff = MAX_UBYTE;
  116. GetDlgItem( IDC_PREVIEW_FRAME)->EnableWindow( TRUE);
  117. INDEX ctPolygons = 0;
  118. // for each of the selected polygons
  119. FOREACHINDYNAMICCONTAINER(pDoc->m_selPolygonSelection, CBrushPolygon, itbpo)
  120. {
  121. CBrushPolygon &bpo = *itbpo;
  122. ubFlagsOn &= bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubFlags;
  123. ubFlagsOff &= ~bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubFlags;
  124. CMappingDefinitionUI mdui;
  125. bpo.bpo_abptTextures[pDoc->m_iTexture].bpt_mdMapping.ToUI( mdui);
  126. CTextureData *ptdTexture = (CTextureData *) bpo.bpo_abptTextures[pDoc->m_iTexture].bpt_toTexture.GetData();
  127. if( ptdTexture == NULL)
  128. {
  129. GetDlgItem( IDC_PREVIEW_FRAME)->EnableWindow( FALSE);
  130. m_strTextureFile = NO_TEXTURE;
  131. m_strTextureDim = "";
  132. }
  133. else
  134. {
  135. CTString strTexture = ptdTexture->GetName();
  136. if( ctPolygons == 0)
  137. {
  138. m_ctrlCombineColor.SetColor( bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_colColor);
  139. m_strTextureFile = strTexture;
  140. m_strTextureDim = ptdTexture->GetDescription();
  141. }
  142. else
  143. {
  144. if( m_ctrlCombineColor.GetColor() != bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_colColor)
  145. {
  146. m_ctrlCombineColor.SetMixedColor();
  147. }
  148. if( m_strTextureFile != CString( strTexture))
  149. {
  150. GetDlgItem( IDC_PREVIEW_FRAME)->EnableWindow( FALSE);
  151. m_strTextureFile = DIFFERENT_TEXTURE;
  152. m_strTextureDim = "";
  153. }
  154. }
  155. }
  156. if( ctPolygons == 0)
  157. {
  158. m_fOffsetU = mdui.mdui_fUOffset; m_bOffsetU = TRUE;
  159. m_fOffsetV = mdui.mdui_fVOffset; m_bOffsetV = TRUE;
  160. m_fRotationU = mdui.mdui_aURotation;m_bRotationU = TRUE;
  161. m_fRotationV = mdui.mdui_aVRotation;m_bRotationV = TRUE;
  162. m_fStretchU = mdui.mdui_fUStretch; m_bStretchU = TRUE;
  163. m_fStretchV = mdui.mdui_fVStretch; m_bStretchV = TRUE;
  164. ubFirstScroll = bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubScroll;
  165. ubFirstBlend = bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubBlend;
  166. }
  167. else
  168. {
  169. if( m_fOffsetU != mdui.mdui_fUOffset) m_bOffsetU = FALSE;
  170. if( m_fOffsetV != mdui.mdui_fVOffset) m_bOffsetV = FALSE;
  171. if( m_fRotationU != mdui.mdui_aURotation) m_bRotationU = FALSE;
  172. if( m_fRotationV != mdui.mdui_aVRotation) m_bRotationV = FALSE;
  173. if( m_fStretchU != mdui.mdui_fUStretch) m_bStretchU = FALSE;
  174. if( m_fStretchV != mdui.mdui_fVStretch) m_bStretchV = FALSE;
  175. if( bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubScroll != ubFirstScroll) bSameScroll = FALSE;
  176. if( bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubBlend != ubFirstBlend) bSameBlend = FALSE;
  177. }
  178. ctPolygons++;
  179. }
  180. if( bSameScroll) m_comboScroll.SetCurSel( ubFirstScroll); else m_comboScroll.SetCurSel(-1);
  181. if( bSameBlend) m_comboBlend.SetCurSel( ubFirstBlend); else m_comboBlend.SetCurSel(-1);
  182. // set states of all flags using on and off masks
  183. if((ubFlagsOn & BPTF_CLAMPU) && !(ubFlagsOff & BPTF_CLAMPU)) m_checkClampU.SetCheck( 1);
  184. else if(!(ubFlagsOn & BPTF_CLAMPU) && (ubFlagsOff & BPTF_CLAMPU)) m_checkClampU.SetCheck( 0);
  185. else m_checkClampU.SetCheck( 2);
  186. if((ubFlagsOn & BPTF_CLAMPV) && !(ubFlagsOff & BPTF_CLAMPV)) m_checkClampV.SetCheck( 1);
  187. else if(!(ubFlagsOn & BPTF_CLAMPV) && (ubFlagsOff & BPTF_CLAMPV)) m_checkClampV.SetCheck( 0);
  188. else m_checkClampV.SetCheck( 2);
  189. if((ubFlagsOn & BPTF_REFLECTION) && !(ubFlagsOff & BPTF_REFLECTION)) m_checkReflective.SetCheck( 1);
  190. else if(!(ubFlagsOn & BPTF_REFLECTION) && (ubFlagsOff & BPTF_REFLECTION)) m_checkReflective.SetCheck( 0);
  191. else m_checkReflective.SetCheck( 2);
  192. if((ubFlagsOn & BPTF_AFTERSHADOW) && !(ubFlagsOff & BPTF_AFTERSHADOW)) m_checkAfterShadow.SetCheck( 1);
  193. else if(!(ubFlagsOn & BPTF_AFTERSHADOW) && (ubFlagsOff & BPTF_AFTERSHADOW)) m_checkAfterShadow.SetCheck( 0);
  194. else m_checkAfterShadow.SetCheck( 2);
  195. }
  196. }
  197. //{{AFX_DATA_MAP(CDlgPgTexture)
  198. DDX_Control(pDX, IDC_AFTER_SHADOW, m_checkAfterShadow);
  199. DDX_Control(pDX, ID_COMBINE_COLOR, m_ctrlCombineColor);
  200. DDX_Control(pDX, IDC_BLEND_TYPE, m_comboBlend);
  201. DDX_Control(pDX, IDC_REFLECTIVE, m_checkReflective);
  202. DDX_Control(pDX, IDC_CLAMP_V, m_checkClampV);
  203. DDX_Control(pDX, IDC_CLAMP_U, m_checkClampU);
  204. DDX_Control(pDX, IDC_SCROLL_COMBO, m_comboScroll);
  205. DDX_Text(pDX, IDC_TEXTURE_FILE_T, m_strTextureFile);
  206. DDX_Radio(pDX, IDC_RADIO_TEXTURE, m_radioTexture);
  207. DDX_Text(pDX, IDC_TEXTURE_DIM_T, m_strTextureDim);
  208. //}}AFX_DATA_MAP
  209. DDX_SkyFloat(pDX, IDC_OFFSET_U, m_fOffsetU, m_bOffsetU);
  210. DDX_SkyFloat(pDX, IDC_OFFSET_V, m_fOffsetV, m_bOffsetV);
  211. DDX_SkyFloat(pDX, IDC_STRETCH_U, m_fStretchU, m_bStretchU);
  212. DDX_SkyFloat(pDX, IDC_STRETCH_V, m_fStretchV, m_bStretchV);
  213. DDX_SkyFloat(pDX, IDC_ROTATION_U, m_fRotationU, m_bRotationU);
  214. DDX_SkyFloat(pDX, IDC_ROTATION_V, m_fRotationV, m_bRotationV);
  215. // if dialog is giving data and control windows are valid
  216. if( (pDX->m_bSaveAndValidate != FALSE) && IsWindow( m_comboScroll.m_hWnd) )
  217. {
  218. m_udTextureData.MarkUpdated();
  219. // paste new active texture over polygon selection
  220. if( (m_strTextureFile != DIFFERENT_TEXTURE) &&
  221. (m_strTextureFile != NO_SELECTION) )
  222. {
  223. if( m_strTextureFile == NO_TEXTURE)
  224. {
  225. pDoc->PasteTextureOverSelection_t( CTString(""));
  226. }
  227. else
  228. {
  229. pDoc->PasteTextureOverSelection_t( CTString( CStringA(m_strTextureFile)));
  230. }
  231. }
  232. // obtain masks for setting and clearing texture flags
  233. ULONG ulBitsToClear = MAX_ULONG;
  234. ULONG ulBitsToSet = 0;
  235. if( m_checkClampU.GetCheck() == 0) ulBitsToClear &= ~BPTF_CLAMPU;
  236. if( m_checkClampU.GetCheck() == 1) ulBitsToSet |= BPTF_CLAMPU;
  237. if( m_checkClampV.GetCheck() == 0) ulBitsToClear &= ~BPTF_CLAMPV;
  238. if( m_checkClampV.GetCheck() == 1) ulBitsToSet |= BPTF_CLAMPV;
  239. if( m_checkReflective.GetCheck() == 0) ulBitsToClear &= ~BPTF_REFLECTION;
  240. if( m_checkReflective.GetCheck() == 1) ulBitsToSet |= BPTF_REFLECTION;
  241. if( m_checkAfterShadow.GetCheck() == 0) ulBitsToClear &= ~BPTF_AFTERSHADOW;
  242. if( m_checkAfterShadow.GetCheck() == 1) ulBitsToSet |= BPTF_AFTERSHADOW;
  243. // for each of the selected polygons
  244. FOREACHINDYNAMICCONTAINER(pDoc->m_selPolygonSelection, CBrushPolygon, itbpo)
  245. {
  246. CBrushPolygon &bpo = *itbpo;
  247. bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubFlags &= ulBitsToClear;
  248. bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubFlags |= ulBitsToSet;
  249. CMappingDefinitionUI mdui;
  250. bpo.bpo_abptTextures[pDoc->m_iTexture].bpt_mdMapping.ToUI( mdui);
  251. if( m_bOffsetU) mdui.mdui_fUOffset = m_fOffsetU;
  252. if( m_bOffsetV) mdui.mdui_fVOffset = m_fOffsetV;
  253. if( m_bRotationU) mdui.mdui_aURotation = m_fRotationU;
  254. if( m_bRotationV) mdui.mdui_aVRotation = m_fRotationV;
  255. if( m_bStretchU) mdui.mdui_fUStretch = m_fStretchU;
  256. if( m_bStretchV) mdui.mdui_fVStretch = m_fStretchV;
  257. bpo.bpo_abptTextures[pDoc->m_iTexture].bpt_mdMapping.FromUI( mdui);
  258. INDEX iScroll = m_comboScroll.GetCurSel();
  259. if( iScroll != -1) bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubScroll = (UBYTE)iScroll;
  260. INDEX iBlend = m_comboBlend.GetCurSel();
  261. if( iBlend != -1) bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_ubBlend = (UBYTE)iBlend;
  262. if( m_ctrlCombineColor.IsColorValid())
  263. {
  264. bpo.bpo_abptTextures[pDoc->m_iTexture].s.bpt_colColor = m_ctrlCombineColor.GetColor();
  265. }
  266. }
  267. pDoc->UpdateAllViews( NULL);
  268. pDoc->SetModifiedFlag( TRUE);
  269. }
  270. // set file name of texture for thumbnail window
  271. CString strWindowText;
  272. GetDlgItem( IDC_TEXTURE_FILE_T)->GetWindowText( strWindowText);
  273. m_wndViewTexture.m_strTexture = CStringA(strWindowText);
  274. if( IsWindow( m_wndViewTexture.m_hWnd))
  275. {
  276. m_wndViewTexture.Invalidate( FALSE);
  277. }
  278. }
  279. BEGIN_MESSAGE_MAP(CDlgPgTexture, CPropertyPage)
  280. //{{AFX_MSG_MAP(CDlgPgTexture)
  281. ON_BN_CLICKED(IDC_BROWSE_TEXTURE, OnBrowseTexture)
  282. ON_BN_CLICKED(IDC_RADIO_TEXTURE, OnRadioTexture)
  283. ON_BN_CLICKED(IDC_TEXTURE_2, OnTexture2)
  284. ON_BN_CLICKED(IDC_TEXTURE_3, OnTexture3)
  285. ON_BN_CLICKED(IDC_REMOVE_TEXTURE, OnRemoveTexture)
  286. ON_CBN_SELCHANGE(IDC_SCROLL_COMBO, OnSelchangeScrollCombo)
  287. ON_WM_DROPFILES()
  288. ON_CBN_SELCHANGE(IDC_BLEND_TYPE, OnSelchangeBlendType)
  289. ON_CBN_DROPDOWN(IDC_SCROLL_COMBO, OnDropdownScrollCombo)
  290. ON_CBN_DROPDOWN(IDC_BLEND_TYPE, OnDropdownBlendType)
  291. //}}AFX_MSG_MAP
  292. END_MESSAGE_MAP()
  293. /////////////////////////////////////////////////////////////////////////////
  294. // CDlgPgTexture message handlers
  295. BOOL CDlgPgTexture::OnInitDialog()
  296. {
  297. CPropertyPage::OnInitDialog();
  298. // obtain document
  299. CWorldEditorDoc* pDoc = theApp.GetDocument();
  300. m_ctrlCombineColor.SetDialogPtr( this);
  301. m_checkReflective.SetDialogPtr( this);
  302. m_checkAfterShadow.SetDialogPtr( this);
  303. m_checkClampV.SetDialogPtr( this);
  304. m_checkClampU.SetDialogPtr( this);
  305. PIX pixLeft = 0;
  306. PIX pixTop = 30;
  307. m_wndViewTexture.Create(NULL, NULL, WS_BORDER|WS_VISIBLE,
  308. CRect( pixLeft, pixTop, pixLeft+64, pixTop+64),
  309. this, IDW_SHOW_TEXTURE);
  310. DragAcceptFiles();
  311. if( pDoc == NULL)
  312. {
  313. m_radioTexture = 0;
  314. }
  315. else
  316. {
  317. m_radioTexture = pDoc->m_iTexture;
  318. }
  319. return TRUE;
  320. }
  321. BOOL CDlgPgTexture::OnIdle(LONG lCount)
  322. {
  323. CWorldEditorDoc* pDoc = theApp.GetDocument();
  324. if( (pDoc == NULL) || !IsWindow(m_hWnd)) return FALSE;
  325. // if polygon selection have been changed update dialog
  326. if( !pDoc->m_chSelections.IsUpToDate( m_udTextureData))
  327. {
  328. UpdateData( FALSE);
  329. }
  330. return TRUE;
  331. }
  332. void CDlgPgTexture::OnBrowseTexture()
  333. {
  334. char achrDirectory[256], achrMessage[256];
  335. if( &CDlgPgTexture::OnRadioTexture == 0)
  336. {
  337. strcpy( achrDirectory, "Hyper texture directory");
  338. strcpy( achrMessage, "Browse hyper texture");
  339. }
  340. else
  341. {
  342. strcpy( achrDirectory, "Texture directory");
  343. strcpy( achrMessage, "Browse texture");
  344. }
  345. CTFileName fnTexture = _EngineGUI.BrowseTexture( CTString(""), achrDirectory, achrMessage);
  346. if( fnTexture != "")
  347. {
  348. GetDlgItem( IDC_TEXTURE_FILE_T)->SetWindowText( CString(fnTexture));
  349. }
  350. // to reflect data change
  351. UpdateData( TRUE);
  352. }
  353. void CDlgPgTexture::OnRemoveTexture()
  354. {
  355. GetDlgItem( IDC_TEXTURE_FILE_T)->SetWindowText( L"No texture");
  356. // apply data change
  357. UpdateData( TRUE);
  358. }
  359. void CDlgPgTexture::OnRadioTexture()
  360. {
  361. CWorldEditorDoc* pDoc = theApp.GetDocument();
  362. if( pDoc == NULL) return;
  363. pDoc->m_iTexture = 0;
  364. UpdateData( FALSE);
  365. }
  366. void CDlgPgTexture::OnTexture2()
  367. {
  368. CWorldEditorDoc* pDoc = theApp.GetDocument();
  369. if( pDoc == NULL) return;
  370. pDoc->m_iTexture = 1;
  371. UpdateData( FALSE);
  372. }
  373. void CDlgPgTexture::OnTexture3()
  374. {
  375. CWorldEditorDoc* pDoc = theApp.GetDocument();
  376. if( pDoc == NULL) return;
  377. pDoc->m_iTexture = 2;
  378. UpdateData( FALSE);
  379. }
  380. void CDlgPgTexture::OnSelchangeScrollCombo()
  381. {
  382. UpdateData( TRUE);
  383. }
  384. void CDlgPgTexture::OnSelchangeBlendType()
  385. {
  386. UpdateData( TRUE);
  387. }
  388. void CDlgPgTexture::OnDropFiles(HDROP hDropInfo)
  389. {
  390. if( m_strTextureFile == NO_SELECTION)
  391. {
  392. return;
  393. }
  394. INDEX iNoOfFiles = DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0);
  395. if( iNoOfFiles != 1)
  396. {
  397. AfxMessageBox( L"You can drop only one file at a time.");
  398. return;
  399. }
  400. // buffer for dropped file name
  401. char chrFile[ 256];
  402. // place dropped file name into buffer
  403. DragQueryFileA( hDropInfo, 0, chrFile, 256);
  404. // create file name from buffer
  405. CTFileName fnDropped = CTString(chrFile);
  406. // if it is not texture, report error
  407. if( fnDropped.FileExt() != ".tex" )
  408. {
  409. AfxMessageBox( L"You can only drop textures here.");
  410. return;
  411. }
  412. try
  413. {
  414. fnDropped.RemoveApplicationPath_t();
  415. GetDlgItem( IDC_TEXTURE_FILE_T)->SetWindowText( CString(fnDropped));
  416. // apply data change
  417. UpdateData( TRUE);
  418. }
  419. catch( char *err_str)
  420. {
  421. AfxMessageBox( CString(err_str));
  422. }
  423. }
  424. BOOL CDlgPgTexture::PreTranslateMessage(MSG* pMsg)
  425. {
  426. if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
  427. {
  428. UpdateData( TRUE);
  429. UpdateData( FALSE);
  430. // the message is handled
  431. return TRUE;
  432. }
  433. return CPropertyPage::PreTranslateMessage(pMsg);
  434. }
  435. void CDlgPgTexture::OnDropdownScrollCombo()
  436. {
  437. m_comboScroll.SetDroppedWidth(256);
  438. }
  439. void CDlgPgTexture::OnDropdownBlendType()
  440. {
  441. m_comboBlend.SetDroppedWidth(256);
  442. }