Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / located_target_dlg.cpp
blob608945ca496b1d28c64860e8f0810553a85f4ee6
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "std_afx.h"
23 #include "nel/3d/particle_system.h"
24 #include "object_viewer.h"
25 #include "located_target_dlg.h"
26 #include "collision_zone_dlg.h"
27 #include "editable_range.h"
28 #include "attrib_dlg.h"
29 #include "direction_attr.h"
31 /////////////////////////////////////////////////////////////////////////////
32 // CLocatedTargetDlg dialog
35 CLocatedTargetDlg::CLocatedTargetDlg(CParticleWorkspace::CNode *ownerNode,
36 NL3D::CPSTargetLocatedBindable *lbTarget,
37 CParticleDlg *particleDlg) : _Node(ownerNode), _LBTarget(lbTarget), _ParticleDlg(particleDlg)
39 nlassert(particleDlg);
40 //{{AFX_DATA_INIT(CLocatedTargetDlg)
41 // NOTE: the ClassWizard will add member initialization here
42 //}}AFX_DATA_INIT
46 void CLocatedTargetDlg::DoDataExchange(CDataExchange* pDX)
48 CDialog::DoDataExchange(pDX);
49 //{{AFX_DATA_MAP(CLocatedTargetDlg)
50 DDX_Control(pDX, IDC_AVAILABLE_TARGET, m_AvailableTargets);
51 DDX_Control(pDX, IDC_TARGET, m_Targets);
52 //}}AFX_DATA_MAP
56 BEGIN_MESSAGE_MAP(CLocatedTargetDlg, CDialog)
57 //{{AFX_MSG_MAP(CLocatedTargetDlg)
58 ON_BN_CLICKED(IDC_ADD_TARGET, OnAddTarget)
59 ON_BN_CLICKED(IDC_REMOVE_TARGET, OnRemoveTarget)
60 //}}AFX_MSG_MAP
61 END_MESSAGE_MAP()
63 /////////////////////////////////////////////////////////////////////////////
64 // CLocatedTargetDlg message handlers
67 void CLocatedTargetDlg::init(CWnd* pParent)
69 Create(IDD_LOCATED_TARGET_DLG, pParent);
70 ShowWindow(SW_SHOW);
74 void CLocatedTargetDlg::OnAddTarget()
76 UpdateData();
77 int totalCount = m_AvailableTargets.GetCount();
78 nlassert(totalCount);
79 std::vector<int> indexs;
80 indexs.resize(totalCount);
81 int selCount = m_AvailableTargets.GetSelItems(totalCount, &indexs[0]);
83 std::sort(indexs.begin(), indexs.begin() + selCount); // we never know ...
85 // check that force isn't applied on a forever lasting object
86 if (dynamic_cast<NL3D::CPSForce *>(_LBTarget))
88 bool forEverLastingTarget = false;
89 for (int k = 0; k < selCount; ++k)
91 NL3D::CPSLocated *loc = (NL3D::CPSLocated *) m_AvailableTargets.GetItemData(indexs[k] - k);
92 nlassert(loc);
93 if (loc->getLastForever())
95 forEverLastingTarget = true;
96 break;
99 if (forEverLastingTarget)
101 CString warningStr;
102 CString messStr;
103 warningStr.LoadString(IDS_WARNING);
104 messStr.LoadString(IDS_FORCE_APPLIED_ON_OBJECT_THAT_LAST_FOREVER);
105 if (MessageBox((LPCTSTR) messStr, (LPCTSTR) warningStr, MB_OKCANCEL) != IDOK)
107 return;
112 for (int k = 0; k < selCount; ++k)
114 NL3D::CPSLocated *loc = (NL3D::CPSLocated *) m_AvailableTargets.GetItemData(indexs[k] - k);
115 nlassert(loc);
116 _LBTarget->attachTarget(loc);
117 m_AvailableTargets.DeleteString(indexs[k] - k);
118 int l = m_Targets.AddString(nlUtf8ToTStr(loc->getName()));
119 m_Targets.SetItemData(l, (DWORD_PTR) loc);
121 UpdateData(FALSE);
123 updateModifiedFlag();
126 void CLocatedTargetDlg::OnRemoveTarget()
128 UpdateData();
129 int totalCount = m_Targets.GetCount();
130 nlassert(totalCount);
131 std::vector<int> indexs;
132 indexs.resize(totalCount);
133 int selCount = m_Targets.GetSelItems(totalCount, &indexs[0]);
134 std::sort(indexs.begin(), indexs.begin() + selCount); // we never know ...
135 for (int k = 0; k < selCount; ++k)
137 NL3D::CPSLocated *loc = (NL3D::CPSLocated *) m_Targets.GetItemData(indexs[k] - k);
138 nlassert(loc);
139 _LBTarget->detachTarget(loc);
140 m_Targets.DeleteString(indexs[k] - k);
141 int l = m_AvailableTargets.AddString(nlUtf8ToTStr(loc->getName()));
143 m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc);
145 UpdateData(FALSE);
146 updateModifiedFlag();
149 BOOL CLocatedTargetDlg::OnInitDialog()
151 CDialog::OnInitDialog();
153 RECT r;
155 uint k;
156 uint nbTarg = _LBTarget->getNbTargets();
158 m_Targets.InitStorage(nbTarg, 128);
160 std::set<NL3D::CPSLocated *> targetSet;
162 // fill the box thta tells us what the target are
163 for(k = 0; k < nbTarg; ++k)
165 m_Targets.AddString(nlUtf8ToTStr(_LBTarget->getTarget(k)->getName()));
166 m_Targets.SetItemData(k, (DWORD_PTR) _LBTarget->getTarget(k));
167 targetSet.insert(_LBTarget->getTarget(k));
170 // fill abox with the available targets
171 NL3D::CParticleSystem *ps = _LBTarget->getOwner()->getOwner();
173 uint nbLocated = ps->getNbProcess();
177 m_AvailableTargets.InitStorage(nbTarg, 128);
178 for (k = 0; k < nbLocated; ++k)
180 NL3D::CPSLocated *loc = dynamic_cast<NL3D::CPSLocated *>(ps->getProcess(k));
181 if (loc)
183 if (targetSet.find(loc) == targetSet.end())
185 int l = m_AvailableTargets.AddString(nlUtf8ToTStr(loc->getName()));
186 m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc);
191 const sint posX = 5;
192 sint posY = 180;
194 // collision zone case
196 if (dynamic_cast<NL3D::CPSZone *>(_LBTarget))
198 CCollisionZoneDlg *czd = new CCollisionZoneDlg(_Node, dynamic_cast<NL3D::CPSZone *>(_LBTarget), _ParticleDlg);
199 pushWnd(czd);
200 czd->init(posX, posY, this);
204 // force with intensity case
206 if (dynamic_cast<NL3D::CPSForceIntensity *>(_LBTarget))
208 _ForceIntensityWrapper.F = dynamic_cast<NL3D::CPSForceIntensity *>(_LBTarget);
209 CAttribDlgFloat *fi = new CAttribDlgFloat(std::string("FORCE INTENSITY"), _Node, 0, 100);
210 pushWnd(fi);
211 fi->setWrapper(&_ForceIntensityWrapper);
212 fi->setSchemeWrapper(&_ForceIntensityWrapper);
214 HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_FORCE_INTENSITY));
215 fi->init(bmh, posX, posY, this);
218 fi->GetClientRect(&r);
219 posY += r.bottom + 3;
222 // vortex (to tune viscosity)
223 if (dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget))
225 CEditableRangeFloat *rv = new CEditableRangeFloat(std::string("RADIAL_VISCOSITY"), _Node, 0, 1);
226 pushWnd(rv);
227 _RadialViscosityWrapper.V = dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget);
228 rv->setWrapper(&_RadialViscosityWrapper);
229 rv->init(posX + 140, posY, this);
230 CStatic *s = new CStatic;
231 pushWnd(s);
232 s->Create(_T("Radial viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this);
233 s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)));
234 s->ShowWindow(SW_SHOW);
237 rv->GetClientRect(&r);
238 posY += r.bottom + 3;
240 CEditableRangeFloat *tv = new CEditableRangeFloat(std::string("TANGENTIAL_VISCOSITY"), _Node, 0, 1);
241 pushWnd(tv);
242 _TangentialViscosityWrapper.V = dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget);
243 tv->setWrapper(&_TangentialViscosityWrapper);
244 tv->init(posX + 140, posY, this);
246 s = new CStatic;
247 pushWnd(s);
248 s->Create(_T("Tangential Viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this);
249 s->ShowWindow(SW_SHOW);
251 tv->GetClientRect(&r);
252 posY += r.bottom + 3;
255 // deals with emitters that have a direction
256 if (dynamic_cast<NL3D::CPSDirection *>(_LBTarget))
258 CDirectionAttr *da = new CDirectionAttr(std::string("DIRECTION"));
259 pushWnd(da);
260 _DirectionWrapper.E = dynamic_cast<NL3D::CPSDirection *>(_LBTarget);
261 da->setWrapper(&_DirectionWrapper);
262 da->setDirectionWrapper(dynamic_cast<NL3D::CPSDirection *>(_LBTarget));
263 da->init(posX, posY, this);
264 da->GetClientRect(&r);
265 posY += r.bottom;
268 // Brownian (to tune parametric factor)
269 if (dynamic_cast<NL3D::CPSBrownianForce *>(_LBTarget))
271 CEditableRangeFloat *rv = new CEditableRangeFloat(std::string("PARAMETRIC_FACTOR"), _Node, 0, 64);
272 pushWnd(rv);
273 _ParamFactorWrapper.F = static_cast<NL3D::CPSBrownianForce *>(_LBTarget);
274 rv->setWrapper(&_ParamFactorWrapper);
275 rv->init(posX + 140, posY, this);
276 CStatic *s = new CStatic;
277 pushWnd(s);
278 s->Create(_T("Parametric factor : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 40), this);
279 s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)));
280 s->ShowWindow(SW_SHOW);
282 rv->GetClientRect(&r);
283 posY += r.bottom + 3;
290 return TRUE; // return TRUE unless you set the focus to a control
291 // EXCEPTION: OCX Property Pages should return FALSE