1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #if !defined(AFX_PARTICLE_DLG_H__AD58E337_952E_4C0D_A6D8_F87AFFEA3A24__INCLUDED_)
19 #define AFX_PARTICLE_DLG_H__AD58E337_952E_4C0D_A6D8_F87AFFEA3A24__INCLUDED_
25 #endif // _MSC_VER > 1000
26 // particle_dlg.h : header file
30 #include "object_viewer.h"
31 #include "particle_tree_ctrl.h"
32 #include "nel/misc/matrix.h"
33 #include "particle_workspace.h"
37 class CParticleSystem
;
38 class CParticleSystemModel
;
44 class CStartStopParticleSystem
;
46 class CParticleTreeCtrl
;
53 /////////////////////////////////////////////////////////////////////////////
54 // CParticleDlg dialog
56 class CParticleDlg
: public CDialog
, public CObjectViewer::IMainLoopCallBack
60 CParticleDlg::CParticleDlg(class CObjectViewer
* main
, CWnd
*pParent
, CMainFrame
* mainFrame
, CAnimationDlg
*animDLG
);
62 void setRightPane(CWnd
*pane
);
63 BOOL
Create(UINT nIDTemplate
, CWnd
* pParentWnd
= NULL
);
66 //{{AFX_DATA(CParticleDlg)
67 enum { IDD
= IDD_PARTICLE
};
72 // ClassWizard generated virtual function overrides
73 //{{AFX_VIRTUAL(CParticleDlg)
75 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
76 virtual LRESULT
WindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
82 // the tree for viewing the system
83 CParticleTreeCtrl
*ParticleTreeCtrl
;
84 // inherited from CObjectViewer::IMainLoopCallBack
88 friend class CParticleTreeCtrl
;
89 /** Active a new node of the workspace
90 * Current active node is ready for edition.
91 * Its bbox is displayed.
93 void setActiveNode(CParticleWorkspace::CNode
*node
);
94 // Get the node of the workspace that is currently active
95 CParticleWorkspace::CNode
*getActiveNode() const { return _ActiveNode
; }
96 // Get the particle system model that is currently active
97 NL3D::CParticleSystemModel
*getActivePSM() const { return _ActiveNode
? _ActiveNode
->getPSModel() : NULL
; }
98 // get matrix of current fx
99 const NLMISC::CMatrix
&getPSMatrix() const;
100 // set matrix of current fx
101 void setPSMatrix(const NLMISC::CMatrix
&mat
);
102 // get world matrix of current fx
103 const NLMISC::CMatrix
&getPSWorldMatrix() const;
104 // set world matrix of current fx
105 void setPSWorldMatrix(const NLMISC::CMatrix
&mat
);
106 // move the current selected element using the given matrix
107 void moveElement(const NLMISC::CMatrix
&mat
);
108 // get the matrix of the current selected element selected, or identity if there's none
109 NLMISC::CMatrix
getElementMatrix(void) const;
111 CMainFrame
*MainFrame
;
112 // the fonts used for particle edition
113 NL3D::CFontManager
*FontManager
;
114 NL3D::CFontGenerator
*FontGenerator
;
115 // get the current right pane of the editor (NULL if none)
116 CWnd
*getRightPane(void) { return CurrentRightPane
; }
117 const CWnd
*getRightPane(void) const { return CurrentRightPane
; }
119 void setAutoBBox(bool enable
) { _AutoUpdateBBox
= enable
; }
120 bool getAutoBBox() const { return _AutoUpdateBBox
; }
121 // reset the auto bbox
122 void resetAutoBBox() { _EmptyBBox
= true; }
123 // get the object viewer instance
124 CObjectViewer
*getObjectViewer() const { return _ObjView
; }
125 /** Stick the current edited fx to a skeleton.
126 * This also reset the fx matrix, and prevent from changing it.
128 void stickPSToSkeleton(CParticleWorkspace::CNode
*node
,
129 NL3D::CSkeletonModel
*skel
,
131 const std::string
&parentSkelName
, // -> saved in the workspace
132 const std::string
&parentBoneName
134 // unstick the current edited fx from its parent skeleton (if there's one)
135 void unstickPSFromSkeleton(CParticleWorkspace::CNode
*node
);
136 // return true is the current edited fx is sticked to a skeleton.
137 bool isPSStickedToSkeleton() const { return _ActiveNode
!= NULL
? _ActiveNode
->getParentSkel() != NULL
: false; }
138 CParticleWorkspace
*getParticleWorkspace() const { return _PW
; }
139 // get a model from a ps pointer. The ps must belong to the workspace
140 NL3D::CParticleSystemModel
*getModelFromPS(NL3D::CParticleSystem
*ps
) const;
141 CStartStopParticleSystem
*StartStopDlg
;
142 // set text of the status bar
143 void setStatusBarText(CString
&str
);
144 // Check if the current workspace has been modified, and prompt the user to save it if so
145 void checkModifiedWorkSpace();
146 // Load a new particle workspace (without asking if current workspace has been modified)
147 void loadWorkspace(const std::string
&fullPath
);
149 CStatusBar _StatusBar
;
150 CObjectViewer
*_ObjView
;
151 CParticleWorkspace
*_PW
;
152 // currently active node of the workspace
153 CParticleWorkspace::CNode
*_ActiveNode
;
155 // the current system that is being edited
156 //NL3D::CParticleSystem *_CurrPS;
158 // the current model that holds our system
159 //NL3D::CParticleSystemModel *_CurrSystemModel;
161 // the system bbox must be updated automatically
162 bool _AutoUpdateBBox
;
164 // the last computed bbox for the system
166 NLMISC::CAABBox _CurrBBox
;
169 // the current right pane of the editor
170 CWnd
*CurrentRightPane
;
171 sint32 CurrRightPaneWidth
, CurrRightPaneHeight
;
173 CRect
getTreeRect(int cx
, int cy
) const;
176 // Generated message map functions
177 //{{AFX_MSG(CParticleDlg)
178 afx_msg
void OnDestroy();
179 virtual BOOL
OnInitDialog();
180 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
181 afx_msg
void OnShowWindow(BOOL bShow
, UINT nStatus
);
182 afx_msg
void OnChar(UINT nChar
, UINT nRepCnt
, UINT nFlags
);
183 afx_msg
void OnCreateNewPsWorkspace();
184 afx_msg
void OnLoadPSWorkspace();
185 afx_msg
void OnSaveAllPsWorkspace();
186 afx_msg
void OnSavePsWorkspace();
187 afx_msg
void OnViewPsFilename();
189 DECLARE_MESSAGE_MAP()
191 // Save the workspace structure
192 void saveWorkspaceStructure();
193 // Save the workspace content
194 void saveWorkspaceContent(bool askToSaveModifiedPS
);
195 // Cloase the workspace without saving or asking the user
196 void closeWorkspace();
198 /** Save a single particle system
199 * \param askToContinueWhenError If an error occurs, the user will be asked if loading must continue (if there are other ps to save)
200 * \return true if loading should continue for remaining ps, false if loading failed and if user didn't want to continue loading
202 bool savePS(HWND parent
, CParticleWorkspace::CNode
&ps
, bool askToContinueWhenError
);
203 bool savePSAs(HWND parent
, CParticleWorkspace::CNode
&ps
, const std::string
&fullPath
, bool askToContinueWhenError
);
204 // Enum to describe the behaviour of loadPS
207 Silent
, // loading error are not prompted
208 ReportError
, // report error
209 ReportErrorSkippable
// report error and ask if the user want errors to be reported again
211 /** Try to load a particle system. Prompt msg as necessary for error loading
212 * \param behav Behaviour in case of error
213 * \return true if the user want see further error (e.g he hasn't checked the 'don't show egain' message box.
215 bool loadPS(HWND parent
, CParticleWorkspace::CNode
&ps
, TLoadPSBehav behav
);
217 uint
computeStatusBarWidth() const;
221 //{{AFX_INSERT_LOCATION}}
222 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
224 #endif // !defined(AFX_PARTICLE_DLG_H__AD58E337_952E_4C0D_A6D8_F87AFFEA3A24__INCLUDED_)