doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogParticleEditor.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../../game/game.h"
33 #include "../../sys/win32/win_local.h"
34 #include "../../sys/win32/rc/common_resource.h"
35 #include "../../sys/win32/rc/Radiant_resource.h"
36 #include "../../sys/win32/rc/ParticleEditor_resource.h"
37 #include "../comafx/DialogName.h"
38 #include "../comafx/VectorCtl.h"
39 #include "../comafx/DialogColorPicker.h"
40 #include "../radiant/GLWidget.h"
41 #include "../radiant/PreviewDlg.h"
42 
43 #include "DialogParticleEditor.h"
44 
45 #ifdef ID_DEBUG_MEMORY
46 #undef new
47 #undef DEBUG_NEW
48 #define DEBUG_NEW new
49 #endif
50 
51 const int StageEnableID[] = {
114 };
115 
116 const int StageIDCount = sizeof( StageEnableID ) / sizeof ( const int );
117 
118 const int EditEnableID[] = {
128 };
129 
130 const int EditIDCount = sizeof ( EditEnableID ) / sizeof ( const int );
131 
132 
134 
135 
136 /*
137 ================
138 ParticleEditorInit
139 ================
140 */
141 void ParticleEditorInit( const idDict *spawnArgs ) {
142 
143  if ( renderSystem->IsFullScreen() ) {
144  common->Printf( "Cannot run the particle editor in fullscreen mode.\n"
145  "Set r_fullscreen to 0 and vid_restart.\n" );
146  return;
147  }
148 
149  if ( g_ParticleDialog == NULL ) {
150  InitAfx();
151  g_ParticleDialog = new CDialogParticleEditor();
152  }
153 
154  if ( g_ParticleDialog->GetSafeHwnd() == NULL) {
155  g_ParticleDialog->Create( IDD_DIALOG_PARTICLE_EDITOR );
156  /*
157  // FIXME: restore position
158  CRect rct;
159  g_AFDialog->SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE );
160  */
161  }
162 
164 
165  g_ParticleDialog->ShowWindow( SW_SHOW );
166  g_ParticleDialog->SetFocus();
167 
168  if ( spawnArgs ) {
169  idStr str = spawnArgs->GetString( "model" );
170  str.StripFileExtension();
171  g_ParticleDialog->SelectParticle( str );
172  g_ParticleDialog->SetParticleVisualization( static_cast<int>( CDialogParticleEditor::SELECTED ) );
173  }
174 
175  cvarSystem->SetCVarBool( "r_useCachedDynamicModels", false );
176 }
177 
178 
179 /*
180 ================
181 ParticleEditorRun
182 ================
183 */
184 void ParticleEditorRun( void ) {
185 #if _MSC_VER >= 1300
186  MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
187 #else
188  MSG *msg = &m_msgCur;
189 #endif
190 
191  while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
192  // pump message
193  if ( !AfxGetApp()->PumpMessage() ) {
194  }
195  }
196 }
197 
198 /*
199 ================
200 ParticleEditorShutdown
201 ================
202 */
204  delete g_ParticleDialog;
205  g_ParticleDialog = NULL;
206 }
207 
208 
209 // CDialogParticleEditor dialog
210 
211 IMPLEMENT_DYNAMIC(CDialogParticleEditor, CDialog)
213  : CDialog(CDialogParticleEditor::IDD, pParent)
214  , matName(_T(""))
215  , animFrames(_T(""))
216  , animRate(_T(""))
217  , color(_T(""))
218  , fadeColor(_T(""))
219  , fadeIn(_T(""))
220  , fadeOut(_T(""))
221  , fadeFraction(_T(""))
222  , count(_T(""))
223  , time(_T(""))
224  , timeOffset(_T(""))
225  , deadTime(_T(""))
226  , gravity(_T(""))
227  , bunching(_T(""))
228  , offset(_T(""))
229  , xSize(_T(""))
230  , ySize(_T(""))
231  , zSize(_T(""))
232  , ringOffset(_T(""))
233  , directionParm(_T(""))
234  , direction(0)
235  , orientation(0)
236  , distribution(0)
237  , viewOrigin(_T(""))
238  , speedFrom(_T(""))
239  , speedTo(_T(""))
240  , rotationFrom(_T(""))
241  , rotationTo(_T(""))
242  , sizeFrom(_T(""))
243  , sizeTo(_T(""))
244  , aspectFrom(_T(""))
245  , aspectTo(_T(""))
246  , customPath(_T(""))
247  , customParms(_T(""))
248  , trails(_T(""))
249  , trailTime(_T(""))
250  , worldGravity(TRUE)
251  , entityColor(TRUE)
252  , randomDistribution(TRUE)
253  , initialAngle(_T(""))
254  , boundsExpansion(_T(""))
255  , customDesc(_T(""))
256  , particleMode(FALSE)
257 {
258  visualization = TESTMODEL;
259  mapModified = false;
260 }
261 
263 }
264 
265 void CDialogParticleEditor::DoDataExchange(CDataExchange* pDX) {
266  CDialog::DoDataExchange(pDX);
267  DDX_Text(pDX, IDC_EDIT_DEPTHHACK, depthHack);
268  DDX_Check(pDX, IDC_CHECK_WORLDGRAVITY, worldGravity);
269  DDX_Check(pDX, IDC_CHECK_ENTITYCOLOR, entityColor);
270  DDX_Control(pDX, IDC_COMBO_PARTICLES, comboParticle);
271  DDX_Control(pDX, IDC_LIST_STAGES, listStages);
272  DDX_Text(pDX, IDC_COMBO_CUSTOMPATH, customPath );
273  DDX_Text(pDX, IDC_EDIT_CUSTOMPARMS, customParms );
274  DDX_Text(pDX, IDC_EDIT_MATERIAL, matName);
275  DDX_Text(pDX, IDC_EDIT_ANIMFRAMES, animFrames);
276  DDX_Text(pDX, IDC_EDIT_ANIMRATE, animRate);
277  DDX_Text(pDX, IDC_EDIT_COLOR, color);
278  DDX_Text(pDX, IDC_EDIT_FADECOLOR, fadeColor);
279  DDX_Text(pDX, IDC_EDIT_FADEIN, fadeIn);
280  DDX_Text(pDX, IDC_EDIT_FADEOUT, fadeOut);
281  DDX_Text(pDX, IDC_EDIT_FADEFRACTION, fadeFraction);
282  DDX_Text(pDX, IDC_EDIT_COUNT, count);
283  DDX_Text(pDX, IDC_EDIT_TIME, time);
284  DDX_Text(pDX, IDC_EDIT_TIMEOFFSET, timeOffset);
285  DDX_Text(pDX, IDC_EDIT_DEADTIME, deadTime);
286  DDX_Text(pDX, IDC_EDIT_GRAVITY, gravity);
287  DDX_Text(pDX, IDC_EDIT_BUNCHING, bunching);
288  DDX_Text(pDX, IDC_EDIT_OFFSET, offset);
289  DDX_Text(pDX, IDC_EDIT_XSIZE, xSize);
290  DDX_Text(pDX, IDC_EDIT_YSIZE, ySize);
291  DDX_Text(pDX, IDC_EDIT_ZSIZE, zSize);
292  DDX_Text(pDX, IDC_EDIT_RINGOFFSET, ringOffset);
293  DDX_Text(pDX, IDC_EDIT_CYCLES, cycles);
294  DDX_Control(pDX, IDC_STATIC_DIRPARM, staticDirectionParm);
295  DDX_Text(pDX, IDC_EDIT_DIRECTIONPARM, directionParm);
296  DDX_Text(pDX, IDC_EDIT_SPEEDFROM, speedFrom);
297  DDX_Text(pDX, IDC_EDIT_SPEEDTO, speedTo);
298  DDX_Text(pDX, IDC_EDIT_ROTATIONFROM, rotationFrom);
299  DDX_Text(pDX, IDC_EDIT_ROTATIONTO, rotationTo);
300  DDX_Text(pDX, IDC_EDIT_SIZEFROM, sizeFrom);
301  DDX_Text(pDX, IDC_EDIT_SIZETO, sizeTo);
302  DDX_Text(pDX, IDC_EDIT_ASPECTFROM, aspectFrom);
303  DDX_Text(pDX, IDC_EDIT_ASPECTTO, aspectTo);
304  DDX_Text(pDX, IDC_EDIT_ORIENTATIONPARM1, trails);
305  DDX_Text(pDX, IDC_EDIT_ORIENTATIONPARM2, trailTime);
307  DDX_Text(pDX, IDC_EDIT_INITIALANGLE, initialAngle);
309  DDX_Text(pDX, IDC_STATIC_DESC, customDesc);
310  DDX_Control(pDX, IDC_EDIT_RINGOFFSET, editRingOffset);
311  DDX_Radio(pDX, IDC_RADIO_RECT, distribution);
312  DDX_Radio(pDX, IDC_RADIO_CONE, direction);
313  DDX_Radio(pDX, IDC_RADIO_VIEW, orientation);
314  DDX_Control(pDX, IDC_SLIDER_BUNCHING, sliderBunching);
315  DDX_Control(pDX, IDC_SLIDER_FADEIN, sliderFadeIn);
316  DDX_Control(pDX, IDC_SLIDER_FADEOUT, sliderFadeOut);
317  DDX_Control(pDX, IDC_SLIDER_FADEFRACTION, sliderFadeFraction);
318  DDX_Control(pDX, IDC_SLIDER_COUNT, sliderCount);
319  DDX_Control(pDX, IDC_SLIDER_TIME, sliderTime);
320  DDX_Control(pDX, IDC_SLIDER_GRAVITY, sliderGravity);
321  DDX_Control(pDX, IDC_SLIDER_SPEEDFROM, sliderSpeedFrom);
322  DDX_Control(pDX, IDC_SLIDER_SPEEDTO, sliderSpeedTo);
323  DDX_Control(pDX, IDC_SLIDER_ROTATIONFROM, sliderRotationFrom);
324  DDX_Control(pDX, IDC_SLIDER_ROTATIONTO, sliderRotationTo);
325  DDX_Control(pDX, IDC_SLIDER_SIZEFROM, sliderSizeFrom);
326  DDX_Control(pDX, IDC_SLIDER_SIZETO, sliderSizeTo);
327  DDX_Control(pDX, IDC_SLIDER_ASPECTFROM, sliderAspectFrom);
328  DDX_Control(pDX, IDC_SLIDER_ASPECTTO, sliderAspectTo);
329  DDX_Control(pDX, IDC_BUTTON_VECTOR, vectorControl);
330 }
331 
332 
333 BEGIN_MESSAGE_MAP(CDialogParticleEditor, CDialog)
334  ON_BN_CLICKED(IDC_BUTTON_ADDSTAGE, OnBnClickedButtonAddstage)
335  ON_BN_CLICKED(IDC_BUTTON_REMOVESTAGE, OnBnClickedButtonRemovestage)
336  ON_BN_CLICKED(IDC_BUTTON_BROWSEMATERIAL, OnBnClickedButtonBrowsematerial)
337  ON_BN_CLICKED(IDC_BUTTON_BROWSECOLOR, OnBnClickedButtonBrowsecolor)
338  ON_BN_CLICKED(IDC_BUTTON_BROWSEFADECOLOR, OnBnClickedButtonBrowsefadecolor)
339  ON_BN_CLICKED(IDC_BUTTON_BROWSECOLOR_ENTITY, OnBnClickedButtonBrowseEntitycolor)
340  ON_BN_CLICKED(IDC_BUTTON_UPDATE, OnBnClickedButtonUpdate)
341  ON_CBN_SELCHANGE(IDC_COMBO_PARTICLES, OnCbnSelchangeComboParticles)
342  ON_CBN_SELCHANGE(IDC_COMBO_CUSTOMPATH, OnCbnSelchangeComboPath)
343  ON_BN_CLICKED(IDC_RADIO_RECT, OnBnClickedRadioRect)
344  ON_BN_CLICKED(IDC_RADIO_SPHERE, OnBnClickedRadioSphere)
345  ON_BN_CLICKED(IDC_RADIO_CYLINDER, OnBnClickedRadioCylinder)
346  ON_BN_CLICKED(IDC_RADIO_CONE, OnBnClickedRadioCone)
347  ON_BN_CLICKED(IDC_RADIO_OUTWARD, OnBnClickedRadioOutward)
348  ON_BN_CLICKED(IDC_RADIO_VIEW, OnBnClickedRadioView)
349  ON_BN_CLICKED(IDC_RADIO_AIMED, OnBnClickedRadioAimed)
350  ON_BN_CLICKED(IDC_RADIO_X, OnBnClickedRadioX)
351  ON_BN_CLICKED(IDC_RADIO_Y, OnBnClickedRadioY)
352  ON_BN_CLICKED(IDC_RADIO_Z, OnBnClickedRadioZ)
353  ON_BN_CLICKED(IDC_BUTTON_HIDESTAGE, OnBnClickedButtonHidestage)
354  ON_BN_CLICKED(IDC_BUTTON_SHOWSTAGE, OnBnClickedButtonShowstage)
355  ON_BN_CLICKED(IDC_CHECK_WORLDGRAVITY, OnBnClickedWorldGravity)
356  ON_BN_CLICKED(IDC_CHECK_ENTITYCOLOR, OnBnClickedEntityColor)
357  ON_LBN_SELCHANGE(IDC_LIST_STAGES, OnLbnSelchangeListStages)
358  ON_BN_CLICKED(IDC_BUTTON_NEW, OnBnClickedButtonNew)
359  ON_BN_CLICKED(IDC_BUTTON_SAVE_PARTICLE, OnBnClickedButtonSave)
360  ON_BN_CLICKED(IDC_BUTTON_SAVE_PARTICLE_AS, OnBnClickedButtonSaveAs)
361  ON_BN_CLICKED(IDC_BUTTON_SAVE_PARTICLEENTITIES, OnBnClickedButtonSaveParticles)
362  ON_BN_CLICKED(IDC_BUTTON_TESTMODEL, OnBnClickedTestModel)
363  ON_BN_CLICKED(IDC_BUTTON_IMPACT, OnBnClickedImpact)
364  ON_BN_CLICKED(IDC_BUTTON_MUZZLE, OnBnClickedMuzzle)
365  ON_BN_CLICKED(IDC_BUTTON_FLIGHT, OnBnClickedFlight)
366  ON_BN_CLICKED(IDC_BUTTON_SELECTED, OnBnClickedSelected)
367  ON_BN_CLICKED(IDC_BUTTON_DOOM, OnBnClickedDoom)
368  ON_BN_CLICKED(IDC_CHECK_EDITPARTICLEMODE, OnBnClickedParticleMode)
369  ON_BN_CLICKED(IDC_BUTTON_DROPEMITTER, OnBtnDrop)
370  ON_BN_CLICKED(IDC_BUTTON_YUP, OnBtnYup)
371  ON_BN_CLICKED(IDC_BUTTON_YDN, OnBtnYdn)
372  ON_BN_CLICKED(IDC_BUTTON_XDN, OnBtnXdn)
373  ON_BN_CLICKED(IDC_BUTTON_XUP, OnBtnXup)
374  ON_BN_CLICKED(IDC_BUTTON_ZUP, OnBtnZup)
375  ON_BN_CLICKED(IDC_BUTTON_ZDN, OnBtnZdn)
376  ON_WM_HSCROLL()
377 END_MESSAGE_MAP()
378 
379 
380 // CDialogParticleEditor message handlers
381 
382 void CDialogParticleEditor::OnBnClickedParticleMode() {
383  particleMode = !particleMode;
384  cvarSystem->SetCVarInteger( "g_editEntityMode", ( particleMode ) ? 4 : 0 );
385  EnableEditControls();
386 }
387 
388 
391  if ( idp == NULL ) {
392  return;
393  }
394  DialogName dlg("New Particle");
395  if (dlg.DoModal() == IDOK) {
396  if ( declManager->FindType( DECL_PARTICLE, dlg.m_strName, false ) ) {
397  MessageBox( "Particle already exists!", "Particle exists", MB_OK );
398  return;
399  }
400  CFileDialog dlgSave( TRUE, "prt", NULL, OFN_CREATEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() );
401  if ( dlgSave.DoModal() == IDOK ) {
402  idStr fileName;
403  fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile );
404  idDeclParticle *decl = dynamic_cast<idDeclParticle*>( declManager->CreateNewDecl( DECL_PARTICLE, dlg.m_strName, fileName ) );
405  if ( decl ) {
406  decl->stages.DeleteContents( true );
407  decl->depthHack = idp->depthHack;
408  for ( int i = 0; i < idp->stages.Num(); i++ ) {
409  idParticleStage *stage = new idParticleStage();
410  *stage = *idp->stages[i];
411  decl->stages.Append( stage );
412  }
413  EnumParticles();
414  int index = comboParticle.FindStringExact( -1, dlg.m_strName );
415  if ( index >= 0 ) {
416  comboParticle.SetCurSel( index );
417  }
421  }
422  }
423  }
424 }
425 
426 
428  cmdSystem->BufferCommandText( CMD_EXEC_NOW, "saveParticles" );
429  CWnd *wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
430  if ( wnd ) {
431  wnd->EnableWindow( FALSE );
432  }
433 }
434 
436  AddStage();
437 }
438 
440  RemoveStage();
441 }
442 
444  CPreviewDlg matDlg( this );
445  matDlg.SetMode(CPreviewDlg::MATERIALS, "particles" );
446  matDlg.SetDisablePreview( true );
447  if ( matDlg.DoModal() == IDOK ) {
448  matName = matDlg.mediaName;
451  }
452 }
453 
455  int r, g, b;
456  float ob;
458  if ( ps == NULL ) {
459  return;
460  }
461  r = ps->color.x * 255.0f;
462  g = ps->color.y * 255.0f;
463  b = ps->color.z * 255.0f;
464  ob = 1.0f;
465  if ( DoNewColor( &r, &g, &b, &ob ) ) {
466  color.Format( "%f %f %f %f", (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0f );
469  }
470 }
471 
473  int r, g, b;
474  float ob;
475  idList<idEntity*> list;
476  idDict dict2;
477  idStr str;
478  list.SetNum( 128 );
479  int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
480  list.SetNum( count );
481 
482  if ( count ) {
483  const idDict *dict = gameEdit->EntityGetSpawnArgs( list[0] );
484  if ( dict ) {
485  idVec3 clr = dict->GetVector( "_color", "1 1 1" );
486  r = clr.x * 255.0f;
487  g = clr.y * 255.0f;
488  b = clr.z * 255.0f;
489  ob = 1.0f;
490  if ( DoNewColor( &r, &g, &b, &ob ) ) {
491  for ( int i = 0; i < count; i++ ) {
492  dict = gameEdit->EntityGetSpawnArgs( list[i] );
493  const char *name = dict->GetString( "name" );
494  idEntity *ent = gameEdit->FindEntity( name );
495  if ( ent ) {
496  gameEdit->EntitySetColor( ent, idVec3( (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f ) );
497  str = va( "%f %f %f", (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f );
498  dict2.Clear();
499  dict2.Set( "_color", str );
500  gameEdit->EntityChangeSpawnArgs( ent, &dict2 );
501  gameEdit->MapSetEntityKeyVal( name, "_color", str );
502  }
503  }
504  }
505  }
506  CWnd *wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
507  if ( wnd ) {
508  wnd->EnableWindow( TRUE );
509  }
510  }
511 
512 }
513 
515  int r, g, b;
516  float ob;
518  if ( ps == NULL ) {
519  return;
520  }
521  r = ps->fadeColor.x * 255.0f;
522  g = ps->fadeColor.y * 255.0f;
523  b = ps->fadeColor.z * 255.0f;
524  ob = 1.0f;
525  if ( DoNewColor( &r, &g, &b, &ob ) ) {
526  fadeColor.Format( "%f %f %f %f", (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0f );
529  }
530 }
531 
533  UpdateData( TRUE );
536 }
537 
539  int index = comboParticle.FindString( 0, name );
540  if ( index >= 0 ) {
541  comboParticle.SetCurSel( index );
543  }
544 }
545 
547  int sel = comboParticle.GetCurSel();
548  if ( sel == CB_ERR ) {
549  return NULL;
550  }
551  int index = comboParticle.GetItemData( sel );
552  return static_cast<idDeclParticle *>( const_cast<idDecl *>( declManager->DeclByIndex( DECL_PARTICLE, index ) ) );
553 }
554 
556 
557  listStages.ResetContent();
559  if ( idp == NULL ) {
560  return;
561  }
562  for ( int i = 0; i < idp->stages.Num(); i++ ) {
563  int index = listStages.AddString( va( "stage %i", i ) );
564  if ( index >= 0 ) {
565  listStages.SetItemData( index, i );
566  }
567  }
568  listStages.SetCurSel( 0 );
570  CWnd *wnd = GetDlgItem( IDC_STATIC_INFILE );
571  if ( wnd ) {
572  wnd->SetWindowText( va( "Particle file: %s", idp->GetFileName() ) );
573  }
574 
575  SetParticleView();
576 }
577 
580 }
581 
582 
587 }
588 
590  CWnd *wnd = GetDlgItem( IDC_EDIT_RINGOFFSET );
591  if ( wnd ) {
592  wnd->EnableWindow( distribution == 2 );
593  }
594  wnd = GetDlgItem( IDC_STATIC_DIRPARM );
595  if ( wnd ) {
596  wnd->SetWindowText( (direction == 0 ) ? "Angle" : "Upward Bias" );
597  }
598  wnd = GetDlgItem( IDC_EDIT_ORIENTATIONPARM1 );
599  if ( wnd ) {
600  wnd->EnableWindow( orientation == 1 );
601  }
602  wnd = GetDlgItem( IDC_EDIT_ORIENTATIONPARM2 );
603  if ( wnd ) {
604  wnd->EnableWindow( orientation == 1 );
605  }
606 
608  if ( ps == NULL ) {
609  return;
610  }
626 }
627 
629  distribution = 0;
633 }
634 
636  distribution = 2;
640 }
641 
643  distribution = 1;
647 }
648 
650  direction = 0;
654 }
655 
657  direction = 1;
661 }
662 
664  orientation = 0;
668 }
669 
671  orientation = 1;
675 }
676 
678  orientation = 2;
682 }
683 
685  orientation = 3;
689 }
690 
692  orientation = 4;
696 }
697 
699  ::SetFocus(win32.hWnd);
700 }
701 
702 
705  SetParticleView();
706 }
707 
710  SetParticleView();
711 }
712 
715  SetParticleView();
716 }
717 
720  SetParticleView();
721 }
722 
725  SetParticleView();
726 }
727 
729  visualization = i;
730  SetParticleView();
731 }
732 
735  if ( idp == NULL ) {
736  return;
737  }
738  cmdSystem->BufferCommandText( CMD_EXEC_NOW, "testmodel" );
739  idStr str;
740  switch ( visualization ) {
741  case TESTMODEL :
742  str = idp->GetName();
743  str.SetFileExtension( ".prt" );
744  cmdSystem->BufferCommandText( CMD_EXEC_NOW, va("testmodel %s\n", str.c_str() ) );
745  break;
746  case IMPACT :
747  str = idp->GetName();
748  str.SetFileExtension( ".prt" );
749  cvarSystem->SetCVarInteger( "g_testParticle", TEST_PARTICLE_IMPACT );
750  cvarSystem->SetCVarString( "g_testParticleName", str );
751  break;
752  case MUZZLE :
753  str = idp->GetName();
754  str.SetFileExtension( ".prt" );
755  cvarSystem->SetCVarInteger( "g_testParticle", TEST_PARTICLE_MUZZLE );
756  cvarSystem->SetCVarString( "g_testParticleName", str );
757  break;
758  case FLIGHT :
759  str = idp->GetName();
760  str.SetFileExtension( ".prt" );
761  cvarSystem->SetCVarInteger( "g_testParticle", TEST_PARTICLE_FLIGHT );
762  cvarSystem->SetCVarString( "g_testParticleName", str );
763  break;
764  case SELECTED :
765  str = idp->GetName();
766  str.SetFileExtension( ".prt" );
767  cvarSystem->SetCVarInteger( "g_testParticle", TEST_PARTICLE_FLIGHT );
768  SetSelectedModel( str );
769  break;
770  }
771 }
772 
774  idList<idEntity*> list;
775  idMat3 axis;
776 
777  list.SetNum( 128 );
778  int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
779  list.SetNum( count );
780 
781  if ( count ) {
782  for ( int i = 0; i < count; i++ ) {
783  const idDict *dict = gameEdit->EntityGetSpawnArgs( list[i] );
784  if ( dict == NULL ) {
785  continue;
786  }
787  const char *name = dict->GetString( "name" );
788  gameEdit->EntitySetModel( list[i], val );
789  gameEdit->EntityUpdateVisuals( list[i] );
790  gameEdit->EntityGetAxis( list[i], axis );
791  vectorControl.SetidAxis( axis );
792  gameEdit->MapSetEntityKeyVal( name, "model", val );
793  }
794  CWnd *wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
795  if ( wnd ) {
796  wnd->EnableWindow( TRUE );
797  }
798  }
799 }
800 
801 
803  HideStage();
804 }
805 
807  ShowStage();
808 }
809 
810 
815 }
816 
821 }
822 
823 
825 
827  if ( idp == NULL ) {
828  return;
829  }
830 
831  idParticleStage *stage = new idParticleStage;
832 
833  if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
835  if ( source == NULL ) {
836  delete stage;
837  return;
838  }
839  *stage = *source;
840  } else {
841  stage->Default();
842  }
843  int newIndex = idp->stages.Append( stage );
844  int index = listStages.AddString( va( "stage %i", newIndex ) );
845  listStages.SetCurSel( index );
846  listStages.SetItemData( index, newIndex );
849 }
850 
853  if ( idp == NULL ) {
854  return;
855  }
856 
857  if ( MessageBox( "Are you sure you want to remove this stage?", "Remove Stage", MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
858  return;
859  }
860 
861  int index = listStages.GetCurSel();
862  if ( index >= 0 ) {
863  int newIndex = listStages.GetItemData( index );
864  if ( newIndex >= 0 && newIndex < idp->stages.Num() ) {
865  idp->stages.RemoveIndex( newIndex );
866  index += ( index >= 1 ) ? -1 : 1;
867  newIndex = comboParticle.FindStringExact( -1, idp->GetName() );
868  EnumParticles();
869  if ( newIndex >= 0 ) {
870  comboParticle.SetCurSel( newIndex );
871  }
873  listStages.SetCurSel( index );
875  }
876  }
878 }
879 
882  if ( ps == NULL ) {
883  return;
884  }
885  ps->hidden = false;
886  int index = listStages.GetCurSel();
887  int newIndex = listStages.GetItemData( index );
888  listStages.DeleteString ( index );
889  listStages.InsertString( index, va("stage %i", index ) );
890  listStages.SetItemData( index, newIndex );
891  listStages.SetCurSel( index );
893 }
894 
897  if ( ps == NULL ) {
898  return;
899  }
900  ps->hidden = true;
901  int index = listStages.GetCurSel();
902  int newIndex = listStages.GetItemData( index );
903  listStages.DeleteString ( index );
904  listStages.InsertString( index, va("stage %i (H) ", index ) );
905  listStages.SetItemData( index, newIndex );
906  listStages.SetCurSel( index );
908 }
909 
912  int sel = listStages.GetCurSel();
913  int index = listStages.GetItemData( sel );
914  if ( idp == NULL || sel == LB_ERR || index >= idp->stages.Num() ) {
915  return NULL;
916  }
917  return idp->stages[index];
918 }
919 
921  matName = "";
922  animFrames = "";
923  animRate = "";
924  color = "";
925  fadeColor = "";
926  fadeIn = "";
927  fadeOut = "";
928  fadeFraction = "";
929  count = "";
930  time = "";
931  timeOffset = "";
932  deadTime = "";
933  gravity = "";
934  bunching = "";
935  offset = "";
936  xSize = "";
937  ySize = "";
938  zSize = "";
939  ringOffset = "";
940  directionParm = "";
941  direction = 1;
942  orientation = 1;
943  distribution = 1;
944  speedFrom = "";
945  speedTo = "";
946  rotationFrom = "";
947  rotationTo = "";
948  sizeFrom = "";
949  sizeTo = "";
950  aspectFrom = "";
951  aspectTo = "";
952  customPath = "";
953  customParms = "";
954  trails = "";
955  trailTime = "";
957  entityColor = FALSE;
959  initialAngle = "";
960  customDesc = "";
961  UpdateData( FALSE );
962 }
963 
965 
966  // go ahead and get the two system vars too
968  if ( idp == NULL ) {
969  return;
970  }
971 
972  depthHack = va( "%.3f", idp->depthHack );
973 
975  if ( ps == NULL ) {
976  return;
977  }
978  matName = ps->material->GetName();
979  animFrames = va( "%i", ps->animationFrames );
980  animRate = va( "%i", ps->animationRate );
981  color = ps->color.ToString();
982  fadeColor = ps->fadeColor.ToString();
983  fadeIn = va( "%.3f", ps->fadeInFraction );
984  fadeOut = va( "%.3f", ps->fadeOutFraction );
985  fadeFraction = va( "%.3f", ps->fadeIndexFraction );
986  count = va( "%i", ps->totalParticles );
987  time = va( "%.3f", ps->particleLife );
988  timeOffset = va( "%.3f", ps->timeOffset );
989  deadTime = va( "%.3f", ps->deadTime );
990  gravity = va( "%.3f", ps->gravity );
991  bunching = va( "%.3f", ps->spawnBunching );
992  offset = ps->offset.ToString( 0 );
993  xSize = va( "%.3f", ps->distributionParms[0] );
994  ySize = va( "%.3f", ps->distributionParms[1] );
995  zSize = va( "%.3f", ps->distributionParms[2] );
996  ringOffset = va( "%.3f", ps->distributionParms[3] );
997  directionParm = va( "%.3f", ps->directionParms[0] );
998  direction = ps->directionType;
999  orientation = ps->orientation;
1001  speedFrom = va( "%.3f", ps->speed.from );
1002  speedTo = va( "%.3f", ps->speed.to );
1003  rotationFrom = va( "%.3f", ps->rotationSpeed.from );
1004  rotationTo = va( "%.3f", ps->rotationSpeed.to );
1005  sizeFrom = va( "%.3f", ps->size.from );
1006  sizeTo = va( "%.3f", ps->size.to );
1007  aspectFrom = va( "%.3f", ps->aspect.from );
1008  aspectTo = va( "%.3f", ps->aspect.to );
1009  trails = va( "%f", ps->orientationParms[0] );
1010  trailTime = va( "%.3f", ps->orientationParms[1] );
1011  cycles = va( "%.3f", ps->cycles );
1012  customPath = ps->GetCustomPathName();
1013  customParms = "";
1014  customDesc = ps->GetCustomPathDesc();
1015  if ( ps->customPathType != PPATH_STANDARD ) {
1016  for ( int i = 0; i < ps->NumCustomPathParms(); i++ ) {
1017  customParms += va( "%.1f ", ps->customPathParms[i] );
1018  }
1019  }
1020  worldGravity = ps->worldGravity;
1021  initialAngle = va( "%.3f", ps->initialAngle );
1022  boundsExpansion = va( "%.3f", ps->boundsExpansion );
1024  entityColor = ps->entityColor;
1025  UpdateData( FALSE );
1026 }
1027 
1029 
1030  // go ahead and set the two system vars too
1031  idDeclParticle *idp = GetCurParticle();
1032  if ( idp == NULL ) {
1033  return;
1034  }
1035  idp->depthHack = atof( depthHack );
1036 
1037  idParticleStage *ps = GetCurStage();
1038  if ( ps == NULL ) {
1039  return;
1040  }
1042  ps->animationFrames = atoi( animFrames );
1043  ps->animationRate = atoi( animRate );
1044  sscanf( color, "%f %f %f %f", &ps->color.x, &ps->color.y, &ps->color.z, &ps->color.w );
1045  sscanf( fadeColor, "%f %f %f %f", &ps->fadeColor.x, &ps->fadeColor.y, &ps->fadeColor.z, &ps->fadeColor.w );
1046  ps->fadeInFraction = atof( fadeIn );
1047  ps->fadeOutFraction = atof( fadeOut );
1048  ps->fadeIndexFraction = atof( fadeFraction );
1049  ps->totalParticles = atoi( count );
1050  ps->particleLife = atof( time );
1051  ps->timeOffset = atof( timeOffset );
1052  ps->deadTime = atof( deadTime );
1053  ps->gravity = atof( gravity );
1054  ps->spawnBunching = atof( bunching );
1055  sscanf( offset, "%f %f %f", &ps->offset.x, &ps->offset.y, &ps->offset.z );
1056  ps->distributionParms[0] = atof( xSize );
1057  ps->distributionParms[1] = atof( ySize );
1058  ps->distributionParms[2] = atof( zSize );
1059  ps->distributionParms[3] = atof( ringOffset );
1060  ps->directionParms[0] = atof( directionParm );
1061  ps->directionType = static_cast<prtDirection_t>( direction );
1062  ps->orientation = static_cast<prtOrientation_t>( orientation );
1063  ps->distributionType = static_cast<prtDistribution_t>( distribution );
1064  ps->speed.from = atof( speedFrom );
1065  ps->speed.to = atof( speedTo );
1066  ps->rotationSpeed.from = atof( rotationFrom );
1067  ps->rotationSpeed.to = atof( rotationTo );
1068  ps->size.from = atof( sizeFrom );
1069  ps->size.to = atof( sizeTo );
1070  ps->aspect.from = atof( aspectFrom );
1071  ps->aspect.to = atof( aspectTo );
1072  ps->orientationParms[0] = atof( trails );
1073  ps->orientationParms[1] = atof( trailTime );
1074  ps->worldGravity = ( worldGravity == TRUE );
1075  ps->cycles = atof( cycles );
1076  ps->cycleMsec = ( ps->particleLife + ps->deadTime ) * 1000;
1077 
1078  sscanf( customParms, "%f %f %f %f %f %f %f %f", &ps->customPathParms[0], &ps->customPathParms[1], &ps->customPathParms[2],
1079  &ps->customPathParms[3], &ps->customPathParms[4], &ps->customPathParms[5],
1080  &ps->customPathParms[6], &ps->customPathParms[7] );
1081 
1083 
1084  ps->initialAngle = atof( initialAngle );
1085  ps->boundsExpansion = atof( boundsExpansion );
1087  ps->entityColor = ( entityColor == TRUE );
1088 
1089 }
1090 
1092  ClearDlgVars();
1093  idParticleStage *ps = GetCurStage();
1094  if ( ps == NULL ) {
1095  return;
1096  }
1099 }
1100 
1102  ShowCurrentStage();
1104 }
1105 
1107  DialogName dlg("New Particle");
1108  if (dlg.DoModal() == IDOK) {
1109  CFileDialog dlgSave( TRUE, "prt", NULL, OFN_CREATEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() );
1110  if ( dlgSave.DoModal() == IDOK ) {
1111  if ( declManager->FindType( DECL_PARTICLE, dlg.m_strName, false ) ) {
1112  MessageBox( "Particle already exists!", "Particle exists", MB_OK );
1113  return;
1114  }
1115  idStr fileName;
1116  fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile );
1117  idDecl *decl = declManager->CreateNewDecl( DECL_PARTICLE, dlg.m_strName, fileName );
1118  if ( decl ) {
1119  if ( MessageBox( "Copy current particle?", "Copy current", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
1120  MessageBox( "Copy current particle not implemented yet.. Stay tuned" );
1121  }
1122  EnumParticles();
1123  int index = comboParticle.FindStringExact( -1, dlg.m_strName );
1124  if ( index >= 0 ) {
1125  comboParticle.SetCurSel( index );
1126  }
1129  }
1130  }
1131  }
1132 }
1133 
1135  idDeclParticle *idp = GetCurParticle();
1136  if ( idp == NULL ) {
1137  return;
1138  }
1139 
1140  if ( strstr( idp->GetFileName(), "implicit" ) ) {
1141  // defaulted, need to choose a file
1142  CFileDialog dlgSave( FALSE, "prt", NULL, OFN_OVERWRITEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() );
1143  if ( dlgSave.DoModal() == IDOK ) {
1144  idStr fileName;
1145  fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile );
1146  idp->Save( fileName );
1147  EnumParticles();
1148  }
1149  } else {
1150  idp->Save();
1151  }
1152 
1153 }
1154 
1156  CWaitCursor cursor;
1157  comboParticle.ResetContent();
1158  for ( int i = 0; i < declManager->GetNumDecls( DECL_PARTICLE ); i++ ) {
1159  const idDecl *idp = declManager->DeclByIndex( DECL_PARTICLE, i );
1160  int index = comboParticle.AddString( idp->GetName() );
1161  if ( index >= 0 ) {
1162  comboParticle.SetItemData( index, i );
1163  }
1164  }
1165  comboParticle.SetCurSel( 0 );
1167 }
1168 
1171  return CDialog::OnDestroy();
1172 }
1173 
1174 void VectorCallBack( idQuat rotation ) {
1175  if ( g_ParticleDialog && g_ParticleDialog->GetSafeHwnd() ) {
1176  g_ParticleDialog->SetVectorControlUpdate( rotation );
1177  }
1178 }
1179 
1181  if ( particleMode ) {
1182  idList<idEntity*> list;
1183 
1184  list.SetNum( 128 );
1185  int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
1186  list.SetNum( count );
1187 
1188  if ( count ) {
1189  for ( int i = 0; i < count; i++ ) {
1190  const idDict *dict = gameEdit->EntityGetSpawnArgs( list[i] );
1191  if ( dict == NULL ) {
1192  continue;
1193  }
1194  const char *name = dict->GetString( "name" );
1195  gameEdit->EntitySetAxis( list[i], rotation.ToMat3() );
1196  gameEdit->EntityUpdateVisuals( list[i] );
1197  gameEdit->MapSetEntityKeyVal( name, "rotation", rotation.ToMat3().ToString() );
1198  }
1199  CWnd *wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
1200  if ( wnd ) {
1201  wnd->EnableWindow( TRUE );
1202  }
1203  }
1204  }
1205 }
1206 
1208 
1210 
1211  particleMode = ( cvarSystem->GetCVarInteger( "g_editEntityMode" ) == 4 );
1212  mapModified = false;
1213 
1214  CDialog::OnInitDialog();
1215 
1216  sliderBunching.SetRange( 0, 20 );
1217  sliderBunching.SetValueRange( 0.0f, 1.0f );
1218  sliderFadeIn.SetRange( 0, 20 );
1219  sliderFadeIn.SetValueRange( 0.0f, 1.0f );
1220  sliderFadeOut.SetRange( 0, 20 );
1221  sliderFadeOut.SetValueRange( 0.0f, 1.0f );
1222  sliderCount.SetRange( 0, 1024 );
1223  sliderCount.SetValueRange( 0, 4096 );
1224  sliderTime.SetRange( 0, 200 );
1225  sliderTime.SetValueRange( 0.0f, 10.0f );
1226  sliderGravity.SetRange( 0, 600 );
1227  sliderGravity.SetValueRange( -300.0f, 300.0f );
1228  sliderSpeedFrom.SetRange( 0, 600 );
1229  sliderSpeedFrom.SetValueRange( -300.0f, 300.0f );
1230  sliderSpeedTo.SetRange( 0, 600 );
1231  sliderSpeedTo.SetValueRange( -300.0f, 300.0f );
1232  sliderRotationFrom.SetRange( 0, 100 );
1233  sliderRotationFrom.SetValueRange( 0.0f, 100.0f );
1234  sliderRotationTo.SetRange( 0, 100 );
1235  sliderRotationTo.SetValueRange( 0.0f, 100.0f );
1236  sliderSizeFrom.SetRange( 0, 256 );
1237  sliderSizeFrom.SetValueRange( 0.0f, 128.0f );
1238  sliderSizeTo.SetRange( 0, 256 );
1239  sliderSizeTo.SetValueRange( 0.0f, 128.0f );
1240  sliderAspectFrom.SetRange( 0, 256 );
1241  sliderAspectFrom.SetValueRange( 0.0f, 128.0f );
1242  sliderAspectTo.SetRange( 0, 256 );
1243  sliderAspectTo.SetValueRange( 0.0f, 128.0f );
1244  sliderFadeFraction.SetRange( 0, 20 );
1245  sliderFadeFraction.SetValueRange( 0.0f, 1.0f );
1246 
1247  EnumParticles();
1248  SetParticleView();
1249 
1250  toolTipCtrl.Create( this );
1251  toolTipCtrl.Activate( TRUE );
1252 
1253  CWnd* wnd = GetWindow( GW_CHILD );
1254  CString str;
1255  while ( wnd ) {
1256  if ( str.LoadString( wnd->GetDlgCtrlID() ) ) {
1257  toolTipCtrl.AddTool( wnd, str );
1258  }
1259  wnd = wnd->GetWindow( GW_HWNDNEXT );
1260  }
1261 
1262  wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
1263  if ( wnd ) {
1264  wnd->EnableWindow( FALSE );
1265  }
1267 
1269 
1270  return TRUE; // return TRUE unless you set the focus to a control
1271  // EXCEPTION: OCX Property Pages should return FALSE
1272 }
1273 
1274 void CDialogParticleEditor::OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar ) {
1275  CDialog::OnHScroll( nSBCode, nPos, pScrollBar );
1276  CSliderCtrl *ctrl = dynamic_cast< CSliderCtrl* >( pScrollBar );
1277  if ( !ctrl ) {
1278  return;
1279  }
1280  if ( ctrl == &sliderBunching ) {
1281  // handle bunching
1282  bunching = va( "%.3f", sliderBunching.GetValue() );
1285  } else if ( ctrl == &sliderFadeIn ) {
1286  fadeIn = va( "%.3f", sliderFadeIn.GetValue() );
1289  } else if ( ctrl == &sliderFadeOut ) {
1290  fadeOut = va( "%.3f", sliderFadeOut.GetValue() );
1293  } else if ( ctrl == &sliderFadeFraction ) {
1294  fadeFraction = va( "%.3f", sliderFadeFraction.GetValue() );
1297  } else if ( ctrl == &sliderCount ) {
1298  count = va( "%i", (int)sliderCount.GetValue() );
1301  } else if ( ctrl == &sliderTime ) {
1302  time = va( "%.3f", sliderTime.GetValue() );
1305  } else if ( ctrl == &sliderGravity ) {
1306  gravity = va( "%.3f", sliderGravity.GetValue() );
1309  } else if ( ctrl == &sliderSpeedFrom ) {
1310  speedFrom = va( "%.3f", sliderSpeedFrom.GetValue() );
1313  } else if ( ctrl == &sliderSpeedTo ) {
1314  speedTo = va( "%.3f", sliderSpeedTo.GetValue() );
1317  } else if ( ctrl == &sliderRotationFrom ) {
1318  rotationFrom = va( "%.3f", sliderRotationFrom.GetValue() );
1321  } else if ( ctrl == &sliderRotationTo ) {
1322  rotationTo = va( "%.3f", sliderRotationTo.GetValue() );
1325  } else if ( ctrl == &sliderSizeFrom ) {
1326  sizeFrom = va( "%.3f", sliderSizeFrom.GetValue() );
1329  } else if ( ctrl == &sliderSizeTo ) {
1330  sizeTo = va( "%.3f", sliderSizeTo.GetValue() );
1333  } else if ( ctrl == &sliderAspectFrom ) {
1334  aspectFrom = va( "%.3f", sliderAspectFrom.GetValue() );
1337  } else if ( ctrl == &sliderAspectTo ) {
1338  aspectTo = va( "%.3f", sliderAspectTo.GetValue() );
1341  }
1342 }
1343 
1344 
1346  if ( pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST ) {
1347  toolTipCtrl.RelayEvent( pMsg );
1348  }
1349  return CDialog::PreTranslateMessage(pMsg);
1350 }
1351 
1353  idParticleStage *stage = GetCurStage();
1354  bool b = ( stage && stage->hidden ) ? false : true;
1355  for ( int i = 0; i < StageIDCount; i++ ) {
1356  CWnd *wnd = GetDlgItem( StageEnableID[ i ] );
1357  if ( wnd ) {
1358  wnd->EnableWindow( b );
1359  }
1360  }
1361 }
1362 
1364  for ( int i = 0; i < EditIDCount; i++ ) {
1365  CWnd *wnd = GetDlgItem( EditEnableID[ i ] );
1366  if ( wnd ) {
1367  wnd->EnableWindow( particleMode );
1368  }
1369  }
1370 }
1371 
1372 void CDialogParticleEditor::UpdateSelectedOrigin( float x, float y, float z ) {
1373  idList<idEntity*> list;
1374  idVec3 origin;
1375  idVec3 vec(x, y, z);
1376 
1377  list.SetNum( 128 );
1378  int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
1379  list.SetNum( count );
1380 
1381  if ( count ) {
1382  for ( int i = 0; i < count; i++ ) {
1383  const idDict *dict = gameEdit->EntityGetSpawnArgs( list[i] );
1384  if ( dict == NULL ) {
1385  continue;
1386  }
1387  const char *name = dict->GetString( "name" );
1388  gameEdit->EntityTranslate( list[i], vec );
1389  gameEdit->EntityUpdateVisuals( list[i] );
1390  gameEdit->MapEntityTranslate( name, vec );
1391  }
1392  CWnd *wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
1393  if ( wnd ) {
1394  wnd->EnableWindow( TRUE );
1395  }
1396  }
1397 }
1398 
1400 {
1401  UpdateSelectedOrigin(0, 8, 0);
1402 }
1403 
1405 {
1406  UpdateSelectedOrigin(0, -8, 0);
1407 }
1408 
1410 {
1411  UpdateSelectedOrigin(-8, 0, 0);
1412 }
1413 
1415 {
1416  UpdateSelectedOrigin(8, 0, 0);
1417 }
1418 
1420 {
1421  UpdateSelectedOrigin(0, 0, 8);
1422 }
1423 
1425 {
1426  UpdateSelectedOrigin(0, 0, -8);
1427 }
1428 
1430 {
1431  idStr classname;
1432  idStr key;
1433  idStr value;
1434  idVec3 org;
1435  idDict args;
1436  idAngles viewAngles;
1437 
1438  if ( !gameEdit->PlayerIsValid() ) {
1439  return;
1440  }
1441 
1442  gameEdit->PlayerGetViewAngles( viewAngles );
1444 
1445  org += idAngles( 0, viewAngles.yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 );
1446  args.Set("origin", org.ToString());
1447  args.Set("classname", "func_emitter");
1448  args.Set("angle", va( "%f", viewAngles.yaw + 180 ));
1449 
1450  idDeclParticle *idp = GetCurParticle();
1451  if ( idp == NULL ) {
1452  return;
1453  }
1454  idStr str = idp->GetName();
1455  str.SetFileExtension( ".prt" );
1456 
1457  args.Set("model", str);
1458 
1459  idStr name = gameEdit->GetUniqueEntityName( "func_emitter" );
1460  bool nameValid = false;
1461  while (!nameValid) {
1462  DialogName dlg("Name Particle", this);
1463  dlg.m_strName = name;
1464  if (dlg.DoModal() == IDOK) {
1465  idEntity *gameEnt = gameEdit->FindEntity( dlg.m_strName );
1466  if (gameEnt) {
1467  if (MessageBox("Please choose another name", "Duplicate Entity Name!", MB_OKCANCEL) == IDCANCEL) {
1468  return;
1469  }
1470  } else {
1471  nameValid = true;
1472  name = dlg.m_strName;
1473  }
1474  }
1475  }
1476 
1477  args.Set("name", name.c_str());
1478 
1479  idEntity *ent = NULL;
1480  gameEdit->SpawnEntityDef( args, &ent );
1481  if (ent) {
1484  gameEdit->AddSelectedEntity( ent );
1485  }
1486 
1487  gameEdit->MapAddEntity( &args );
1488 }
1489 
1491 {
1492  // never return on OK as windows will map this at times when you don't want
1493  // ENTER closing the dialog
1494  // CDialog::OnOK();
1495 }
virtual void EntityUpdateChangeableSpawnArgs(idEntity *ent, const idDict *dict)
Definition: GameEdit.cpp:864
void ParticleEditorInit(const idDict *spawnArgs)
#define IDC_BUTTON_NEW
GLubyte g
Definition: glext.h:4662
byte color[4]
Definition: MegaTexture.cpp:54
void VectorCallBack(idQuat rotation)
virtual void SetCVarInteger(const char *name, const int value, int flags=0)=0
GLsizei const GLfloat * value
Definition: glext.h:3614
#define IDC_EDIT_FADEIN
#define IDC_SLIDER_FADEIN
idStr & SetFileExtension(const char *extension)
Definition: Str.cpp:743
int mapModified
Definition: EditorMap.cpp:34
virtual void MapAddEntity(const idDict *dict) const
Definition: GameEdit.cpp:1070
virtual void EntitySetColor(idEntity *ent, const idVec3 color)
Definition: GameEdit.cpp:830
#define IDC_BUTTON_SAVE_PARTICLE
idCVarSystem * cvarSystem
Definition: CVarSystem.cpp:487
#define IDC_BUTTON_BROWSEFADECOLOR
const char * GetFileName(void) const
Definition: DeclManager.h:171
#define IDC_EDIT_RINGOFFSET
#define IDC_SLIDER_ROTATIONTO
afx_msg void OnBnClickedRadioAimed()
#define IDC_EDIT_SIZETO
float y
Definition: Vector.h:811
#define IDC_BUTTON_IMPACT
#define IDC_EDIT_ANIMFRAMES
#define IDC_BUTTON_BROWSECOLOR_ENTITY
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
virtual void EntityTranslate(idEntity *ent, const idVec3 &org)
Definition: GameEdit.cpp:841
const char * ToString(int precision=2) const
Definition: Matrix.cpp:610
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
idMat3 ToMat3(void) const
Definition: Quat.cpp:70
#define IDC_EDIT_SIZEFROM
prtDirection_t
Definition: DeclParticle.h:61
void UpdateSelectedOrigin(float x, float y, float z)
#define IDC_EDIT_DEADTIME
#define IDC_RADIO_Z
virtual void EntitySetAxis(idEntity *ent, const idMat3 &axis)
Definition: GameEdit.cpp:819
static void ClearStates(void)
Definition: KeyInput.cpp:746
idDeclParticle * GetCurParticle()
virtual int GetCVarInteger(const char *name) const =0
GLenum GLint GLint y
Definition: glext.h:2849
float fadeIndexFraction
Definition: DeclParticle.h:180
virtual const char * GetUniqueEntityName(const char *classname) const
Definition: GameEdit.cpp:764
idRenderSystem * renderSystem
float z
Definition: Vector.h:812
float z
Definition: Vector.h:320
prtDistribution_t
Definition: DeclParticle.h:53
CString m_strName
Definition: DialogName.h:51
#define IDC_SLIDER_TIME
#define IDC_BUTTON_MUZZLE
idFileSystem * fileSystem
Definition: FileSystem.cpp:500
#define IDC_RADIO_SPHERE
#define IDC_EDIT_ZSIZE
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
afx_msg void OnBnClickedButtonSaveAs()
void SetVectorControlUpdate(idQuat rotation)
#define IDC_EDIT_OFFSET
const char * GetName(void) const
Definition: DeclManager.h:140
#define IDC_BUTTON_SAVE_PARTICLEENTITIES
Definition: Vector.h:316
virtual idDecl * CreateNewDecl(declType_t type, const char *name, const char *fileName)=0
type * Ptr(void)
Definition: List.h:596
#define IDC_RADIO_CYLINDER
idStr mediaName
Definition: PreviewDlg.h:53
bool Save(const char *fileName=NULL)
virtual void SetCVarString(const char *name, const char *value, int flags=0)=0
idCmdSystem * cmdSystem
Definition: CmdSystem.cpp:116
afx_msg void OnCbnSelchangeComboPath()
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
void SetMode(int mode, const char *preSelect=NULL)
Definition: PreviewDlg.cpp:527
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
#define IDC_EDIT_GRAVITY
float x
Definition: Vector.h:318
GLenum GLint x
Definition: glext.h:2849
int i
Definition: process.py:33
#define BOOL
Definition: mprintf.c:71
GLintptr offset
Definition: glext.h:3113
afx_msg void OnCbnSelchangeComboParticles()
#define IDC_EDIT_SPEEDFROM
#define IDC_EDIT_SPEEDTO
afx_msg void OnBnClickedButtonAddstage()
#define IDC_BUTTON_SELECTED
afx_msg void OnBnClickedRadioOutward()
#define IDC_EDIT_XSIZE
CDialogParticleEditor * g_ParticleDialog
#define IDC_RADIO_X
#define IDC_SLIDER_BUNCHING
idParticleParm aspect
Definition: DeclParticle.h:174
idParticleParm rotationSpeed
Definition: DeclParticle.h:168
idGameEdit * gameEdit
Definition: GameEdit.cpp:668
#define IDC_EDIT_ASPECTTO
#define IDC_BUTTON_DOOM
#define IDC_RADIO_RECT
afx_msg void OnBnClickedWorldGravity()
void InitAfx(void)
Definition: StdAfx.cpp:53
int com_editors
Definition: Common.cpp:97
afx_msg void OnLbnSelchangeListStages()
#define IDC_COMBO_CUSTOMPATH
GLsizei GLsizei GLcharARB * source
Definition: glext.h:3633
virtual void MapSetEntityKeyVal(const char *name, const char *key, const char *val) const
Definition: GameEdit.cpp:1011
prtOrientation_t
Definition: DeclParticle.h:74
virtual void BufferCommandText(cmdExecution_t exec, const char *text)=0
const int EditEnableID[]
virtual void EntityGetAxis(idEntity *ent, idMat3 &axis) const
Definition: GameEdit.cpp:797
#define IDD_DIALOG_PARTICLE_EDITOR
const int EditIDCount
#define IDC_RADIO_Y
virtual void PlayerGetEyePosition(idVec3 &org) const
Definition: GameEdit.cpp:973
afx_msg void OnBnClickedButtonSaveParticles()
afx_msg void OnBnClickedButtonBrowseEntitycolor()
GLuint GLuint GLsizei count
Definition: glext.h:2845
#define IDC_BUTTON_VECTOR
#define IDC_EDIT_COUNT
#define IDC_BUTTON_ZDN
void SelectParticle(const char *name)
void SetCustomPathType(const char *p)
virtual bool IsFullScreen(void) const =0
GLuint index
Definition: glext.h:3476
afx_msg void OnBnClickedButtonBrowsefadecolor()
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
#define IDC_EDIT_DEPTHHACK
#define IDC_EDIT_ROTATIONFROM
idStr & StripFileExtension(void)
Definition: Str.cpp:757
idVec3 ToForward(void) const
Definition: Angles.cpp:117
void SetValueRange(float _low, float _high)
#define IDC_CHECK_WORLDGRAVITY
#define IDC_EDIT_FADECOLOR
virtual void DoDataExchange(CDataExchange *pDX)
afx_msg void OnBnClickedButtonUpdate()
afx_msg void OnBnClickedRadioSphere()
#define IDC_BUTTON_SAVE_PARTICLE_AS
#define IDC_EDIT_CUSTOMPARMS
idCommon * common
Definition: Common.cpp:206
bool DoNewColor(int *i1, int *i2, int *i3, float *overBright, void(*Update)(float, float, float, float))
virtual void PlayerGetViewAngles(idAngles &angles) const
Definition: GameEdit.cpp:964
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
#define IDC_SLIDER_SPEEDFROM
#define IDC_LIST_STAGES
#define IDC_CHECK_EDITPARTICLEMODE
void Clear(void)
Definition: Dict.cpp:201
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
#define IDC_BUTTON_XUP
float y
Definition: Vector.h:319
virtual void AddSelectedEntity(idEntity *ent)
Definition: GameEdit.cpp:724
#define IDC_SLIDER_ASPECTTO
prtDirection_t directionType
Definition: DeclParticle.h:146
virtual void SetCVarBool(const char *name, const bool value, int flags=0)=0
#define IDC_SLIDER_ROTATIONFROM
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:260
#define IDC_EDIT_CYCLES
afx_msg void OnBnClickedButtonShowstage()
#define IDC_BUTTON_YUP
const char * ToString(int precision=2) const
Definition: Vector.cpp:307
float w
Definition: Vector.h:813
const int StageEnableID[]
prtDistribution_t distributionType
Definition: DeclParticle.h:143
const char * GetCustomPathName()
#define IDC_SLIDER_FADEOUT
const idMaterial * material
Definition: DeclParticle.h:128
#define IDC_EDIT_FADEOUT
#define IDC_SLIDER_ASPECTFROM
void DeleteContents(bool clear)
Definition: List.h:207
void SetVectorChangingCallback(VectorCtlCallbackProc proc)
Definition: VectorCtl.h:146
#define IDC_RADIO_VIEW
#define IDC_BUTTON_ADDSTAGE
#define IDC_EDIT_ORIENTATIONPARM2
afx_msg void OnBnClickedButtonBrowsematerial()
#define IDC_EDIT_ORIENTATIONPARM1
#define IDC_BUTTON_DROPEMITTER
#define IDC_BUTTON_SHOWSTAGE
virtual void Printf(const char *fmt,...) id_attribute((format(printf
#define IDC_BUTTON_HIDESTAGE
float orientationParms[4]
Definition: DeclParticle.h:171
idList< idParticleStage * > stages
Definition: DeclParticle.h:204
void ParticleEditorRun(void)
afx_msg void OnBnClickedButtonHidestage()
afx_msg void OnBnClickedButtonBrowsecolor()
#define IDC_BUTTON_REMOVESTAGE
const char * GetCustomPathDesc()
prtCustomPth_t customPathType
Definition: DeclParticle.h:157
const char * ToString(int precision=2) const
Definition: Vector.cpp:221
virtual int GetSelectedEntities(idEntity *list[], int max)
Definition: GameEdit.cpp:676
#define IDC_EDIT_COLOR
#define IDC_COMBO_PARTICLES
idDeclManager * declManager
#define IDC_CHECK_ENTITYCOLOR
#define IDC_STATIC_DIRPARM
afx_msg void OnBnClickedEntityColor()
GLubyte GLubyte b
Definition: glext.h:4662
#define IDC_SLIDER_COUNT
Definition: Quat.h:48
virtual void EntitySetModel(idEntity *ent, const char *val)
Definition: GameEdit.cpp:905
virtual int GetNumDecls(declType_t type)=0
#define IDC_EDIT_BUNCHING
int Append(const type &obj)
Definition: List.h:646
GLdouble GLdouble GLdouble r
Definition: glext.h:2951
#define IDC_STATIC_INFILE
Definition: Matrix.h:333
idParticleParm speed
Definition: DeclParticle.h:149
#define IDC_CHECK_RANDOMDISTRIBUTION
void SetDisablePreview(bool b)
Definition: PreviewDlg.h:49
#define IDC_SLIDER_GRAVITY
float yaw
Definition: Angles.h:54
#define IDC_EDIT_TIME
#define IDC_SLIDER_SIZETO
#define IDC_EDIT_TIMEOFFSET
#define IDC_STATIC_DESC
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
tuple f
Definition: idal.py:89
#define IDC_BUTTON_TESTMODEL
#define IDC_EDIT_BOUNDSEXPANSION
int Num(void) const
Definition: List.h:265
bool RemoveIndex(int index)
Definition: List.h:849
const GLcharARB * name
Definition: glext.h:3629
#define IDC_EDIT_ANIMRATE
#define IDC_SLIDER_SPEEDTO
#define IDC_EDIT_ROTATIONTO
void SetValuePos(float val)
Definition: Str.h:116
float distributionParms[4]
Definition: DeclParticle.h:144
virtual bool PlayerIsValid() const
Definition: GameEdit.cpp:937
const char * c_str(void) const
Definition: Str.h:487
#define FALSE
Definition: mprintf.c:70
#define IDC_EDIT_MATERIAL
virtual void ClearEntitySelection(void)
Definition: GameEdit.cpp:710
#define IDC_BUTTON_UPDATE
virtual void SpawnEntityDef(const idDict &args, idEntity **ent)
Definition: GameEdit.cpp:744
#define IDC_EDIT_ASPECTFROM
#define TRUE
Definition: mprintf.c:69
virtual const idDict * EntityGetSpawnArgs(idEntity *ent) const
Definition: GameEdit.cpp:852
float directionParms[4]
Definition: DeclParticle.h:147
#define IDC_EDIT_INITIALANGLE
#define IDC_EDIT_YSIZE
void ParticleEditorShutdown(void)
char * va(const char *fmt,...)
Definition: Str.cpp:1568
#define IDC_RADIO_CONE
Win32Vars_t win32
Definition: win_main.cpp:65
#define IDC_BUTTON_FLIGHT
prtOrientation_t orientation
Definition: DeclParticle.h:170
#define IDC_SLIDER_SIZEFROM
virtual const char * OSPathToRelativePath(const char *OSPath)=0
void SetidAxis(const idMat3 &mat)
Definition: VectorCtl.h:131
afx_msg void OnBnClickedButtonRemovestage()
virtual void EntityChangeSpawnArgs(idEntity *ent, const idDict *newArgs)
Definition: GameEdit.cpp:875
#define IDC_BUTTON_ZUP
float x
Definition: Vector.h:810
#define IDC_BUTTON_YDN
#define IDC_RADIO_OUTWARD
GLdouble GLdouble z
Definition: glext.h:3067
#define IDC_EDIT_FADEFRACTION
#define IDC_EDIT_DIRECTIONPARM
#define IDC_RADIO_AIMED
virtual idEntity * FindEntity(const char *name) const
Definition: GameEdit.cpp:753
#define IDC_SLIDER_FADEFRACTION
float customPathParms[8]
Definition: DeclParticle.h:158
#define IDC_BUTTON_XDN
virtual void MapEntityTranslate(const char *name, const idVec3 &v) const
Definition: GameEdit.cpp:1131
#define IDC_BUTTON_BROWSEMATERIAL
const int StageIDCount
afx_msg void OnBnClickedRadioCylinder()
idParticleParm size
Definition: DeclParticle.h:173
virtual void EntityUpdateVisuals(idEntity *ent)
Definition: GameEdit.cpp:894
idParticleStage * GetCurStage()
void SetSelectedModel(const char *val)
#define IDC_BUTTON_BROWSECOLOR