EmitterColorPropPage.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. // EmitterColorPropPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "emittercolorproppage.h"
  23. #include "part_emt.h"
  24. #include "utils.h"
  25. #include "opacitysettingsdialog.h"
  26. #include "colorutils.h"
  27. #include "emitterinstancelist.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. /////////////////////////////////////////////////////////////////////////////
  34. // EmitterColorPropPageClass property page
  35. IMPLEMENT_DYNCREATE(EmitterColorPropPageClass, CPropertyPage)
  36. /////////////////////////////////////////////////////////////
  37. //
  38. // EmitterColorPropPageClass
  39. //
  40. /////////////////////////////////////////////////////////////
  41. EmitterColorPropPageClass::EmitterColorPropPageClass (EmitterInstanceListClass *pemitter)
  42. : m_pEmitterList (NULL),
  43. m_bValid (true),
  44. m_ColorBar (NULL),
  45. m_OpacityBar (NULL),
  46. m_Lifetime (0),
  47. CPropertyPage (EmitterColorPropPageClass::IDD)
  48. {
  49. ::memset (&m_OrigColors, 0, sizeof (m_OrigColors));
  50. ::memset (&m_OrigOpacities, 0, sizeof (m_OrigOpacities));
  51. ::memset (&m_CurrentColors, 0, sizeof (m_CurrentColors));
  52. ::memset (&m_CurrentOpacities, 0, sizeof (m_CurrentOpacities));
  53. //{{AFX_DATA_INIT(EmitterColorPropPageClass)
  54. //}}AFX_DATA_INIT
  55. Initialize ();
  56. return ;
  57. }
  58. /////////////////////////////////////////////////////////////
  59. //
  60. // ~EmitterColorPropPageClass
  61. //
  62. /////////////////////////////////////////////////////////////
  63. EmitterColorPropPageClass::~EmitterColorPropPageClass (void)
  64. {
  65. // Free the original setting arrays
  66. SAFE_DELETE_ARRAY (m_OrigColors.KeyTimes);
  67. SAFE_DELETE_ARRAY (m_OrigColors.Values);
  68. SAFE_DELETE_ARRAY (m_OrigOpacities.KeyTimes);
  69. SAFE_DELETE_ARRAY (m_OrigOpacities.Values);
  70. // Free the current setting arrays
  71. SAFE_DELETE_ARRAY (m_CurrentColors.KeyTimes);
  72. SAFE_DELETE_ARRAY (m_CurrentColors.Values);
  73. SAFE_DELETE_ARRAY (m_CurrentOpacities.KeyTimes);
  74. SAFE_DELETE_ARRAY (m_CurrentOpacities.Values);
  75. return;
  76. }
  77. /////////////////////////////////////////////////////////////
  78. //
  79. // DoDataExchange
  80. //
  81. /////////////////////////////////////////////////////////////
  82. void
  83. EmitterColorPropPageClass::DoDataExchange (CDataExchange* pDX)
  84. {
  85. // Allow the base class to process this message
  86. CPropertyPage::DoDataExchange(pDX);
  87. //{{AFX_DATA_MAP(EmitterColorPropPageClass)
  88. DDX_Control(pDX, IDC_OPACITY_RANDOM_SPIN, m_OpacityRandomSpin);
  89. DDX_Control(pDX, IDC_RED_RANDOM_SPIN, m_RedRandomSpin);
  90. DDX_Control(pDX, IDC_GREEN_RANDOM_SPIN, m_GreenRandomSpin);
  91. DDX_Control(pDX, IDC_BLUE_RANDOM_SPIN, m_BlueRandomSpin);
  92. //}}AFX_DATA_MAP
  93. return ;
  94. }
  95. BEGIN_MESSAGE_MAP(EmitterColorPropPageClass, CPropertyPage)
  96. //{{AFX_MSG_MAP(EmitterColorPropPageClass)
  97. ON_WM_DESTROY()
  98. ON_NOTIFY(UDN_DELTAPOS, IDC_RED_RANDOM_SPIN, OnDeltaposRedRandomSpin)
  99. //}}AFX_MSG_MAP
  100. END_MESSAGE_MAP()
  101. /////////////////////////////////////////////////////////////
  102. //
  103. // Initialize
  104. //
  105. /////////////////////////////////////////////////////////////
  106. void
  107. EmitterColorPropPageClass::Initialize (void)
  108. {
  109. SAFE_DELETE_ARRAY (m_OrigColors.KeyTimes);
  110. SAFE_DELETE_ARRAY (m_OrigColors.Values);
  111. SAFE_DELETE_ARRAY (m_OrigOpacities.KeyTimes);
  112. SAFE_DELETE_ARRAY (m_OrigOpacities.Values);
  113. SAFE_DELETE_ARRAY (m_CurrentColors.KeyTimes);
  114. SAFE_DELETE_ARRAY (m_CurrentColors.Values);
  115. SAFE_DELETE_ARRAY (m_CurrentOpacities.KeyTimes);
  116. SAFE_DELETE_ARRAY (m_CurrentOpacities.Values);
  117. if (m_pEmitterList != NULL) {
  118. m_Lifetime = m_pEmitterList->Get_Lifetime ();
  119. //
  120. // Get the initial values from the emitter
  121. //
  122. m_pEmitterList->Get_Color_Keyframes (m_OrigColors);
  123. m_pEmitterList->Get_Color_Keyframes (m_CurrentColors);
  124. m_pEmitterList->Get_Opacity_Keyframes (m_OrigOpacities);
  125. m_pEmitterList->Get_Opacity_Keyframes (m_CurrentOpacities);
  126. }
  127. return ;
  128. }
  129. /////////////////////////////////////////////////////////////
  130. //
  131. // OnInitDialog
  132. //
  133. /////////////////////////////////////////////////////////////
  134. BOOL
  135. EmitterColorPropPageClass::OnInitDialog (void)
  136. {
  137. // Allow the base class to process this message
  138. CPropertyPage::OnInitDialog ();
  139. m_ColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_COLOR_BAR));
  140. m_OpacityBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_OPACITY_BAR));
  141. //
  142. // Setup the color bars
  143. //
  144. m_ColorBar->Set_Range (0, 1);
  145. m_OpacityBar->Set_Range (0, 1);
  146. m_OpacityBar->Modify_Point (0, 0, 255, 255, 255);
  147. //
  148. // Setup the spinners
  149. //
  150. m_OpacityRandomSpin.SetRange (0, 100);
  151. m_RedRandomSpin.SetRange (0, 255);
  152. m_GreenRandomSpin.SetRange (0, 255);
  153. m_BlueRandomSpin.SetRange (0, 255);
  154. m_OpacityRandomSpin.SetPos (m_OrigOpacities.Rand * 100);
  155. m_RedRandomSpin.SetPos (m_OrigColors.Rand.X * 255);
  156. m_GreenRandomSpin.SetPos (m_OrigColors.Rand.Y * 255);
  157. m_BlueRandomSpin.SetPos (m_OrigColors.Rand.Z * 255);
  158. //
  159. // Reset the color bars
  160. //
  161. m_ColorBar->Clear_Points ();
  162. m_OpacityBar->Clear_Points ();
  163. m_ColorBar->Modify_Point (0, 0, m_OrigColors.Start.X * 255, m_OrigColors.Start.Y * 255, m_OrigColors.Start.Z * 255);
  164. m_OpacityBar->Modify_Point (0, 0, m_OrigOpacities.Start * 255, m_OrigOpacities.Start * 255, m_OrigOpacities.Start * 255);
  165. //
  166. // Setup the ranges
  167. //
  168. m_ColorBar->Set_Range (0, 1);
  169. m_OpacityBar->Set_Range (0, 1);
  170. //
  171. // Set-up the color bar
  172. //
  173. for (UINT index = 0; index < m_OrigColors.NumKeyFrames; index ++) {
  174. m_ColorBar->Modify_Point (index + 1,
  175. m_OrigColors.KeyTimes[index] / m_Lifetime,
  176. m_OrigColors.Values[index].X * 255,
  177. m_OrigColors.Values[index].Y * 255,
  178. m_OrigColors.Values[index].Z * 255);
  179. }
  180. //
  181. // Set-up the opacity bar
  182. //
  183. for (index = 0; index < m_OrigOpacities.NumKeyFrames; index ++) {
  184. m_OpacityBar->Modify_Point (index + 1,
  185. m_OrigOpacities.KeyTimes[index] / m_Lifetime,
  186. m_OrigOpacities.Values[index] * 255,
  187. m_OrigOpacities.Values[index] * 255,
  188. m_OrigOpacities.Values[index] * 255);
  189. }
  190. //
  191. // Ensure our initial 'current' values are up-to-date
  192. //
  193. m_CurrentColors.Rand = m_OrigColors.Rand;
  194. m_CurrentOpacities.Rand = m_OrigOpacities.Rand;
  195. Update_Colors ();
  196. Update_Opacities ();
  197. return TRUE;
  198. }
  199. /////////////////////////////////////////////////////////////
  200. //
  201. // OnApply
  202. //
  203. /////////////////////////////////////////////////////////////
  204. BOOL
  205. EmitterColorPropPageClass::OnApply (void)
  206. {
  207. /*SAFE_DELETE_ARRAY (m_OrigColors.KeyTimes);
  208. SAFE_DELETE_ARRAY (m_OrigColors.Values);
  209. SAFE_DELETE_ARRAY (m_OrigOpacities.KeyTimes);
  210. SAFE_DELETE_ARRAY (m_OrigOpacities.Values);
  211. //
  212. // Make the current values from the emitter the default values.
  213. //
  214. m_pEmitter->Get_Color_Key_Frames (m_OrigColors);
  215. m_pEmitter->Get_Opacity_Key_Frames (m_OrigOpacities);*/
  216. // Allow the base class to process this message
  217. return CPropertyPage::OnApply ();
  218. }
  219. /////////////////////////////////////////////////////////////
  220. //
  221. // OnDestroy
  222. //
  223. /////////////////////////////////////////////////////////////
  224. void
  225. EmitterColorPropPageClass::OnDestroy (void)
  226. {
  227. CPropertyPage::OnDestroy();
  228. return ;
  229. }
  230. /////////////////////////////////////////////////////////////
  231. //
  232. // OnNotify
  233. //
  234. /////////////////////////////////////////////////////////////
  235. BOOL
  236. EmitterColorPropPageClass::OnNotify
  237. (
  238. WPARAM wParam,
  239. LPARAM lParam,
  240. LRESULT *pResult
  241. )
  242. {
  243. CBR_NMHDR *color_bar_hdr = (CBR_NMHDR *)lParam;
  244. //
  245. // Which control sent the notification?
  246. //
  247. switch (color_bar_hdr->hdr.idFrom)
  248. {
  249. case IDC_OPACITY_BAR:
  250. {
  251. if (color_bar_hdr->hdr.code == CBRN_DBLCLK_POINT) {
  252. //
  253. // Allow the user to edit the keyframe
  254. //
  255. OpacitySettingsDialogClass dialog (color_bar_hdr->red / 255, this);
  256. if (dialog.DoModal () == IDOK) {
  257. m_OpacityBar->Modify_Point (color_bar_hdr->key_index,
  258. color_bar_hdr->position,
  259. dialog.Get_Opacity () * 255,
  260. dialog.Get_Opacity () * 255,
  261. dialog.Get_Opacity () * 255);
  262. // Update the emitter
  263. Update_Opacities ();
  264. m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities);
  265. SetModified ();
  266. }
  267. } else if ((color_bar_hdr->hdr.code == CBRN_MOVING_POINT) ||
  268. (color_bar_hdr->hdr.code == CBRN_DELETED_POINT)) {
  269. // Update the emitter
  270. Update_Opacities ();
  271. m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities);
  272. SetModified ();
  273. }
  274. }
  275. break;
  276. case IDC_COLOR_BAR:
  277. {
  278. if (color_bar_hdr->hdr.code == CBRN_DBLCLK_POINT) {
  279. //
  280. // Allow the user to edit the keyframe
  281. //
  282. int red = (int)color_bar_hdr->red;
  283. int green = (int)color_bar_hdr->green;
  284. int blue = (int)color_bar_hdr->blue;
  285. if (Show_Color_Picker (&red, &green, &blue)) {
  286. m_ColorBar->Modify_Point (color_bar_hdr->key_index,
  287. color_bar_hdr->position,
  288. red,
  289. green,
  290. blue);
  291. // Update the emitter
  292. Update_Colors ();
  293. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  294. SetModified ();
  295. }
  296. } else if ((color_bar_hdr->hdr.code == CBRN_MOVING_POINT) ||
  297. (color_bar_hdr->hdr.code == CBRN_DELETED_POINT)) {
  298. // Update the emitter
  299. Update_Colors ();
  300. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  301. SetModified ();
  302. }
  303. }
  304. break;
  305. case IDC_RED_RANDOM_SPIN:
  306. {
  307. // Update the emitter
  308. NMUPDOWN *pudnotif = (NMUPDOWN *)lParam;
  309. if (pudnotif->hdr.code == UDN_DELTAPOS) {
  310. float pos = (pudnotif->iPos + pudnotif->iDelta);
  311. m_CurrentColors.Rand.X = pos / 255.0F;
  312. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  313. SetModified ();
  314. }
  315. }
  316. break;
  317. case IDC_GREEN_RANDOM_SPIN:
  318. {
  319. // Update the emitter
  320. NMUPDOWN *pudnotif = (NMUPDOWN *)lParam;
  321. if (pudnotif->hdr.code == UDN_DELTAPOS) {
  322. float pos = (pudnotif->iPos + pudnotif->iDelta);
  323. m_CurrentColors.Rand.Y = pos / 255.0F;
  324. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  325. SetModified ();
  326. }
  327. }
  328. break;
  329. case IDC_BLUE_RANDOM_SPIN:
  330. {
  331. // Update the emitter
  332. NMUPDOWN *pudnotif = (NMUPDOWN *)lParam;
  333. if (pudnotif->hdr.code == UDN_DELTAPOS) {
  334. float pos = (pudnotif->iPos + pudnotif->iDelta);
  335. m_CurrentColors.Rand.Z = pos / 255.0F;
  336. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  337. SetModified ();
  338. }
  339. }
  340. break;
  341. case IDC_OPACITY_RANDOM_SPIN:
  342. {
  343. // Update the emitter
  344. NMUPDOWN *pudnotif = (NMUPDOWN *)lParam;
  345. if (pudnotif->hdr.code == UDN_DELTAPOS) {
  346. float pos = (pudnotif->iPos + pudnotif->iDelta);
  347. m_CurrentOpacities.Rand = pos / 100.0F;
  348. m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities);
  349. SetModified ();
  350. }
  351. }
  352. break;
  353. }
  354. return CPropertyPage::OnNotify(wParam, lParam, pResult);
  355. }
  356. /////////////////////////////////////////////////////////////
  357. //
  358. // OnCancel
  359. //
  360. /////////////////////////////////////////////////////////////
  361. void
  362. EmitterColorPropPageClass::OnCancel (void)
  363. {
  364. //
  365. // Reset the emitter to its original state
  366. //
  367. m_pEmitterList->Set_Color_Keyframes (m_OrigColors);
  368. m_pEmitterList->Set_Opacity_Keyframes (m_OrigOpacities);
  369. CPropertyPage::OnCancel ();
  370. return ;
  371. }
  372. /////////////////////////////////////////////////////////////
  373. //
  374. // Update_Opacities
  375. //
  376. /////////////////////////////////////////////////////////////
  377. void
  378. EmitterColorPropPageClass::Update_Opacities (void)
  379. {
  380. float position = 0;
  381. float red = 0;
  382. float green = 0;
  383. float blue = 0;
  384. m_OpacityBar->Get_Point (0, &position, &red, &green, &blue);
  385. //
  386. // Setup the initial or 'starting' opacity
  387. //
  388. m_CurrentOpacities.Start = red / 255;
  389. //
  390. // Free the current setting arrays
  391. //
  392. SAFE_DELETE_ARRAY (m_CurrentOpacities.KeyTimes);
  393. SAFE_DELETE_ARRAY (m_CurrentOpacities.Values);
  394. //
  395. // Determine if we need to build the array of key frames or not
  396. //
  397. int count = m_OpacityBar->Get_Point_Count ();
  398. m_CurrentOpacities.NumKeyFrames = count - 1;
  399. if (count > 1) {
  400. m_CurrentOpacities.KeyTimes = new float[count - 1];
  401. m_CurrentOpacities.Values = new float[count - 1];
  402. //
  403. // Get all the opacity key frames and add them to our structure
  404. //
  405. for (int index = 1; index < count; index ++) {
  406. m_OpacityBar->Get_Point (index, &position, &red, &green, &blue);
  407. m_CurrentOpacities.KeyTimes[index - 1] = position * m_Lifetime;
  408. m_CurrentOpacities.Values[index - 1] = red / 255;
  409. }
  410. }
  411. return ;
  412. }
  413. /////////////////////////////////////////////////////////////
  414. //
  415. // Update_Colors
  416. //
  417. /////////////////////////////////////////////////////////////
  418. void
  419. EmitterColorPropPageClass::Update_Colors (void)
  420. {
  421. float position = 0;
  422. float red = 0;
  423. float green = 0;
  424. float blue = 0;
  425. m_ColorBar->Get_Point (0, &position, &red, &green, &blue);
  426. //
  427. // Setup the initial or 'starting' color
  428. //
  429. m_CurrentColors.Start.X = red / 255;
  430. m_CurrentColors.Start.Y = green / 255;
  431. m_CurrentColors.Start.Z = blue / 255;
  432. //
  433. // Free the current setting arrays
  434. //
  435. SAFE_DELETE_ARRAY (m_CurrentColors.KeyTimes);
  436. SAFE_DELETE_ARRAY (m_CurrentColors.Values);
  437. //
  438. // Determine if we need to build the array of key frames or not
  439. //
  440. int count = m_ColorBar->Get_Point_Count ();
  441. m_CurrentColors.NumKeyFrames = count - 1;
  442. if (count > 1) {
  443. m_CurrentColors.KeyTimes = new float[count - 1];
  444. m_CurrentColors.Values = new Vector3[count - 1];
  445. //
  446. // Get all the color points and add them to our structure
  447. //
  448. for (int index = 1; index < count; index ++) {
  449. m_ColorBar->Get_Point (index, &position, &red, &green, &blue);
  450. m_CurrentColors.KeyTimes[index-1] = position * m_Lifetime;
  451. m_CurrentColors.Values[index-1].X = red / 255;
  452. m_CurrentColors.Values[index-1].Y = green / 255;
  453. m_CurrentColors.Values[index-1].Z = blue / 255;
  454. }
  455. }
  456. return ;
  457. }
  458. /////////////////////////////////////////////////////////////
  459. //
  460. // OnCommand
  461. //
  462. /////////////////////////////////////////////////////////////
  463. BOOL
  464. EmitterColorPropPageClass::OnCommand
  465. (
  466. WPARAM wParam,
  467. LPARAM lParam
  468. )
  469. {
  470. switch (LOWORD (wParam))
  471. {
  472. case IDC_RED_RANDOM_EDIT:
  473. {
  474. if (HIWORD (wParam) == EN_CHANGE) {
  475. SetModified ();
  476. }
  477. // Update the emitter
  478. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  479. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  480. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  481. m_CurrentColors.Rand.X = ((float)GetDlgItemInt (IDC_RED_RANDOM_EDIT)) / 255;
  482. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  483. SetModified ();
  484. }
  485. }
  486. break;
  487. case IDC_GREEN_RANDOM_EDIT:
  488. {
  489. if (HIWORD (wParam) == EN_CHANGE) {
  490. SetModified ();
  491. }
  492. // Update the emitter
  493. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  494. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  495. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  496. m_CurrentColors.Rand.Y = ((float)GetDlgItemInt (IDC_GREEN_RANDOM_EDIT)) / 255;
  497. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  498. SetModified ();
  499. }
  500. }
  501. break;
  502. case IDC_BLUE_RANDOM_EDIT:
  503. {
  504. if (HIWORD (wParam) == EN_CHANGE) {
  505. SetModified ();
  506. }
  507. // Update the emitter
  508. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  509. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  510. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  511. m_CurrentColors.Rand.Z = ((float)GetDlgItemInt (IDC_BLUE_RANDOM_EDIT)) / 255;
  512. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  513. SetModified ();
  514. }
  515. }
  516. break;
  517. case IDC_OPACITY_RANDOM_EDIT:
  518. {
  519. if (HIWORD (wParam) == EN_CHANGE) {
  520. SetModified ();
  521. }
  522. // Update the emitter
  523. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  524. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  525. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  526. m_CurrentOpacities.Rand = ((float)GetDlgItemInt (IDC_OPACITY_RANDOM_EDIT)) / 100;
  527. m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities);
  528. SetModified ();
  529. }
  530. }
  531. break;
  532. }
  533. return CPropertyPage::OnCommand (wParam, lParam);
  534. }
  535. void EmitterColorPropPageClass::OnDeltaposRedRandomSpin(NMHDR* pNMHDR, LRESULT* pResult)
  536. {
  537. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  538. // TODO: Add your control notification handler code here
  539. int test = 0;
  540. *pResult = 0;
  541. return ;
  542. }
  543. /////////////////////////////////////////////////////////////
  544. //
  545. // On_Lifetime_Changed
  546. //
  547. /////////////////////////////////////////////////////////////
  548. void
  549. EmitterColorPropPageClass::On_Lifetime_Changed (float lifetime)
  550. {
  551. if (m_Lifetime != lifetime) {
  552. float conversion = lifetime / m_Lifetime;
  553. //
  554. // Rescale the colors
  555. //
  556. for (UINT index = 0; index < m_CurrentColors.NumKeyFrames; index ++) {
  557. m_CurrentColors.KeyTimes[index] *= conversion;
  558. }
  559. //
  560. // Rescale the opacities
  561. //
  562. for (index = 0; index < m_CurrentOpacities.NumKeyFrames; index ++) {
  563. m_CurrentOpacities.KeyTimes[index] *= conversion;
  564. }
  565. //
  566. // Update the emitter
  567. //
  568. m_pEmitterList->Set_Color_Keyframes (m_CurrentColors);
  569. m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities);
  570. m_Lifetime = lifetime;
  571. /*if (m_hWnd != NULL) {
  572. Update_Colors ();
  573. Update_Opacities ();
  574. }*/
  575. }
  576. return ;
  577. }