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 #include "object_viewer.h"
19 #include "nel/3d/ps_particle.h"
20 #include "tail_particle_dlg.h"
25 /////////////////////////////////////////////////////////////////////////////
26 // CTailParticleDlg dialog
29 CTailParticleDlg::CTailParticleDlg(CParticleWorkspace::CNode
*ownerNode
, NL3D::CPSTailParticle
*tp
)
34 //{{AFX_DATA_INIT(CTailParticleDlg)
35 m_TailFade
= tp
->getColorFading();
36 m_TailPersistAfterDeath
= FALSE
;
41 void CTailParticleDlg::init(CWnd
*pParent
, sint x
, sint y
)
43 Create(IDD_TAIL_PARTICLE
, pParent
);
46 r
.top
+= y
; r
.bottom
+= y
;
47 r
.right
+= x
; r
.left
+= x
;
50 if (!dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
))
52 m_TailShape
.EnableWindow(FALSE
);
53 m_TailShape
.ShowWindow(FALSE
);
54 m_TailPersistAfterDeathCtrl
.EnableWindow(FALSE
);
55 m_TailPersistAfterDeathCtrl
.ShowWindow(FALSE
);
59 /// m_TailPersistAfterDeath = (dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))->getPersistAfterDeath();
61 NL3D::CPSRibbon
*ribbon
= dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
);
64 ((CComboBox
*) GetDlgItem(IDC_RIBBON_ORIENTATION
))->SetCurSel(ribbon
->getOrientation());
68 GetDlgItem(IDC_RIBBON_ORIENTATION
)->ShowWindow(SW_HIDE
);
74 void CTailParticleDlg::DoDataExchange(CDataExchange
* pDX
)
76 CDialog::DoDataExchange(pDX
);
77 //{{AFX_DATA_MAP(CTailParticleDlg)
78 DDX_Control(pDX
, IDC_TAIL_SHAPE
, m_TailShape
);
79 DDX_Control(pDX
, IDC_TAIL_PERSIST_AFTER_DEATH
, m_TailPersistAfterDeathCtrl
);
80 DDX_Check(pDX
, IDC_TAIL_FADE
, m_TailFade
);
81 DDX_Check(pDX
, IDC_TAIL_PERSIST_AFTER_DEATH
, m_TailPersistAfterDeath
);
86 BEGIN_MESSAGE_MAP(CTailParticleDlg
, CDialog
)
87 //{{AFX_MSG_MAP(CTailParticleDlg)
88 ON_BN_CLICKED(IDC_TAIL_FADE
, OnTailFade
)
89 ON_BN_CLICKED(IDC_TAIL_PERSIST_AFTER_DEATH
, OnTailPersistAfterDeath
)
90 ON_CBN_SELCHANGE(IDC_TAIL_SHAPE
, OnSelchangeTailShape
)
92 ON_CBN_SELCHANGE(IDC_RIBBON_ORIENTATION
, OnSelchangeRibbonOrientation
)
96 /////////////////////////////////////////////////////////////////////////////
97 // CTailParticleDlg message handlers
99 void CTailParticleDlg::OnTailFade()
102 _TailParticle
->setColorFading(m_TailFade
? true : false);
103 _Node
->setModified(true);
109 void CTailParticleDlg::OnTailPersistAfterDeath()
112 nlassert(dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
));
113 /// (dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))->setPersistAfterDeath(m_TailPersistAfterDeath ? true : false);
114 _Node
->setModified(true);
118 void CTailParticleDlg::OnSelchangeTailShape()
121 NL3D::CPSRibbon
*r
= dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
);
123 switch (m_TailShape
.GetCurSel() )
126 r
->setShape(NL3D::CPSRibbon::Triangle
, NL3D::CPSRibbon::NbVerticesInTriangle
);
129 r
->setShape(NL3D::CPSRibbon::Losange
, NL3D::CPSRibbon::NbVerticesInLosange
);
132 r
->setShape(NL3D::CPSRibbon::HeightSides
, NL3D::CPSRibbon::NbVerticesInHeightSide
);
135 r
->setShape(NL3D::CPSRibbon::Pentagram
, NL3D::CPSRibbon::NbVerticesInPentagram
);
137 case 4: // simple segment x
138 r
->setShape(NL3D::CPSRibbon::SimpleSegmentX
, NL3D::CPSRibbon::NbVerticesInSimpleSegmentX
, true);
140 case 5: // simple segment y
141 r
->setShape(NL3D::CPSRibbon::SimpleSegmentY
, NL3D::CPSRibbon::NbVerticesInSimpleSegmentY
, true);
143 case 6: // simple segment z
144 r
->setShape(NL3D::CPSRibbon::SimpleSegmentZ
, NL3D::CPSRibbon::NbVerticesInSimpleSegmentZ
, true);
146 case 7: // simple brace
147 r
->setShape(NL3D::CPSRibbon::SimpleBrace
, NL3D::CPSRibbon::NbVerticesInSimpleBrace
, true);
150 _Node
->setModified(true);
154 void CTailParticleDlg::OnPaint()
156 CPaintDC
dc(this); // device context for painting
158 NL3D::CPSRibbon
*r
= dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
);
159 // if we're dealing with a ribbon, we draw the shape used for extrusion
162 const uint x
= 270, y
= 15, size
= 32;
165 dc
.FillSolidRect(x
, y
, size
, size
, 0xffffff);
167 std::vector
<NLMISC::CVector
> verts
;
168 verts
.resize(r
->getNbVerticesInShape() );
169 r
->getShape(&verts
[0]);
172 p
.CreatePen(PS_SOLID
, 1, (COLORREF
) 0);
173 CPen
*old
= dc
.SelectObject(&p
);
175 if (r
->getBraceMode())
177 for(uint k
= 0; k
< verts
.size() / 2; ++k
)
179 dc
.MoveTo((int) (x
+ (size
/ 2) * (1 + verts
[2 * k
].x
)), (int) (y
+ (size
/ 2) * (1 - verts
[2 * k
].y
)));
180 dc
.LineTo((int) (x
+ (size
/ 2) * (1 + verts
[2 * k
+ 1].x
)), (int) (y
+ (size
/ 2) * (1 - verts
[2 * k
+ 1].y
)));
185 dc
.MoveTo((int) (x
+ (size
/ 2) * (1 + verts
[0].x
)), (int) (y
+ (size
/ 2) * (1 - verts
[0].y
)));
186 for (std::vector
<NLMISC::CVector
>::const_iterator it
= verts
.begin(); it
!= verts
.end(); ++it
)
188 dc
.LineTo((int) (x
+ (size
/ 2) * (1 + it
->x
)), (int) (y
+ (size
/ 2) * (1 - it
->y
)));
190 dc
.LineTo((int) (x
+ (size
/ 2) * (1 + verts
[0].x
)), (int) (y
+ (size
/ 2) * (1 - verts
[0].y
)));
192 dc
.SelectObject(old
);
196 void CTailParticleDlg::OnSelchangeRibbonOrientation()
198 NL3D::CPSRibbon
*r
= dynamic_cast<NL3D::CPSRibbon
*>(_TailParticle
);
200 r
->setOrientation((NL3D::CPSRibbon::TOrientation
) ((CComboBox
*) GetDlgItem(IDC_RIBBON_ORIENTATION
))->GetCurSel());
201 _Node
->setModified(true);