ParticleEditorDialog.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. #pragma once
  19. #include <map> // for std::pair
  20. #include <string> // for std::string
  21. #include <vector> // for std::vector
  22. #include <list> // for std::list
  23. #define DEFINE_PARTICLE_SYSTEM_NAMES 1
  24. #include "Gameclient/ParticleSys.h"
  25. #include "CColorAlphaDialog.h"
  26. #include "CSwitchesDialog.h"
  27. #include "MoreParmsDialog.h"
  28. #define FORMAT_STRING "%.2f"
  29. #define NONE_STRING "(None)"
  30. struct RGBColorKeyframe;
  31. struct RandomKeyframe;
  32. interface ISwapablePanel;
  33. #define NUM_EMISSION_TYPES 5
  34. #define NUM_VELOCITY_TYPES 5
  35. #define NUM_PARTICLE_TYPES 3
  36. #define NUM_SHADER_TYPES 3
  37. enum SwitchType
  38. {
  39. ST_HOLLOW = 0,
  40. ST_ONESHOT,
  41. ST_ALIGNXY,
  42. ST_EMITABOVEGROUNDONLY,
  43. ST_PARTICLEUPTOWARDSEMITTER,
  44. };
  45. class DebugWindowDialog : public CDialog
  46. {
  47. public:
  48. enum {IDD = IDD_PSEd};
  49. DebugWindowDialog(UINT nIDTemplate = DebugWindowDialog::IDD, CWnd* pParentWnd = NULL);
  50. virtual ~DebugWindowDialog();
  51. void InitPanel( void );
  52. HWND GetMainWndHWND( void );
  53. void addParticleSystem( IN const char *particleSystem );
  54. void addThingTemplate( IN const char *thingTemplate );
  55. void clearAllParticleSystems( void );
  56. void clearAllThingTemplates( void );
  57. Bool hasSelectionChanged( void );
  58. void getSelectedSystemName( OUT char *bufferToCopyInto ) const;
  59. void getSelectedParticleAsciiStringParm( IN int parmNum, OUT char *bufferToCopyInto ) const;
  60. void updateParticleAsciiStringParm( IN int parmNum, IN const char *bufferToCopyFrom );
  61. void updateCurrentParticleCap( IN int particleCap );
  62. void updateCurrentNumParticles( IN int particleCount );
  63. int getNewParticleCap( void );
  64. void updateCurrentParticleSystem( IN ParticleSystemTemplate *particleTemplate );
  65. void updateSystemUseParameters( IN ParticleSystemTemplate *particleTemplate );
  66. void signalParticleSystemEdit( void );
  67. // The purpose of these is to add as few friends as possible to the particle system classes.
  68. // Therefore, this class has ALL the access to ParticleSystems, and dances on the data directly.
  69. // Child panels make calls here
  70. void getColorValueFromSystem( IN Int systemNum,
  71. OUT RGBColorKeyframe &colorFrame ) const;
  72. void updateColorValueToSystem( IN Int systemNum,
  73. IN const RGBColorKeyframe &colorFrame );
  74. void getAlphaRangeFromSystem( IN Int systemNum,
  75. OUT ParticleSystemInfo::RandomKeyframe &randomVar ) const;
  76. void updateAlphaRangeToSystem( IN Int systemNum,
  77. IN const ParticleSystemInfo::RandomKeyframe &randomVar );
  78. void getHalfSizeFromSystem( IN Int coordNum, // 0:X, 1:Y, 2:Z
  79. OUT Real& halfSize ) const;
  80. void updateHalfSizeToSystem( IN Int coordNum, // 0:X, 1:Y, 2:Z
  81. IN const Real &halfSize );
  82. void getSphereRadiusFromSystem( OUT Real &radius ) const;
  83. void updateSphereRadiusToSystem( IN const Real &radius );
  84. void getCylinderRadiusFromSystem( OUT Real &radius ) const;
  85. void updateCylinderRadiusToSystem( IN const Real &radius );
  86. void getCylinderLengthFromSystem( OUT Real &length ) const;
  87. void updateCylinderLengthToSystem( IN const Real &length );
  88. void getLineFromSystem( IN Int coordNum, // 0:X1, 1:Y1, 2:Z1, 3:X2, 4:Y2, 5:Z2
  89. OUT Real& linePoint ) const;
  90. void updateLineToSystem( IN Int coordNum, // 0:X, 1:Y, 2:Z, 3:X2, 4:Y2, 5:Z2
  91. IN const Real &linePoint );
  92. void getVelSphereFromSystem( IN Int velNum, // 0:min 1:max
  93. OUT Real &radius ) const;
  94. void updateVelSphereToSystem( IN Int velNum, // 0:min 1:max
  95. IN const Real &radius );
  96. void getVelHemisphereFromSystem( IN Int velNum, // 0:min 1:max
  97. OUT Real &radius ) const;
  98. void updateVelHemisphereToSystem( IN Int velNum, // 0:min 1:max
  99. IN const Real &radius );
  100. void getVelOrthoFromSystem( IN Int coordNum, // 0:Xmin, 1:Ymin, 2:Zmin, 3:Xmax, 4:Ymax, 5:Zmax
  101. OUT Real& ortho ) const;
  102. void updateVelOrthoToSystem( IN Int coordNum, // 0:Xmin, 1:Ymin, 2:Zmin, 3:Xmax, 4:Ymax, 5:Zmax
  103. IN const Real& ortho );
  104. void getVelCylinderFromSystem( IN Int coordNum, // 0:Radialmin, 1:Lengthmin, 2:Radialmax, 3:Lengthmax
  105. OUT Real& ortho ) const;
  106. void updateVelCylinderToSystem( IN Int coordNum, // 0:Radialmin, 1:Lengthmin, 2:Radialmax, 3:Lengthmax
  107. IN const Real& ortho );
  108. void getVelOutwardFromSystem( IN Int coordNum, // 0:Outwardmin, 1:Othermin, 2:Outwardmax, 3:Othermax
  109. OUT Real& ortho ) const;
  110. void updateVelOutwardToSystem( IN Int coordNum, // 0:Outwardmin, 1:Othermin, 2:Outwardmax, 3:Othermax
  111. IN const Real& ortho );
  112. void getParticleNameFromSystem( OUT char *buffer, IN int buffLen ) const;
  113. void updateParticleNameToSystem( IN const char *buffer );
  114. void getDrawableNameFromSystem( OUT char *buffer, IN int buffLen ) const;
  115. void updateDrawableNameToSystem( IN const char *buffer );
  116. void getInitialDelayFromSystem( IN Int parmNum, // 0:min, 1:min
  117. OUT Real& initialDelay ) const;
  118. void updateInitialDelayToSystem( IN Int parmNum, // 0:min, 1:min
  119. IN const Real& initialDelay );
  120. void getBurstDelayFromSystem( IN Int parmNum, // 0:min, 1:min
  121. OUT Real& burstDelay ) const;
  122. void updateBurstDelayToSystem( IN Int parmNum, // 0:min, 1:min
  123. IN const Real& burstDelay );
  124. void getBurstCountFromSystem( IN Int parmNum, // 0:min, 1:min
  125. OUT Real& burstCount ) const;
  126. void updateBurstCountToSystem( IN Int parmNum, // 0:min, 1:min
  127. IN const Real& burstCount );
  128. void getColorScaleFromSystem( IN Int parmNum, // 0:min, 1:min
  129. OUT Real& colorScale ) const;
  130. void updateColorScaleToSystem( IN Int parmNum, // 0:min, 1:min
  131. IN const Real& colorScale );
  132. void getParticleLifetimeFromSystem( IN Int parmNum, // 0:min, 1:min
  133. OUT Real& particleLifetime ) const;
  134. void updateParticleLifetimeToSystem( IN Int parmNum, // 0:min, 1:min
  135. IN const Real& particleLifetime );
  136. void getParticleSizeFromSystem( IN Int parmNum, // 0:min, 1:min
  137. OUT Real& particleSize ) const;
  138. void updateParticleSizeToSystem( IN Int parmNum, // 0:min, 1:min
  139. IN const Real& particleSize );
  140. void getStartSizeRateFromSystem( IN Int parmNum, // 0:min, 1:min
  141. OUT Real& startSizeRate ) const;
  142. void updateStartSizeRateToSystem( IN Int parmNum, // 0:min, 1:min
  143. IN const Real& startSizeRate );
  144. void getSizeRateFromSystem( IN Int parmNum, // 0:min, 1:min
  145. OUT Real& sizeRate ) const;
  146. void updateSizeRateToSystem( IN Int parmNum, // 0:min, 1:min
  147. IN const Real& sizeRate );
  148. void getSizeDampingFromSystem( IN Int parmNum, // 0:min, 1:min
  149. OUT Real& sizeDamping ) const;
  150. void updateSizeDampingToSystem( IN Int parmNum, // 0:min, 1:min
  151. IN const Real& sizeDamping );
  152. void getSystemLifetimeFromSystem( OUT Real& systemLifetime ) const;
  153. void updateSystemLifetimeToSystem( IN const Real& systemLifetime );
  154. void getSlaveOffsetFromSystem( IN Int parmNum, // 0:min, 1:min
  155. OUT Real& slaveOffset ) const;
  156. void updateSlaveOffsetToSystem( IN Int parmNum, // 0:min, 1:min
  157. IN const Real& slaveOffset );
  158. void getDriftVelocityFromSystem( IN Int parmNum, // 0:X, 1:Y, 2:Z
  159. OUT Real& driftVelocity ) const;
  160. void updateDriftVelocityToSystem( IN Int parmNum, // 0:min, 1:min
  161. IN const Real& driftVelocity );
  162. void getSwitchFromSystem( IN SwitchType switchType,
  163. OUT Bool& switchVal ) const;
  164. void updateSwitchToSystem( IN SwitchType switchType,
  165. IN const Bool& switchVal );
  166. void getSlaveSystemFromSystem( OUT char *buffer, IN Int bufferSize) const;
  167. void updateSlaveSystemToSystem( IN const char *buffer );
  168. void getPerParticleSystemFromSystem( OUT char *buffer, IN Int bufferSize) const;
  169. void updatePerParticleSystemToSystem( IN const char *buffer );
  170. void getWindMotionFromSystem( OUT ParticleSystemInfo::WindMotion& windMotion ) const;
  171. void updateWindMotionToSystem( IN const ParticleSystemInfo::WindMotion& windMotion );
  172. void getPingPongStartAngleFromSystem( IN Int parmNum, OUT Real& angle ) const;
  173. void updatePingPongStartAngleToSystem( IN Int parmNum, IN const Real& angle );
  174. void getPingPongEndAngleFromSystem( IN Int parmNum, OUT Real& angle ) const;
  175. void updatePingPongEndAngleToSystem( IN Int parmNum, IN const Real& angle );
  176. void getWindAngleChangeFromSystem( IN Int parmNum, OUT Real& angle ) const;
  177. void updateWindAngleChangeToSystem( IN Int parmNum, IN const Real& angle );
  178. Bool shouldWriteINI( void );
  179. Bool hasRequestedReload( void );
  180. Bool shouldBusyWait( void );
  181. Bool shouldUpdateParticleCap( void );
  182. Bool shouldReloadTextures( void );
  183. Bool shouldKillAllParticleSystems( void );
  184. const std::list<std::string> &getAllThingTemplates( void ) const { return m_listOfThingTemplates; }
  185. const std::list<std::string> &getAllParticleSystems( void ) const { return m_listOfParticleSystems; }
  186. ParticleSystemTemplate *getCurrentParticleSystem( void ) { return m_particleSystem; }
  187. protected:
  188. HWND mMainWndHWND;
  189. Bool m_changeHasOcurred;
  190. ParticleSystemTemplate *m_particleSystem;
  191. std::list<std::string> m_listOfThingTemplates;
  192. std::vector<std::string> m_particleParmValues;
  193. std::list<std::string> m_listOfParticleSystems;
  194. Bool m_shouldWriteINI;
  195. Bool m_showColorDlg;
  196. Bool m_showSwitchesDlg;
  197. Bool m_showMoreParmsDlg;
  198. Bool m_shouldReload;
  199. Bool m_shouldBusyWait;
  200. Bool m_shouldUpdateParticleCap;
  201. Bool m_shouldReloadTextures;
  202. Bool m_shouldKillAllParticleSystems;
  203. CColorAlphaDialog m_colorAlphaDialog;
  204. CSwitchesDialog m_switchesDialog;
  205. MoreParmsDialog m_moreParmsDialog;
  206. int m_activeEmissionPage;
  207. int m_activeVelocityPage;
  208. int m_activeParticlePage;
  209. ISwapablePanel *m_emissionTypePanels[NUM_EMISSION_TYPES];
  210. ISwapablePanel *m_velocityTypePanels[NUM_VELOCITY_TYPES];
  211. ISwapablePanel *m_particleTypePanels[NUM_PARTICLE_TYPES];
  212. void appendParticleSystemToList( IN const std::string &rString );
  213. void appendThingTemplateToList( IN const std::string &rString );
  214. // if true, updates the UI from the Particle System.
  215. // if false, updates the Particle System from the UI
  216. void performUpdate( IN Bool toUI );
  217. protected:
  218. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  219. afx_msg void OnSize(UINT nType, int cx, int cy);
  220. afx_msg void OnClose();
  221. afx_msg void OnParticleSystemChange(); // the current particle system isn't the same as the previous system
  222. afx_msg void OnParticleSystemEdit(); // this system has been edited
  223. afx_msg void OnKillAllParticleSystems(); // kill all particle systems in the world
  224. afx_msg void OnEditColorAlpha();
  225. afx_msg void OnEditMoreParms();
  226. afx_msg void OnEditSwitches();
  227. afx_msg void OnPushSave();
  228. afx_msg void OnReloadTextures();
  229. afx_msg void OnReloadSystem();
  230. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  231. afx_msg void OnReloadCurrent();
  232. afx_msg void OnReloadAll();
  233. afx_msg void OnSaveCurrent();
  234. afx_msg void OnSaveAll();
  235. afx_msg void OnParticleCapEdit();
  236. DECLARE_MESSAGE_MAP()
  237. };