EmitterParticlePropPage.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. // EmitterParticlePropPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "EmitterParticlePropPage.h"
  23. #include "Part_Emt.H"
  24. #include "Utils.H"
  25. #include "Vector3RndCombo.H"
  26. #include "VolumeRandomDialog.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. // EmitterParticlePropPageClass property page
  35. IMPLEMENT_DYNCREATE(EmitterParticlePropPageClass, CPropertyPage)
  36. /////////////////////////////////////////////////////////////
  37. //
  38. // EmitterParticlePropPageClass
  39. //
  40. EmitterParticlePropPageClass::EmitterParticlePropPageClass (EmitterInstanceListClass *pemitter)
  41. : m_pEmitterList (pemitter),
  42. m_bValid (true),
  43. m_Rate (0),
  44. m_BurstSize (0),
  45. m_MaxParticles (0),
  46. m_Randomizer (NULL),
  47. CPropertyPage(EmitterParticlePropPageClass::IDD)
  48. {
  49. //{{AFX_DATA_INIT(EmitterParticlePropPageClass)
  50. //}}AFX_DATA_INIT
  51. Initialize ();
  52. return ;
  53. }
  54. /////////////////////////////////////////////////////////////
  55. //
  56. // ~EmitterParticlePropPageClass
  57. //
  58. EmitterParticlePropPageClass::~EmitterParticlePropPageClass (void)
  59. {
  60. SAFE_DELETE (m_Randomizer);
  61. return;
  62. }
  63. /////////////////////////////////////////////////////////////
  64. //
  65. // DoDataExchange
  66. //
  67. void
  68. EmitterParticlePropPageClass::DoDataExchange (CDataExchange* pDX)
  69. {
  70. // Allow the base class to process this message
  71. CPropertyPage::DoDataExchange(pDX);
  72. //{{AFX_DATA_MAP(EmitterParticlePropPageClass)
  73. DDX_Control(pDX, IDC_BURST_SIZE_SPIN, m_BurstSizeSpin);
  74. DDX_Control(pDX, IDC_EMISSION_RATE_SPIN, m_EmitionRateSpin);
  75. DDX_Control(pDX, IDC_MAX_PARTICLES_SPIN, m_MaxParticlesSpin);
  76. //}}AFX_DATA_MAP
  77. return ;
  78. }
  79. BEGIN_MESSAGE_MAP(EmitterParticlePropPageClass, CPropertyPage)
  80. //{{AFX_MSG_MAP(EmitterParticlePropPageClass)
  81. ON_BN_CLICKED(IDC_SPECIFY_CREATION_VOLUME, OnSpecifyCreationVolume)
  82. ON_BN_CLICKED(IDC_MAX_PARTICLES_CHECK, OnMaxParticlesCheck)
  83. //}}AFX_MSG_MAP
  84. END_MESSAGE_MAP()
  85. /////////////////////////////////////////////////////////////
  86. //
  87. // Initialize
  88. //
  89. void
  90. EmitterParticlePropPageClass::Initialize (void)
  91. {
  92. SAFE_DELETE (m_Randomizer);
  93. if (m_pEmitterList != NULL) {
  94. //
  95. // Read the settings from the emitter
  96. //
  97. m_Rate = m_pEmitterList->Get_Emission_Rate ();
  98. m_BurstSize = m_pEmitterList->Get_Burst_Size ();
  99. m_MaxParticles = m_pEmitterList->Get_Max_Emissions ();
  100. m_Randomizer = m_pEmitterList->Get_Creation_Volume ();
  101. }
  102. return ;
  103. }
  104. /////////////////////////////////////////////////////////////
  105. //
  106. // OnInitDialog
  107. //
  108. BOOL
  109. EmitterParticlePropPageClass::OnInitDialog (void)
  110. {
  111. // Allow the base class to process this message
  112. CPropertyPage::OnInitDialog ();
  113. //
  114. // Setup the burst controls
  115. //
  116. m_BurstSizeSpin.SetRange (0, 10000);
  117. m_BurstSizeSpin.SetPos (m_BurstSize);
  118. ::Initialize_Spinner (m_EmitionRateSpin, m_Rate, -10000, 10000);
  119. //
  120. // Setup the max particles spin
  121. //
  122. m_MaxParticlesSpin.SetRange (0, 10000);
  123. m_MaxParticlesSpin.SetPos (m_MaxParticles);
  124. SendDlgItemMessage (IDC_MAX_PARTICLES_CHECK, BM_SETCHECK, WPARAM(m_MaxParticles != 0));
  125. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_MAX_PARTICLES_EDIT), m_MaxParticles != 0);
  126. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_MAX_PARTICLES_SPIN), m_MaxParticles != 0);
  127. return TRUE;
  128. }
  129. /////////////////////////////////////////////////////////////
  130. //
  131. // OnApply
  132. //
  133. BOOL
  134. EmitterParticlePropPageClass::OnApply (void)
  135. {
  136. //
  137. // Get the data from the controls
  138. //
  139. m_Rate = ::GetDlgItemFloat (m_hWnd, IDC_EMISSION_RATE_EDIT);
  140. m_BurstSize = GetDlgItemInt (IDC_BURST_SIZE_EDIT);
  141. //
  142. // Determine if we need to cap the particles or not
  143. //
  144. m_MaxParticles = 0;
  145. if (SendDlgItemMessage (IDC_MAX_PARTICLES_CHECK, BM_GETCHECK)) {
  146. m_MaxParticles = GetDlgItemInt (IDC_MAX_PARTICLES_EDIT);
  147. }
  148. //
  149. // Apply the changes to the emitter
  150. //
  151. m_pEmitterList->Set_Emission_Rate (m_Rate);
  152. m_pEmitterList->Set_Burst_Size (m_BurstSize);
  153. m_pEmitterList->Set_Max_Emissions (m_MaxParticles);
  154. m_pEmitterList->Set_Creation_Volume (m_Randomizer->Clone ());
  155. // Allow the base class to process this message
  156. return CPropertyPage::OnApply ();
  157. }
  158. /////////////////////////////////////////////////////////////
  159. //
  160. // WindowProc
  161. //
  162. LRESULT
  163. EmitterParticlePropPageClass::WindowProc
  164. (
  165. UINT message,
  166. WPARAM wParam,
  167. LPARAM lParam
  168. )
  169. {
  170. /*switch (message)
  171. {
  172. }*/
  173. // Allow the base class to process this message
  174. return CPropertyPage::WindowProc(message, wParam, lParam);
  175. }
  176. /////////////////////////////////////////////////////////////
  177. //
  178. // OnNotify
  179. //
  180. BOOL
  181. EmitterParticlePropPageClass::OnNotify
  182. (
  183. WPARAM wParam,
  184. LPARAM lParam,
  185. LRESULT *pResult
  186. )
  187. {
  188. //
  189. // Update the spinner control if necessary
  190. //
  191. NMHDR *pheader = (NMHDR *)lParam;
  192. if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) {
  193. LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam;
  194. ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta);
  195. SetModified ();
  196. }
  197. // Allow the base class to process this message
  198. return CPropertyPage::OnNotify (wParam, lParam, pResult);
  199. }
  200. /////////////////////////////////////////////////////////////
  201. //
  202. // OnSpecifyCreationVolume
  203. //
  204. /////////////////////////////////////////////////////////////
  205. void
  206. EmitterParticlePropPageClass::OnSpecifyCreationVolume (void)
  207. {
  208. VolumeRandomDialogClass dialog (m_Randomizer, this);
  209. if (dialog.DoModal () == IDOK) {
  210. //
  211. // Get the new randomizer from the dialog
  212. //
  213. SAFE_DELETE (m_Randomizer);
  214. m_Randomizer = dialog.Get_Randomizer ();
  215. SetModified ();
  216. }
  217. return ;
  218. }
  219. /////////////////////////////////////////////////////////////
  220. //
  221. // OnCommand
  222. //
  223. /////////////////////////////////////////////////////////////
  224. BOOL
  225. EmitterParticlePropPageClass::OnCommand
  226. (
  227. WPARAM wParam,
  228. LPARAM lParam
  229. )
  230. {
  231. switch (LOWORD (wParam))
  232. {
  233. case IDC_BURST_SIZE_EDIT:
  234. case IDC_EMISSION_RATE_EDIT:
  235. case IDC_MAX_PARTICLES_EDIT:
  236. if (HIWORD (wParam) == EN_CHANGE) {
  237. SetModified ();
  238. }
  239. break;
  240. }
  241. return CPropertyPage::OnCommand(wParam, lParam);
  242. }
  243. /////////////////////////////////////////////////////////////
  244. //
  245. // OnMaxParticlesCheck
  246. //
  247. /////////////////////////////////////////////////////////////
  248. void
  249. EmitterParticlePropPageClass::OnMaxParticlesCheck (void)
  250. {
  251. BOOL enable = SendDlgItemMessage (IDC_MAX_PARTICLES_CHECK, BM_GETCHECK);
  252. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_MAX_PARTICLES_EDIT), enable);
  253. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_MAX_PARTICLES_SPIN), enable);
  254. SetModified ();
  255. return ;
  256. }