Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / direction_attr.cpp
blobd72ef78d14ed8b424888c69621f975c610e72a86
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"
21 #include "object_viewer.h"
22 #include "direction_attr.h"
23 #include "direction_edit.h"
24 #include "choose_name.h"
25 #include "nel/3d/ps_direction.h"
26 #include "nel/3d/particle_system.h"
30 /////////////////////////////////////////////////////////////////////////////
31 // CDirectionAttr dialog
32 CDirectionAttr::CDirectionAttr(const std::string &id): _DirectionDlg(NULL), _Wrapper(NULL), _DirectionWrapper(NULL)
34 //{{AFX_DATA_INIT(CDirectionAttr)
35 // NOTE: the ClassWizard will add member initialization here
36 //}}AFX_DATA_INIT
39 //=======================================================================================
40 void CDirectionAttr::init(uint32 x, uint32 y, CWnd *pParent)
42 Create(IDD_DIRECTION_ATTR, pParent);
43 RECT r;
44 GetClientRect(&r);
45 CRect wr;
46 wr.left = r.left + x;
47 wr.top = r.top + y;
48 wr.bottom = r.bottom + y;
49 wr.right = r.right + x;
50 MoveWindow(wr);
51 if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue())
53 GetDlgItem(IDC_GLOBAL_DIRECTION)->ShowWindow(TRUE);
55 EnableWindow(TRUE);
56 ShowWindow(SW_SHOW);
60 //=======================================================================================
61 void CDirectionAttr::DoDataExchange(CDataExchange* pDX)
63 CDialog::DoDataExchange(pDX);
64 //{{AFX_DATA_MAP(CDirectionAttr)
65 // NOTE: the ClassWizard will add DDX and DDV calls here
66 //}}AFX_DATA_MAP
70 BEGIN_MESSAGE_MAP(CDirectionAttr, CDialog)
71 //{{AFX_MSG_MAP(CDirectionAttr)
72 ON_BN_CLICKED(IDC_VECT_I, OnVectI)
73 ON_BN_CLICKED(IDC_VECT_J, OnVectJ)
74 ON_BN_CLICKED(IDC_VECT_K, OnVectK)
75 ON_BN_CLICKED(IDC_VECT_MINUS_I, OnVectMinusI)
76 ON_BN_CLICKED(IDC_VECT_MINUS_J, OnVectMinusJ)
77 ON_BN_CLICKED(IDC_VECT_MINUS_K, OnVectMinusK)
78 ON_BN_CLICKED(IDC_CUSTOM_DIRECTION, OnCustomDirection)
79 ON_WM_DESTROY()
80 ON_BN_CLICKED(IDC_GLOBAL_DIRECTION, OnGlobalDirection)
81 //}}AFX_MSG_MAP
82 END_MESSAGE_MAP()
84 /////////////////////////////////////////////////////////////////////////////
85 // CDirectionAttr message handlers
88 //=======================================================================================
89 void CDirectionAttr::OnVectI()
91 nlassert(_Wrapper);
92 _Wrapper->setAndUpdateModifiedFlag(NLMISC::CVector::I);
95 //=======================================================================================
96 void CDirectionAttr::OnVectJ()
98 nlassert(_Wrapper);
99 _Wrapper->setAndUpdateModifiedFlag(NLMISC::CVector::J);
102 //=======================================================================================
103 void CDirectionAttr::OnVectK()
105 _Wrapper->setAndUpdateModifiedFlag(NLMISC::CVector::K);
108 //=======================================================================================
109 void CDirectionAttr::OnVectMinusI()
111 _Wrapper->setAndUpdateModifiedFlag( - NLMISC::CVector::I);
114 //=======================================================================================
115 void CDirectionAttr::OnVectMinusJ()
117 _Wrapper->setAndUpdateModifiedFlag(- NLMISC::CVector::J);
120 //=======================================================================================
121 void CDirectionAttr::OnVectMinusK()
123 _Wrapper->setAndUpdateModifiedFlag(- NLMISC::CVector::K);
126 //=======================================================================================
127 BOOL CDirectionAttr::EnableWindow(BOOL bEnable)
129 BOOL enableUserDirection = TRUE;
130 if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue() && !_DirectionWrapper->getGlobalVectorValueName().empty())
132 enableUserDirection = FALSE;
134 GetDlgItem(IDC_VECT_I)->EnableWindow(bEnable & enableUserDirection);
135 GetDlgItem(IDC_VECT_J)->EnableWindow(bEnable & enableUserDirection);
136 GetDlgItem(IDC_VECT_K)->EnableWindow(bEnable & enableUserDirection);
137 GetDlgItem(IDC_VECT_MINUS_I)->EnableWindow(bEnable & enableUserDirection);
138 GetDlgItem(IDC_VECT_MINUS_J)->EnableWindow(bEnable & enableUserDirection);
139 GetDlgItem(IDC_VECT_MINUS_K)->EnableWindow(bEnable & enableUserDirection);
140 GetDlgItem(IDC_CUSTOM_DIRECTION)->EnableWindow(bEnable & enableUserDirection);
141 GetDlgItem(IDC_DIRECTION_TEXT)->EnableWindow(bEnable & enableUserDirection);
142 GetDlgItem(IDC_GLOBAL_DIRECTION)->EnableWindow(bEnable);
143 return CEditAttribDlg::EnableWindow(bEnable);
146 //=======================================================================================
147 void CDirectionAttr::OnCustomDirection()
149 _DirectionDlg = new CDirectionEdit(_Wrapper);
150 _DirectionDlg->init(this, this);
151 EnableWindow(FALSE);
154 //=======================================================================================
155 void CDirectionAttr::childPopupClosed(CWnd *)
157 _DirectionDlg->DestroyWindow();
158 delete _DirectionDlg;
159 _DirectionDlg = NULL;
160 EnableWindow(TRUE);
164 //=======================================================================================
165 void CDirectionAttr::OnDestroy()
167 CDialog::OnDestroy();
168 if (_DirectionDlg)
170 _DirectionDlg->DestroyWindow();
172 delete _DirectionDlg;
175 //=======================================================================================
176 void CDirectionAttr::OnGlobalDirection()
178 nlassert(_DirectionWrapper);
179 CChooseName chooseName(nlUtf8ToTStr(_DirectionWrapper->getGlobalVectorValueName()));
181 if (chooseName.DoModal() == IDOK)
183 _DirectionWrapper->enableGlobalVectorValue(chooseName.getName());
184 if (!chooseName.getName().empty())
186 NL3D::CParticleSystem::setGlobalVectorValue(chooseName.getName(), NLMISC::CVector::I); // take a non NULL value for the direction
189 EnableWindow(TRUE);