DlgPgShadow.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. // DlgPgShadow.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "DlgPgShadow.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. /////////////////////////////////////////////////////////////////////////////
  23. // CDlgPgShadow property page
  24. IMPLEMENT_DYNCREATE(CDlgPgShadow, CPropertyPage)
  25. CDlgPgShadow::CDlgPgShadow() : CPropertyPage(CDlgPgShadow::IDD)
  26. {
  27. m_ctrlShadowColor.SetPickerType( CColoredButton::PT_MFC);
  28. //{{AFX_DATA_INIT(CDlgPgShadow)
  29. //}}AFX_DATA_INIT
  30. }
  31. CDlgPgShadow::~CDlgPgShadow()
  32. {
  33. }
  34. void CDlgPgShadow::DoDataExchange(CDataExchange* pDX)
  35. {
  36. if( theApp.m_bDisableDataExchange) return;
  37. CPropertyPage::DoDataExchange(pDX);
  38. // mark that property page has been modified
  39. SetModified( TRUE);
  40. // obtain document
  41. CWorldEditorDoc* pDoc = theApp.GetDocument();
  42. if( pDoc == NULL) return;
  43. // polygon mode must be on
  44. if( pDoc->GetEditingMode() != POLYGON_MODE) return;
  45. // get flags of control activity
  46. BOOL bSelectionExists = pDoc->m_selPolygonSelection.Count() != 0;
  47. // if dialog is recieving data and control window is valid
  48. if( (pDX->m_bSaveAndValidate == FALSE) && IsWindow( m_NoShadow.m_hWnd) )
  49. {
  50. // initialize combo boxes
  51. InitComboBoxes();
  52. // polygon controls exist if polygon selection exists
  53. m_bNoPlaneDiffusion.EnableWindow( bSelectionExists);
  54. m_bDarkCorners.EnableWindow( bSelectionExists);
  55. m_bDynamicLightsOnly.EnableWindow( bSelectionExists);
  56. m_bHasDirectionalShadows.EnableWindow( bSelectionExists);
  57. m_bHasPreciseShadows.EnableWindow( bSelectionExists);
  58. m_bHasDirectionalAmbient.EnableWindow( bSelectionExists);
  59. m_IsLightBeamPassable.EnableWindow( bSelectionExists);
  60. m_bDontReceiveShadows.EnableWindow( bSelectionExists);
  61. m_bNoDynamicLights.EnableWindow( bSelectionExists);
  62. m_NoShadow.EnableWindow( bSelectionExists);
  63. m_ctrlComboClusterSize.EnableWindow( bSelectionExists);
  64. m_comboShadowBlend.EnableWindow( bSelectionExists);
  65. m_ComboIllumination.EnableWindow( bSelectionExists);
  66. m_ctrlComboGradient.EnableWindow( bSelectionExists);
  67. GetDlgItem( IDC_STATIC_CLUSTER_SIZE)->EnableWindow( bSelectionExists);
  68. GetDlgItem( IDC_STATIC_ILLUMINATION)->EnableWindow( bSelectionExists);
  69. GetDlgItem( IDC_STATIC_GRADIENT)->EnableWindow( bSelectionExists);
  70. GetDlgItem( IDC_STATIC_SHADOW_COLOR)->EnableWindow( bSelectionExists);
  71. GetDlgItem( IDC_STATIC_SHADOW_BLEND)->EnableWindow( bSelectionExists);
  72. m_ctrlShadowColor.EnableWindow( bSelectionExists);
  73. // if selection exists, calculate tri-state value of attribute intersection
  74. if( bSelectionExists)
  75. {
  76. // get properties from first polygon
  77. UBYTE ubFirstIllumination;
  78. SBYTE sbFirstShadowClusterSize;
  79. UBYTE ubFirstShadowBlend;
  80. UBYTE ubFirstGradient;
  81. BOOL bSameIllumination = TRUE;
  82. BOOL bSameShadowClusterSize = TRUE;
  83. BOOL bSameShadowBlend = TRUE;
  84. BOOL bSameGradient = TRUE;
  85. ULONG ulFlagsOn = MAX_ULONG;
  86. ULONG ulFlagsOff = MAX_ULONG;
  87. INDEX iPolygon = 0;
  88. // for each of the selected polygons
  89. FOREACHINDYNAMICCONTAINER(pDoc->m_selPolygonSelection, CBrushPolygon, itbpo)
  90. {
  91. ulFlagsOn &= itbpo->bpo_ulFlags;
  92. ulFlagsOff &= ~itbpo->bpo_ulFlags;
  93. if( iPolygon == 0)
  94. {
  95. ubFirstIllumination = itbpo->bpo_bppProperties.bpp_ubIlluminationType;
  96. sbFirstShadowClusterSize = itbpo->bpo_bppProperties.bpp_sbShadowClusterSize;
  97. ubFirstShadowBlend = itbpo->bpo_bppProperties.bpp_ubShadowBlend;
  98. ubFirstGradient = itbpo->bpo_bppProperties.bpp_ubGradientType;
  99. m_ctrlShadowColor.SetColor( itbpo->bpo_colShadow);
  100. }
  101. else
  102. {
  103. if( m_ctrlShadowColor.GetColor() != itbpo->bpo_colShadow)
  104. {
  105. m_ctrlShadowColor.SetMixedColor();
  106. }
  107. if( itbpo->bpo_bppProperties.bpp_ubIlluminationType != ubFirstIllumination) bSameIllumination = FALSE;
  108. if( itbpo->bpo_bppProperties.bpp_sbShadowClusterSize != sbFirstShadowClusterSize) bSameShadowClusterSize = FALSE;
  109. if( itbpo->bpo_bppProperties.bpp_ubShadowBlend != ubFirstShadowBlend) bSameShadowBlend = FALSE;
  110. if( itbpo->bpo_bppProperties.bpp_ubGradientType != ubFirstGradient) bSameGradient = FALSE;
  111. }
  112. iPolygon++;
  113. }
  114. // apply flags to controls
  115. #define SET_TRI_STATE_TO_CTRL( ctrl, flag)\
  116. if((ulFlagsOn & flag) && !(ulFlagsOff & flag)) ctrl.SetCheck( 1);\
  117. else if(!(ulFlagsOn & flag) && (ulFlagsOff & flag)) ctrl.SetCheck( 0);\
  118. else ctrl.SetCheck( 2);
  119. SET_TRI_STATE_TO_CTRL( m_bHasDirectionalShadows, BPOF_HASDIRECTIONALLIGHT);
  120. SET_TRI_STATE_TO_CTRL( m_bHasPreciseShadows, BPOF_ACCURATESHADOWS);
  121. SET_TRI_STATE_TO_CTRL( m_bHasDirectionalAmbient, BPOF_HASDIRECTIONALAMBIENT);
  122. SET_TRI_STATE_TO_CTRL( m_bNoPlaneDiffusion, BPOF_NOPLANEDIFFUSION);
  123. SET_TRI_STATE_TO_CTRL( m_bDarkCorners, BPOF_DARKCORNERS);
  124. SET_TRI_STATE_TO_CTRL( m_bDynamicLightsOnly, BPOF_DYNAMICLIGHTSONLY);
  125. SET_TRI_STATE_TO_CTRL( m_IsLightBeamPassable, BPOF_DOESNOTCASTSHADOW);
  126. SET_TRI_STATE_TO_CTRL( m_bDontReceiveShadows, BPOF_DOESNOTRECEIVESHADOW);
  127. SET_TRI_STATE_TO_CTRL( m_bNoDynamicLights, BPOF_NODYNAMICLIGHTS);
  128. SET_TRI_STATE_TO_CTRL( m_NoShadow, BPOF_FULLBRIGHT);
  129. if( bSameIllumination)
  130. {
  131. for( INDEX iIllumination=0; iIllumination<m_ComboIllumination.GetCount(); iIllumination++)
  132. {
  133. INDEX iIlluminationData = m_ComboIllumination.GetItemData( iIllumination);
  134. if( iIlluminationData==ubFirstIllumination)
  135. {
  136. m_ComboIllumination.SetCurSel( iIllumination);
  137. break;
  138. }
  139. }
  140. }
  141. else m_ComboIllumination.SetCurSel(-1);
  142. if( bSameShadowClusterSize) m_ctrlComboClusterSize.SetCurSel( sbFirstShadowClusterSize+4);
  143. else m_ctrlComboClusterSize.SetCurSel(-1);
  144. if( bSameShadowBlend) m_comboShadowBlend.SetCurSel( ubFirstShadowBlend);
  145. else m_comboShadowBlend.SetCurSel(-1);
  146. if( bSameGradient) m_ctrlComboGradient.SetCurSel( ubFirstGradient);
  147. else m_ctrlComboGradient.SetCurSel(-1);
  148. }
  149. // mark that page is updated
  150. m_udPolygonSelection.MarkUpdated();
  151. }
  152. //{{AFX_DATA_MAP(CDlgPgShadow)
  153. DDX_Control(pDX, IDC_GRADIENT_COMBO, m_ctrlComboGradient);
  154. DDX_Control(pDX, IDC_DARK_CORNERS, m_bDarkCorners);
  155. DDX_Control(pDX, IDC_NO_DYNAMIC_LIGHTS, m_bNoDynamicLights);
  156. DDX_Control(pDX, IDC_IS_RECEIVING_SHADOWS, m_bDontReceiveShadows);
  157. DDX_Control(pDX, IDC_DYNAMIC_LIGHTS_ONLY, m_bDynamicLightsOnly);
  158. DDX_Control(pDX, IDC_HAS_DIRECTIONAL_AMBIENT, m_bHasDirectionalAmbient);
  159. DDX_Control(pDX, IDC_HAS_PRECISE_SHADOWS, m_bHasPreciseShadows);
  160. DDX_Control(pDX, IDC_NO_PLANE_DIFFUSION, m_bNoPlaneDiffusion);
  161. DDX_Control(pDX, IDC_HAS_DIRECTIONAL_SHADOWS, m_bHasDirectionalShadows);
  162. DDX_Control(pDX, IDC_NO_SHADOW, m_NoShadow);
  163. DDX_Control(pDX, IDC_IS_LIGHT_BEAM_PASSABLLE, m_IsLightBeamPassable);
  164. DDX_Control(pDX, ID_SHADOW_COLOR, m_ctrlShadowColor);
  165. DDX_Control(pDX, IDC_SHADOW_BLEND_COMBO, m_comboShadowBlend);
  166. DDX_Control(pDX, IDC_CLUSTER_SIZE_COMBO, m_ctrlComboClusterSize);
  167. DDX_Control(pDX, IDC_ILLUMINATION_COMBO, m_ComboIllumination);
  168. //}}AFX_DATA_MAP
  169. // if dialog is giving data
  170. if( pDX->m_bSaveAndValidate != FALSE)
  171. {
  172. BOOL bFindShadowLayers = FALSE;
  173. BOOL bOnlySelected = TRUE;
  174. // calculate bounding box for all polygons
  175. FLOATaabbox3D boxBoundingBoxPolygonSelection;
  176. FOREACHINDYNAMICCONTAINER(pDoc->m_selPolygonSelection, CBrushPolygon, itbpo)
  177. {
  178. boxBoundingBoxPolygonSelection |= itbpo->bpo_boxBoundingBox;
  179. if( m_comboShadowBlend.GetCurSel()!=-1) itbpo->bpo_bppProperties.bpp_ubShadowBlend = m_comboShadowBlend.GetCurSel();
  180. INDEX iItem = m_ComboIllumination.GetCurSel();
  181. if( iItem!=CB_ERR)
  182. {
  183. INDEX iIlluminationToSet = m_ComboIllumination.GetItemData( iItem);
  184. if( itbpo->bpo_bppProperties.bpp_ubIlluminationType != iIlluminationToSet)
  185. {
  186. itbpo->bpo_bppProperties.bpp_ubIlluminationType = (UBYTE) iIlluminationToSet;
  187. itbpo->bpo_smShadowMap.Uncache();
  188. itbpo->DiscardShadows();
  189. bFindShadowLayers = TRUE;
  190. bOnlySelected = FALSE;
  191. }
  192. }
  193. INDEX iShadowClusterSize = m_ctrlComboClusterSize.GetCurSel()-4;
  194. if( (m_ctrlComboClusterSize.GetCurSel()!=-1) &&
  195. (itbpo->bpo_bppProperties.bpp_sbShadowClusterSize != iShadowClusterSize) )
  196. {
  197. itbpo->bpo_bppProperties.bpp_sbShadowClusterSize = (SBYTE) iShadowClusterSize;
  198. // discard all shadow layers on the polygon.
  199. itbpo->bpo_smShadowMap.DiscardAllLayers();
  200. itbpo->InitializeShadowMap();
  201. bFindShadowLayers = TRUE;
  202. }
  203. INDEX iGradient = m_ctrlComboGradient.GetCurSel();
  204. if( iGradient!=CB_ERR)
  205. {
  206. if( itbpo->bpo_bppProperties.bpp_ubGradientType != iGradient)
  207. {
  208. itbpo->bpo_bppProperties.bpp_ubGradientType = (UBYTE) iGradient;
  209. itbpo->bpo_smShadowMap.DiscardAllLayers();
  210. itbpo->InitializeShadowMap();
  211. bFindShadowLayers = TRUE;
  212. }
  213. }
  214. // set polygon's flags acording witg given tri-state ctrl
  215. #define TRI_STATE_CTRL_TO_FLAGS( ctrl, flag, buncache, bdiscardshadows, bfindshadowlayers, bonlyselected)\
  216. if( (ctrl.GetCheck() == 1) && !(itbpo->bpo_ulFlags & flag) ) {\
  217. itbpo->bpo_ulFlags |= flag;\
  218. if( buncache) itbpo->bpo_smShadowMap.Uncache();\
  219. if( bdiscardshadows) itbpo->DiscardShadows();\
  220. bFindShadowLayers |= bfindshadowlayers;\
  221. bOnlySelected &= bonlyselected ;\
  222. } else if( (ctrl.GetCheck() == 0) && (itbpo->bpo_ulFlags & flag) ) {\
  223. itbpo->bpo_ulFlags &= ~flag;\
  224. if( buncache) itbpo->bpo_smShadowMap.Uncache();\
  225. if( bdiscardshadows) itbpo->DiscardShadows();\
  226. bFindShadowLayers |= bfindshadowlayers;\
  227. bOnlySelected &= bonlyselected ;\
  228. }
  229. TRI_STATE_CTRL_TO_FLAGS( m_bNoPlaneDiffusion, BPOF_NOPLANEDIFFUSION, TRUE, FALSE, FALSE, FALSE);
  230. TRI_STATE_CTRL_TO_FLAGS( m_bDarkCorners, BPOF_DARKCORNERS, TRUE, TRUE, TRUE, TRUE);
  231. TRI_STATE_CTRL_TO_FLAGS( m_bDynamicLightsOnly, BPOF_DYNAMICLIGHTSONLY, TRUE, FALSE, FALSE, FALSE);
  232. TRI_STATE_CTRL_TO_FLAGS( m_bHasDirectionalShadows, BPOF_HASDIRECTIONALLIGHT, TRUE, TRUE, TRUE, TRUE);
  233. TRI_STATE_CTRL_TO_FLAGS( m_bHasPreciseShadows, BPOF_ACCURATESHADOWS, TRUE, TRUE, TRUE, TRUE);
  234. TRI_STATE_CTRL_TO_FLAGS( m_bHasDirectionalAmbient, BPOF_HASDIRECTIONALAMBIENT, TRUE, FALSE, FALSE, FALSE);
  235. TRI_STATE_CTRL_TO_FLAGS( m_IsLightBeamPassable, BPOF_DOESNOTCASTSHADOW, TRUE, TRUE, TRUE, FALSE);
  236. TRI_STATE_CTRL_TO_FLAGS( m_bDontReceiveShadows, BPOF_DOESNOTRECEIVESHADOW, TRUE, TRUE, TRUE, TRUE);
  237. TRI_STATE_CTRL_TO_FLAGS( m_bNoDynamicLights, BPOF_NODYNAMICLIGHTS, FALSE, FALSE, FALSE, TRUE);
  238. TRI_STATE_CTRL_TO_FLAGS( m_NoShadow, BPOF_FULLBRIGHT, TRUE, TRUE, TRUE, TRUE);
  239. if( m_ctrlShadowColor.IsColorValid()) {
  240. itbpo->bpo_colShadow = m_ctrlShadowColor.GetColor();
  241. }
  242. }
  243. // if we should find shadow layers
  244. if( bFindShadowLayers)
  245. {
  246. pDoc->m_woWorld.FindShadowLayers( boxBoundingBoxPolygonSelection, bOnlySelected);
  247. }
  248. // mark that document is changed
  249. theApp.GetDocument()->SetModifiedFlag( TRUE);
  250. // redraw to show changes
  251. pDoc->UpdateAllViews( NULL);
  252. }
  253. }
  254. BEGIN_MESSAGE_MAP(CDlgPgShadow, CPropertyPage)
  255. //{{AFX_MSG_MAP(CDlgPgShadow)
  256. ON_CBN_SELCHANGE(IDC_CLUSTER_SIZE_COMBO, OnSelchangeShadowClusterSizeCombo)
  257. ON_CBN_SELCHANGE(IDC_ILLUMINATION_COMBO, OnSelchangeIlluminationCombo)
  258. ON_CBN_DROPDOWN(IDC_ILLUMINATION_COMBO, OnDropdownIlluminationCombo)
  259. ON_CBN_SELCHANGE(IDC_SHADOW_BLEND_COMBO, OnSelchangeShadowBlendCombo)
  260. ON_CBN_DROPDOWN(IDC_SHADOW_BLEND_COMBO, OnDropdownShadowBlendCombo)
  261. ON_CBN_DROPDOWN(IDC_CLUSTER_SIZE_COMBO, OnDropdownClusterSizeCombo)
  262. ON_WM_CONTEXTMENU()
  263. ON_CBN_DROPDOWN(IDC_GRADIENT_COMBO, OnDropdownGradientCombo)
  264. ON_CBN_SELCHANGE(IDC_GRADIENT_COMBO, OnSelchangeGradientCombo)
  265. ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  266. //}}AFX_MSG_MAP
  267. END_MESSAGE_MAP()
  268. /////////////////////////////////////////////////////////////////////////////
  269. // CDlgPgShadow message handlers
  270. void CDlgPgShadow::InitComboBoxes(void)
  271. {
  272. CWorldEditorDoc* pDoc = theApp.GetDocument();
  273. CTString strGradientName;
  274. CTString strIlluminationName;
  275. m_ComboIllumination.ResetContent();
  276. m_ctrlComboClusterSize.ResetContent();
  277. m_comboShadowBlend.ResetContent();
  278. m_ctrlComboGradient.ResetContent();
  279. // add all available illuminations
  280. for(INDEX iIllumination=0; iIllumination<MAX_UBYTE; iIllumination++)
  281. {
  282. strIlluminationName = pDoc->m_woWorld.wo_aitIlluminationTypes[iIllumination].it_strName;
  283. if(strIlluminationName == "") break;
  284. INDEX iAddedAs = m_ComboIllumination.AddString( CString(strIlluminationName));
  285. m_ComboIllumination.SetItemData( iAddedAs, (ULONG) iIllumination);
  286. }
  287. for(INDEX iBlend=0; iBlend<256; iBlend++)
  288. {
  289. CTString strBlendName = pDoc->m_woWorld.wo_atbTextureBlendings[iBlend].tb_strName;
  290. if( strBlendName != CTString("") ) m_comboShadowBlend.AddString( CString(strBlendName));
  291. }
  292. // none must exist
  293. m_ctrlComboGradient.AddString( L"None");
  294. // add gradients
  295. if( pDoc->m_selPolygonSelection.Count() != 0)
  296. {
  297. // obtain first polygon's brush
  298. CBrush3D *pbrBrush = NULL;
  299. pDoc->m_selPolygonSelection.Lock();
  300. if( !pDoc->m_selPolygonSelection.IsMember( pDoc->m_pbpoLastCentered))
  301. {
  302. pbrBrush = pDoc->m_selPolygonSelection[0].bpo_pbscSector->bsc_pbmBrushMip->bm_pbrBrush;
  303. }
  304. pDoc->m_selPolygonSelection.Unlock();
  305. BOOL bEnableGradient = TRUE;
  306. // for each of the selected polygons
  307. FOREACHINDYNAMICCONTAINER(pDoc->m_selPolygonSelection, CBrushPolygon, itbpo)
  308. {
  309. // disable gradient combo box if all polygons are not from same brush
  310. if( pbrBrush != itbpo->bpo_pbscSector->bsc_pbmBrushMip->bm_pbrBrush)
  311. {
  312. bEnableGradient = FALSE;
  313. break;
  314. }
  315. }
  316. // if gradient combo is enabled
  317. if( bEnableGradient)
  318. {
  319. // add gradients
  320. for(INDEX iGradient=0; iGradient<MAX_UBYTE; iGradient++)
  321. {
  322. CTString strGradientName = pbrBrush->br_penEntity->GetGradientName( iGradient);
  323. if( strGradientName == "") break;
  324. m_ctrlComboGradient.AddString( CString(strGradientName));
  325. }
  326. }
  327. }
  328. // add all available shadow cluster sizes
  329. m_ctrlComboClusterSize.AddString( L"3.125 cm");
  330. m_ctrlComboClusterSize.AddString( L"6.25 cm");
  331. m_ctrlComboClusterSize.AddString( L"12.5 cm");
  332. m_ctrlComboClusterSize.AddString( L"25 cm");
  333. m_ctrlComboClusterSize.AddString( L"0.5 m");
  334. m_ctrlComboClusterSize.AddString( L"1 m");
  335. m_ctrlComboClusterSize.AddString( L"2 m");
  336. m_ctrlComboClusterSize.AddString( L"4 m");
  337. m_ctrlComboClusterSize.AddString( L"8 m");
  338. m_ctrlComboClusterSize.AddString( L"16 m");
  339. m_ctrlComboClusterSize.AddString( L"32 m");
  340. m_ctrlComboClusterSize.AddString( L"64 m");
  341. m_ctrlComboClusterSize.AddString( L"128 m");
  342. m_ctrlComboClusterSize.AddString( L"256 m");
  343. m_ctrlComboClusterSize.AddString( L"512 m");
  344. m_ctrlComboClusterSize.AddString( L"1024 m");
  345. }
  346. BOOL CDlgPgShadow::OnIdle(LONG lCount)
  347. {
  348. CWorldEditorDoc* pDoc = theApp.GetDocument();
  349. if( (pDoc == NULL) || !IsWindow(m_hWnd) )
  350. {
  351. return TRUE;
  352. }
  353. // if selections have been changed (they are not up to date)
  354. if( !pDoc->m_chSelections.IsUpToDate( m_udPolygonSelection) )
  355. {
  356. // update dialog data
  357. UpdateData( FALSE);
  358. }
  359. return TRUE;
  360. }
  361. BOOL CDlgPgShadow::PreTranslateMessage(MSG* pMsg)
  362. {
  363. if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
  364. {
  365. // move data from page to polygon
  366. UpdateData( TRUE);
  367. // the message is handled
  368. return TRUE;
  369. }
  370. return CPropertyPage::PreTranslateMessage(pMsg);
  371. }
  372. BOOL CDlgPgShadow::OnInitDialog()
  373. {
  374. EnableToolTips( TRUE);
  375. CPropertyPage::OnInitDialog();
  376. if( IsWindow( m_ComboIllumination.m_hWnd))
  377. {
  378. InitComboBoxes();
  379. }
  380. m_ctrlShadowColor.SetDialogPtr( this);
  381. m_bNoPlaneDiffusion.SetDialogPtr( this);
  382. m_bDarkCorners.SetDialogPtr( this);
  383. m_bDynamicLightsOnly.SetDialogPtr( this);
  384. m_bHasPreciseShadows.SetDialogPtr( this);
  385. m_bHasDirectionalAmbient.SetDialogPtr( this);
  386. m_bHasDirectionalShadows.SetDialogPtr( this);
  387. m_NoShadow.SetDialogPtr( this);
  388. m_IsLightBeamPassable.SetDialogPtr( this);
  389. m_bDontReceiveShadows.SetDialogPtr( this);
  390. m_bNoDynamicLights.SetDialogPtr( this);
  391. return TRUE;
  392. }
  393. void CDlgPgShadow::OnSelchangeShadowClusterSizeCombo()
  394. {
  395. // update dialog data (to reflect data change)
  396. UpdateData( TRUE);
  397. }
  398. void CDlgPgShadow::OnSelchangeIlluminationCombo()
  399. {
  400. UpdateData( TRUE);
  401. }
  402. void CDlgPgShadow::OnSelchangeShadowBlendCombo()
  403. {
  404. UpdateData( TRUE);
  405. }
  406. void CDlgPgShadow::OnSelchangeGradientCombo()
  407. {
  408. UpdateData( TRUE);
  409. }
  410. void CDlgPgShadow::OnDropdownIlluminationCombo()
  411. {
  412. m_ComboIllumination.SetDroppedWidth( 256);
  413. }
  414. void CDlgPgShadow::OnDropdownShadowBlendCombo()
  415. {
  416. m_comboShadowBlend.SetDroppedWidth( 256);
  417. }
  418. void CDlgPgShadow::OnDropdownClusterSizeCombo()
  419. {
  420. m_ctrlComboClusterSize.SetDroppedWidth( 256);
  421. }
  422. void CDlgPgShadow::OnDropdownGradientCombo()
  423. {
  424. m_ctrlComboGradient.SetDroppedWidth( 256);
  425. }
  426. void CDlgPgShadow::OnContextMenu(CWnd* pWnd, CPoint point)
  427. {
  428. CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
  429. CMenu menu;
  430. if( pDoc->GetEditingMode() == POLYGON_MODE)
  431. {
  432. if( menu.LoadMenu(IDR_INFO_POLYGON_POPUP))
  433. {
  434. CMenu* pPopup = menu.GetSubMenu(0);
  435. if( pDoc->m_selPolygonSelection.Count() != 1)
  436. {
  437. menu.EnableMenuItem(ID_SET_AS_DEFAULT, MF_DISABLED|MF_GRAYED);
  438. }
  439. pPopup->TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_LEFTALIGN,
  440. point.x, point.y, this);
  441. }
  442. }
  443. }
  444. BOOL CDlgPgShadow::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  445. {
  446. TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  447. UINT nID =pNMHDR->idFrom;
  448. if (pTTT->uFlags & TTF_IDISHWND)
  449. {
  450. // idFrom is actually the HWND of the tool
  451. nID = ::GetDlgCtrlID((HWND)nID);
  452. if(nID)
  453. {
  454. pTTT->lpszText = MAKEINTRESOURCE(nID);
  455. pTTT->hinst = AfxGetResourceHandle();
  456. return(TRUE);
  457. }
  458. }
  459. return(FALSE);
  460. }