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/>.
17 #if !defined(AFX_ATTRIB_DLG_H__DF35743E_C8B4_4218_9C42_A3DF4126BEF2__INCLUDED_)
18 #define AFX_ATTRIB_DLG_H__DF35743E_C8B4_4218_9C42_A3DF4126BEF2__INCLUDED_
25 #include "nel/misc/rgba.h"
26 #include "nel/3d/ps_plane_basis.h"
27 #include "nel/3d/ps_attrib_maker.h"
28 #include "editable_range.h"
29 #include "popup_notify.h"
30 #include "particle_workspace.h"
34 class CPSAttribMakerBase
;
44 /////////////////////////////////////////////////////////////////////////////
47 class CAttribDlg
: public CDialog
, public IPopupNotify
51 /** construct the dialog
52 * \param : valueID : an unique id for this dialog
53 * \param : enableConstantValue when false, only a scheme is available
55 CAttribDlg(const std::string
&valueID
, CParticleWorkspace::CNode
*ownerNode
, bool enableConstantValue
= true); // standard constructor
56 CAttribDlg::~CAttribDlg();
59 /// must be called before init, disable constant value usage
60 void disableConstantValue(void) { _EnableConstantValue
= false; }
62 // close window if being edited
63 void closeEditWindow();
66 //{{AFX_DATA(CAttribDlg)
67 enum { IDD
= IDD_ATTRIB_DLG
};
70 CButton m_EditUserParam
;
71 CComboBox m_SchemeInput
;
72 CStatic m_CstValuePos
;
77 CComboBox m_UseScheme
;
84 /// init the dialog with the given bitmap
85 void init(HBITMAP bitmap
, sint x
, sint y
, CWnd
*pParent
= NULL
);
87 // force to update dialog content
91 // ClassWizard generated virtual function overrides
92 //{{AFX_VIRTUAL(CAttribDlg)
94 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
99 /// enable the srcInput
100 void enableSrcInput(bool enable
= true) { _SrcInputEnabled
= enable
; }
101 bool isSrcInputEnabled() const { return _SrcInputEnabled
; }
104 /** Disable the possibility to choose a scheme that has memory. (for example, a scheme for lifetime of a located has no sense
105 * because located have already some memory to store it)
107 void enableMemoryScheme(bool enabled
= true) { _DisableMemoryScheme
= !enabled
; }
109 /** tells whether memory schemes are enables
110 * \see enableMemoryScheme()
112 bool isMemorySchemeEnabled() const { return !_DisableMemoryScheme
; }
114 /// enable Nb Cycle tuning
115 void enableNbCycles(bool enabled
= true) { _NbCycleEnabled
= enabled
; }
116 bool isNbCycleEnabled() const { return _NbCycleEnabled
; }
120 // private usage (not private because accessed by a static function) : return the nbCycles parameter of the scheme (e.g the input multiplier).
121 virtual float getSchemeNbCycles(void) const = 0;
123 // private usage (not private because accessed by a static function) : set the nbCycles parameter of the scheme (e.g the input multiplier)
124 virtual void setSchemeNbCycles(float nbCycles
) = 0;
126 BOOL
EnableWindow( BOOL bEnable
= TRUE
);
131 /// bool : true is src input are allowed
132 bool _SrcInputEnabled
;
134 // true if constant values are allowed
135 bool _EnableConstantValue
;
137 // change the dialog for constant values
138 void cstValueUpdate();
140 /// enable / disable the 'edit input' button, when input can be edited
141 void inputValueUpdate(void);
144 // toggle back from scheme to cst value
145 virtual void resetCstValue(void) = 0;
147 // change the dialog for scheme usage
148 void schemeValueUpdate();
150 // return true if a scheme is used
151 virtual bool useScheme(void) const = 0;
154 // get the number of attributes makers (schemes) that are available
155 virtual uint
getNumScheme(void) const = 0;
157 // get the text associated with an attribute maker
158 virtual std::string
getSchemeName(uint index
) const = 0;
160 // edit the current scheme. And return a window on it
161 virtual CWnd
*editScheme(void) = 0;
163 // set the current scheme
164 virtual void setCurrentScheme(uint index
) = 0;
166 // set the current scheme ptr
167 virtual void setCurrentSchemePtr(NL3D::CPSAttribMakerBase
*) = 0;
169 // get the current scheme, -1 if the scheme is unknow (created outside the editor ?)
170 virtual sint
getCurrentScheme(void) const = 0;
172 /// get a pointer on the current scheme base class
173 virtual NL3D::CPSAttribMakerBase
*getCurrentSchemePtr(void) const = 0;
176 // this must return the right dialog for a constant value (created with nex)
177 virtual CEditAttribDlg
*createConstantValueDlg() = 0;
180 // tells whether the scheme supports custom input
181 virtual bool hasSchemeCustomInput(void) const = 0;
182 // retrieve the scheme input id
183 virtual NL3D::CPSInputType
getSchemeInput(void) const = 0;
184 // set the scheme input id
185 virtual void setSchemeInput(const NL3D::CPSInputType
&input
) = 0;
187 // tells whether the scheme input value is clamped or not
188 virtual bool isSchemeClamped(void) const = 0;
189 // clamp / unclamp the scheme
190 virtual void clampScheme(bool clamped
= true) = 0;
191 // return true if clamping is supported
192 virtual bool isClampingSupported(void) const = 0;
194 /// inherited from IPopupNotify
195 virtual void childPopupClosed(CWnd
*child
);
198 // the dialog used to tune the nb cycles param (when available)
199 CEditableRangeFloat
*_NbCyclesDlg
;
200 // this is equal to true when memory schemes are not permitted
201 bool _DisableMemoryScheme
;
202 /// true to enable 'nb cycles' control
203 bool _NbCycleEnabled
;
204 // wrapper to tune the number of cycles
205 struct CNbCyclesWrapper
: public IPSWrapperFloat
208 float get(void) const { return Dlg
->getSchemeNbCycles(); }
209 void set(const float &v
) { Dlg
->setSchemeNbCycles(v
); }
211 // true when created, it is set to false once a constant, or scheme dialog has bee shown
213 // the dialog used to tune a constant value
214 CEditAttribDlg
*_CstValueDlg
;
216 // the current dialog for scheme edition
217 CWnd
*_SchemeEditionDlg
;
218 std::string _ValueID
;
219 CParticleWorkspace::CNode
*_Node
;
221 // Generated message map functions
222 //{{AFX_MSG(CAttribDlg)
223 afx_msg
void OnSelchangeUseScheme();
224 afx_msg
void OnSelchangeScheme();
225 afx_msg
void OnEditScheme();
226 afx_msg
void OnSelchangeSchemeInput();
227 afx_msg
void OnClampAttrib();
228 afx_msg
void OnEditInput();
229 afx_msg
void OnGetScheme();
230 afx_msg
void OnPutScheme();
231 afx_msg
void OnDestroy();
232 afx_msg
void OnClose();
234 DECLARE_MESSAGE_MAP()
245 * a template class that helps to specialize the attrib maker edition dialog with various types
247 template <typename T
> class CAttribDlgT
: public CAttribDlg
250 CAttribDlgT(const std::string
&valueID
, CParticleWorkspace::CNode
*node
) : CAttribDlg(valueID
, node
),
255 void setWrapper(IPSWrapper
<T
> *wrapper
) { nlassert(wrapper
); _Wrapper
= wrapper
; _Wrapper
->OwnerNode
= _Node
; }
256 void setSchemeWrapper(IPSSchemeWrapper
<T
> *schemeWrapper
) { nlassert(schemeWrapper
); _SchemeWrapper
= schemeWrapper
; _SchemeWrapper
->OwnerNode
= _Node
; }
258 // inherited from CAttribDlg
259 virtual uint
getNumScheme(void) const = 0;
260 virtual std::string
getSchemeName(uint index
) const = 0;
261 virtual CWnd
*editScheme(void) = 0;
262 virtual void setCurrentScheme(uint index
) = 0;
263 virtual sint
getCurrentScheme(void) const = 0;
265 virtual void resetCstValue(void)
267 _Wrapper
->setAndUpdateModifiedFlag(_Wrapper
->get()); // reuse current color
270 virtual bool hasSchemeCustomInput(void) const { return _SchemeWrapper
->getScheme()->hasCustomInput(); }
271 virtual NL3D::CPSInputType
getSchemeInput(void) const { return _SchemeWrapper
->getScheme()->getInput(); }
272 virtual void setSchemeInput(const NL3D::CPSInputType
&input
) { _SchemeWrapper
->getScheme()->setInput(input
); }
275 virtual float getSchemeNbCycles(void) const { return _SchemeWrapper
->getScheme()->getNbCycles(); }
276 virtual void setSchemeNbCycles(float nbCycles
) { _SchemeWrapper
->getScheme()->setNbCycles(nbCycles
); }
280 virtual bool isSchemeClamped(void) const { return _SchemeWrapper
->getScheme()->getClamping(); }
281 virtual void clampScheme(bool clamped
= true) { _SchemeWrapper
->getScheme()->setClamping(clamped
); }
282 virtual bool isClampingSupported(void) const { return _SchemeWrapper
->getScheme()->isClampingSupported(); };
283 virtual NL3D::CPSAttribMakerBase
*getCurrentSchemePtr(void) const { return _SchemeWrapper
->getScheme(); }
284 virtual void setCurrentSchemePtr(NL3D::CPSAttribMakerBase
*s
)
286 _SchemeWrapper
->setSchemeAndUpdateModifiedFlag(NLMISC::safe_cast
<NL3D::CPSAttribMaker
<T
> *>(s
));
291 virtual bool useScheme(void) const
293 nlassert(_SchemeWrapper
);
294 return(_SchemeWrapper
->getScheme() != NULL
);
297 // wrapper to set/get a constant float
298 IPSWrapper
<T
> *_Wrapper
;
299 // wrapper to set/get a scheme
300 IPSSchemeWrapper
<T
> *_SchemeWrapper
;
303 /** an attribute editor specialized for float values
306 class CAttribDlgFloat
: public CAttribDlgT
<float>, public CBoundCheckerFloat
310 * \param valueID an unique id for the constant value editable range dialog
311 * \param minValue : the min value for the editable range dlg(for constant value)
312 * \param maxValue : the min value for the editable range dlg (for constant value)
314 CAttribDlgFloat(const std::string
&valueID
, CParticleWorkspace::CNode
*node
, float minValue
= 0, float maxValue
= 10);
317 // inherited from CAttribDlg
318 virtual uint
getNumScheme(void) const;
319 virtual std::string
getSchemeName(uint index
) const;
320 virtual CWnd
*editScheme(void);
321 virtual void setCurrentScheme(uint index
);
322 virtual sint
getCurrentScheme(void) const;
328 virtual CEditAttribDlg
*createConstantValueDlg();
329 // ID for the cst float value edition dialog
330 std::string _CstValueId
;
331 float _MinRange
, _MaxRange
;
335 /** an attribute editor specialized for unsigned int values
338 class CAttribDlgUInt
: public CAttribDlgT
<uint32
>, public CBoundCheckerUInt
342 * \param valueID an unique id for the constant value editable range dialog
343 * \param minValue : the min value for the editable range dlg(for constant value)
344 * \param maxValue : the min value for the editable range dlg (for constant value)
346 CAttribDlgUInt(const std::string
&valueID
, CParticleWorkspace::CNode
*node
, uint32 minValue
= 0, uint32 maxValue
= 10);
349 // inherited from CAttribDlg
350 virtual uint
getNumScheme(void) const;
351 virtual std::string
getSchemeName(uint index
) const;
352 virtual CWnd
*editScheme(void);
353 virtual void setCurrentScheme(uint index
);
354 virtual sint
getCurrentScheme(void) const;
360 virtual CEditAttribDlg
*createConstantValueDlg();
361 // ID for the cst float value edition dialog
362 std::string _CstValueId
;
363 uint32 _MinRange
, _MaxRange
;
368 /** an attribute editor specialized for signed int values
371 class CAttribDlgInt
: public CAttribDlgT
<sint32
>, public CBoundCheckerInt
375 * \param valueID an unique id for the constant value editable range dialog
376 * \param minValue : the min value for the editable range dlg(for constant value)
377 * \param maxValue : the min value for the editable range dlg (for constant value)
379 CAttribDlgInt(const std::string
&valueID
, CParticleWorkspace::CNode
*node
, sint32 minValue
= 0, sint32 maxValue
= 10);
382 // inherited from CAttribDlg
383 virtual uint
getNumScheme(void) const;
384 virtual std::string
getSchemeName(uint index
) const;
385 virtual CWnd
*editScheme(void);
386 virtual void setCurrentScheme(uint index
);
387 virtual sint
getCurrentScheme(void) const;
393 virtual CEditAttribDlg
*createConstantValueDlg();
394 // ID for the cst float value edition dialog
395 std::string _CstValueId
;
396 sint32 _MinRange
, _MaxRange
;
402 /** an attribute editor specialized for RGB values
405 class CAttribDlgRGBA
: public CAttribDlgT
<CRGBA
>
409 * \param valueID an unique id for the constant value editable range dialog
411 CAttribDlgRGBA(const std::string
&valueID
, CParticleWorkspace::CNode
*node
);
414 // inherited from CAttribDlg
415 virtual uint
getNumScheme(void) const;
416 virtual std::string
getSchemeName(uint index
) const;
417 virtual CWnd
*editScheme(void);
418 virtual void setCurrentScheme(uint index
);
419 virtual sint
getCurrentScheme(void) const;
425 virtual CEditAttribDlg
*createConstantValueDlg();
426 // ID for the cst float value edition dialog
427 std::string _CstValueId
;
431 /** an attribute editor specialized for plane basis values
434 class CAttribDlgPlaneBasis
: public CAttribDlgT
<NL3D::CPlaneBasis
>
438 * \param valueID an unique id for the constant value editable range dialog
440 CAttribDlgPlaneBasis(const std::string
&valueID
, CParticleWorkspace::CNode
*node
);
443 // inherited from CAttribDlg
444 virtual uint
getNumScheme(void) const;
445 virtual std::string
getSchemeName(uint index
) const;
446 virtual CWnd
*editScheme(void);
447 virtual void setCurrentScheme(uint index
);
448 virtual sint
getCurrentScheme(void) const;
454 virtual CEditAttribDlg
*createConstantValueDlg();
455 // ID for the cst float value edition dialog
456 std::string _CstValueId
;
461 //{{AFX_INSERT_LOCATION}}
462 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
464 #endif // !defined(AFX_ATTRIB_DLG_H__DF35743E_C8B4_4218_9C42_A3DF4126BEF2__INCLUDED_)