29 #include "../../idlib/precompiled.h"
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"
45 #ifdef ID_DEBUG_MEMORY
144 common->
Printf(
"Cannot run the particle editor in fullscreen mode.\n"
145 "Set r_fullscreen to 0 and vid_restart.\n" );
149 if ( g_ParticleDialog ==
NULL ) {
154 if ( g_ParticleDialog->GetSafeHwnd() ==
NULL) {
165 g_ParticleDialog->ShowWindow( SW_SHOW );
166 g_ParticleDialog->SetFocus();
186 MSG *msg = AfxGetCurrentMessage();
188 MSG *msg = &m_msgCur;
191 while( ::PeekMessage(msg,
NULL,
NULL,
NULL, PM_NOREMOVE) ) {
193 if ( !AfxGetApp()->PumpMessage() ) {
205 g_ParticleDialog =
NULL;
221 , fadeFraction(_T(""))
233 , directionParm(_T(""))
240 , rotationFrom(_T(""))
247 , customParms(_T(""))
252 , randomDistribution(TRUE)
253 , initialAngle(_T(""))
254 , boundsExpansion(_T(""))
256 , particleMode(
FALSE)
258 visualization = TESTMODEL;
266 CDialog::DoDataExchange(pDX);
383 particleMode = !particleMode;
385 EnableEditControls();
395 if (dlg.DoModal() == IDOK) {
397 MessageBox(
"Particle already exists!",
"Particle exists", MB_OK );
400 CFileDialog dlgSave(
TRUE,
"prt",
NULL, OFN_CREATEPROMPT,
"Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() );
401 if ( dlgSave.DoModal() == IDOK ) {
431 wnd->EnableWindow(
FALSE );
447 if ( matDlg.DoModal() == IDOK ) {
466 color.Format(
"%f %f %f %f", (
float)r / 255.0
f, (
float)g / 255.0
f, (
float)b / 255.0
f, 1.0
f );
497 str =
va(
"%f %f %f", (
float)r / 255.0
f, (
float)g / 255.0
f, (
float)b / 255.0
f );
499 dict2.
Set(
"_color", str );
508 wnd->EnableWindow(
TRUE );
526 fadeColor.Format(
"%f %f %f %f", (
float)r / 255.0
f, (
float)g / 255.0
f, (
float)b / 255.0
f, 1.0
f );
548 if ( sel == CB_ERR ) {
572 wnd->SetWindowText(
va(
"Particle file: %s", idp->
GetFileName() ) );
596 wnd->SetWindowText( (
direction == 0 ) ?
"Angle" :
"Upward Bias" );
784 if ( dict ==
NULL ) {
796 wnd->EnableWindow(
TRUE );
833 if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
835 if ( source ==
NULL ) {
857 if ( MessageBox(
"Are you sure you want to remove this stage?",
"Remove Stage", MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
863 int newIndex =
listStages.GetItemData( index );
864 if ( newIndex >= 0 && newIndex < idp->stages.Num() ) {
866 index += ( index >= 1 ) ? -1 : 1;
869 if ( newIndex >= 0 ) {
887 int newIndex =
listStages.GetItemData( index );
889 listStages.InsertString( index,
va(
"stage %i", index ) );
902 int newIndex =
listStages.GetItemData( index );
904 listStages.InsertString( index,
va(
"stage %i (H) ", index ) );
914 if ( idp ==
NULL || sel == LB_ERR || index >= idp->
stages.
Num() ) {
1025 UpdateData(
FALSE );
1032 if ( idp ==
NULL ) {
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 ) {
1112 MessageBox(
"Particle already exists!",
"Particle exists", MB_OK );
1119 if ( MessageBox(
"Copy current particle?",
"Copy current", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
1120 MessageBox(
"Copy current particle not implemented yet.. Stay tuned" );
1136 if ( idp ==
NULL ) {
1142 CFileDialog dlgSave(
FALSE,
"prt",
NULL, OFN_OVERWRITEPROMPT,
"Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() );
1143 if ( dlgSave.DoModal() == IDOK ) {
1146 idp->
Save( fileName );
1171 return CDialog::OnDestroy();
1175 if ( g_ParticleDialog && g_ParticleDialog->GetSafeHwnd() ) {
1189 for (
int i = 0;
i <
count;
i++ ) {
1191 if ( dict ==
NULL ) {
1201 wnd->EnableWindow(
TRUE );
1214 CDialog::OnInitDialog();
1253 CWnd* wnd = GetWindow( GW_CHILD );
1256 if ( str.LoadString( wnd->GetDlgCtrlID() ) ) {
1259 wnd = wnd->GetWindow( GW_HWNDNEXT );
1264 wnd->EnableWindow(
FALSE );
1275 CDialog::OnHScroll( nSBCode, nPos, pScrollBar );
1276 CSliderCtrl *ctrl =
dynamic_cast< CSliderCtrl*
>( pScrollBar );
1346 if ( pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST ) {
1349 return CDialog::PreTranslateMessage(pMsg);
1354 bool b = ( stage && stage->
hidden ) ?
false :
true;
1358 wnd->EnableWindow( b );
1365 CWnd *wnd = GetDlgItem( EditEnableID[
i ] );
1382 for (
int i = 0;
i <
count;
i++ ) {
1384 if ( dict ==
NULL ) {
1394 wnd->EnableWindow(
TRUE );
1447 args.
Set(
"classname",
"func_emitter");
1448 args.
Set(
"angle",
va(
"%f", viewAngles.
yaw + 180 ));
1451 if ( idp ==
NULL ) {
1457 args.
Set(
"model", str);
1460 bool nameValid =
false;
1461 while (!nameValid) {
1464 if (dlg.DoModal() == IDOK) {
1467 if (MessageBox(
"Please choose another name",
"Duplicate Entity Name!", MB_OKCANCEL) == IDCANCEL) {
virtual void EntityUpdateChangeableSpawnArgs(idEntity *ent, const idDict *dict)
void ParticleEditorInit(const idDict *spawnArgs)
CRangeSlider sliderSizeTo
afx_msg void OnBnClickedRadioY()
void VectorCallBack(idQuat rotation)
virtual void SetCVarInteger(const char *name, const int value, int flags=0)=0
void UpdateParticleData()
GLsizei const GLfloat * value
#define IDC_SLIDER_FADEIN
idStr & SetFileExtension(const char *extension)
virtual void MapAddEntity(const idDict *dict) const
virtual void EntitySetColor(idEntity *ent, const idVec3 color)
#define IDC_BUTTON_SAVE_PARTICLE
idCVarSystem * cvarSystem
#define IDC_BUTTON_BROWSEFADECOLOR
afx_msg void OnBnClickedMuzzle()
void SetParticleVisualization(int i)
const char * GetFileName(void) const
afx_msg void OnBnClickedRadioCone()
#define IDC_EDIT_RINGOFFSET
#define IDC_SLIDER_ROTATIONTO
afx_msg void OnBnClickedRadioAimed()
afx_msg void OnBnClickedRadioX()
#define IDC_BUTTON_IMPACT
#define IDC_EDIT_ANIMFRAMES
#define IDC_BUTTON_BROWSECOLOR_ENTITY
CONST PIXELFORMATDESCRIPTOR UINT
virtual void EntityTranslate(idEntity *ent, const idVec3 &org)
const char * ToString(int precision=2) const
afx_msg void OnBnClickedRadioView()
void SetNum(int newnum, bool resize=true)
idMat3 ToMat3(void) const
#define IDC_EDIT_SIZEFROM
void UpdateSelectedOrigin(float x, float y, float z)
#define IDC_EDIT_DEADTIME
virtual void EntitySetAxis(idEntity *ent, const idMat3 &axis)
idDeclParticle * GetCurParticle()
virtual int GetCVarInteger(const char *name) const =0
virtual const char * GetUniqueEntityName(const char *classname) const
idRenderSystem * renderSystem
#define IDC_BUTTON_MUZZLE
idFileSystem * fileSystem
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
CRangeSlider sliderAspectTo
afx_msg void OnBnClickedButtonSaveAs()
afx_msg void OnBnClickedRadioZ()
void SetVectorControlUpdate(idQuat rotation)
const char * GetName(void) const
#define IDC_BUTTON_SAVE_PARTICLEENTITIES
virtual idDecl * CreateNewDecl(declType_t type, const char *name, const char *fileName)=0
#define IDC_RADIO_CYLINDER
bool Save(const char *fileName=NULL)
virtual void SetCVarString(const char *name, const char *value, int flags=0)=0
CStatic staticDirectionParm
CRangeSlider sliderSpeedFrom
afx_msg void OnCbnSelchangeComboPath()
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
void SetMode(int mode, const char *preSelect=NULL)
void Set(const char *key, const char *value)
afx_msg void OnCbnSelchangeComboParticles()
#define IDC_EDIT_SPEEDFROM
afx_msg void OnBnClickedButtonAddstage()
CRangeSlider sliderBunching
#define IDC_BUTTON_SELECTED
afx_msg void OnBnClickedRadioOutward()
CDialogParticleEditor * g_ParticleDialog
#define IDC_SLIDER_BUNCHING
idParticleParm rotationSpeed
#define IDC_EDIT_ASPECTTO
afx_msg void OnBnClickedButtonSave()
afx_msg void OnBnClickedWorldGravity()
afx_msg void OnLbnSelchangeListStages()
#define IDC_COMBO_CUSTOMPATH
GLsizei GLsizei GLcharARB * source
virtual void MapSetEntityKeyVal(const char *name, const char *key, const char *val) const
virtual void BufferCommandText(cmdExecution_t exec, const char *text)=0
virtual void EntityGetAxis(idEntity *ent, idMat3 &axis) const
#define IDD_DIALOG_PARTICLE_EDITOR
virtual void PlayerGetEyePosition(idVec3 &org) const
afx_msg void OnBnClickedButtonSaveParticles()
afx_msg void OnBnClickedButtonBrowseEntitycolor()
GLuint GLuint GLsizei count
#define IDC_BUTTON_VECTOR
void SelectParticle(const char *name)
void SetCustomPathType(const char *p)
virtual bool IsFullScreen(void) const =0
CRangeSlider sliderFadeIn
afx_msg void OnBnClickedButtonBrowsefadecolor()
const char * GetString(const char *key, const char *defaultString="") const
#define IDC_EDIT_DEPTHHACK
#define IDC_EDIT_ROTATIONFROM
idStr & StripFileExtension(void)
idVec3 ToForward(void) const
void SetValueRange(float _low, float _high)
CRangeSlider sliderSizeFrom
#define IDC_CHECK_WORLDGRAVITY
#define IDC_EDIT_FADECOLOR
virtual void DoDataExchange(CDataExchange *pDX)
afx_msg void OnBnClickedButtonUpdate()
afx_msg void OnBnClickedRadioSphere()
CRangeSlider sliderFadeOut
#define IDC_BUTTON_SAVE_PARTICLE_AS
#define IDC_EDIT_CUSTOMPARMS
bool DoNewColor(int *i1, int *i2, int *i3, float *overBright, void(*Update)(float, float, float, float))
virtual void PlayerGetViewAngles(idAngles &angles) const
afx_msg void OnBnClickedSelected()
#define IDC_SLIDER_SPEEDFROM
#define IDC_CHECK_EDITPARTICLEMODE
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
virtual void AddSelectedEntity(idEntity *ent)
#define IDC_SLIDER_ASPECTTO
prtDirection_t directionType
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
afx_msg void OnBnClickedButtonShowstage()
const char * ToString(int precision=2) const
CRangeSlider sliderGravity
const int StageEnableID[]
prtDistribution_t distributionType
const char * GetCustomPathName()
#define IDC_SLIDER_FADEOUT
const idMaterial * material
#define IDC_SLIDER_ASPECTFROM
void DeleteContents(bool clear)
void SetVectorChangingCallback(VectorCtlCallbackProc proc)
#define IDC_BUTTON_ADDSTAGE
CRangeSlider sliderAspectFrom
#define IDC_EDIT_ORIENTATIONPARM2
afx_msg void OnBnClickedButtonBrowsematerial()
#define IDC_EDIT_ORIENTATIONPARM1
void EnableStageControls()
#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]
idList< idParticleStage * > stages
virtual ~CDialogParticleEditor()
void ParticleEditorRun(void)
afx_msg void OnBnClickedButtonHidestage()
afx_msg void OnBnClickedButtonBrowsecolor()
#define IDC_BUTTON_REMOVESTAGE
const char * GetCustomPathDesc()
prtCustomPth_t customPathType
const char * ToString(int precision=2) const
virtual int GetSelectedEntities(idEntity *list[], int max)
#define IDC_COMBO_PARTICLES
idDeclManager * declManager
#define IDC_CHECK_ENTITYCOLOR
#define IDC_STATIC_DIRPARM
afx_msg void OnBnClickedEntityColor()
virtual void EntitySetModel(idEntity *ent, const char *val)
virtual int GetNumDecls(declType_t type)=0
#define IDC_EDIT_BUNCHING
int Append(const type &obj)
GLdouble GLdouble GLdouble r
#define IDC_STATIC_INFILE
#define IDC_CHECK_RANDOMDISTRIBUTION
void SetDisablePreview(bool b)
#define IDC_SLIDER_GRAVITY
#define IDC_SLIDER_SIZETO
#define IDC_EDIT_TIMEOFFSET
afx_msg void OnBnClickedTestModel()
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
virtual BOOL OnInitDialog()
#define IDC_BUTTON_TESTMODEL
#define IDC_EDIT_BOUNDSEXPANSION
void EnableEditControls()
bool RemoveIndex(int index)
CRangeSlider sliderRotationFrom
afx_msg void OnBnClickedFlight()
afx_msg void OnBnClickedDoom()
#define IDC_EDIT_ANIMRATE
afx_msg void OnBnClickedButtonNew()
#define IDC_SLIDER_SPEEDTO
#define IDC_EDIT_ROTATIONTO
void SetValuePos(float val)
float distributionParms[4]
CRangeSlider sliderRotationTo
CRangeSlider sliderFadeFraction
virtual bool PlayerIsValid() const
const char * c_str(void) const
#define IDC_EDIT_MATERIAL
virtual void ClearEntitySelection(void)
#define IDC_BUTTON_UPDATE
virtual void SpawnEntityDef(const idDict &args, idEntity **ent)
#define IDC_EDIT_ASPECTFROM
afx_msg void OnBnClickedRadioRect()
BOOL PreTranslateMessage(MSG *pMsg)
virtual const idDict * EntityGetSpawnArgs(idEntity *ent) const
afx_msg void OnBnClickedImpact()
#define IDC_EDIT_INITIALANGLE
void ParticleEditorShutdown(void)
char * va(const char *fmt,...)
#define IDC_BUTTON_FLIGHT
prtOrientation_t orientation
#define IDC_SLIDER_SIZEFROM
virtual const char * OSPathToRelativePath(const char *OSPath)=0
void SetidAxis(const idMat3 &mat)
afx_msg void OnBnClickedButtonRemovestage()
virtual void EntityChangeSpawnArgs(idEntity *ent, const idDict *newArgs)
#define IDC_RADIO_OUTWARD
#define IDC_EDIT_FADEFRACTION
#define IDC_EDIT_DIRECTIONPARM
virtual idEntity * FindEntity(const char *name) const
#define IDC_SLIDER_FADEFRACTION
CRangeSlider sliderSpeedTo
virtual void MapEntityTranslate(const char *name, const idVec3 &v) const
#define IDC_BUTTON_BROWSEMATERIAL
afx_msg void OnBnClickedRadioCylinder()
virtual void EntityUpdateVisuals(idEntity *ent)
idParticleStage * GetCurStage()
void SetSelectedModel(const char *val)
#define IDC_BUTTON_BROWSECOLOR