1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
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 // vegetable_wind_dlg.cpp : implementation file
24 #include "object_viewer.h"
25 #include "vegetable_wind_dlg.h"
26 #include "object_viewer.h"
29 #define NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE 1000
30 #define NL_VEGETABLE_EDIT_WIND_MAX_POWER 10.f
31 #define NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY 10.f
32 #define NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART 1.f
34 /////////////////////////////////////////////////////////////////////////////
35 // CVegetableWindDlg dialog
38 CVegetableWindDlg::CVegetableWindDlg(CObjectViewer
*objViewer
, CWnd
* pParent
/*=NULL*/)
39 : CDialog(CVegetableWindDlg::IDD
, pParent
), _ObjViewer(objViewer
)
41 //{{AFX_DATA_INIT(CVegetableWindDlg)
42 // NOTE: the ClassWizard will add member initialization here
47 void CVegetableWindDlg::DoDataExchange(CDataExchange
* pDX
)
49 CDialog::DoDataExchange(pDX
);
50 //{{AFX_DATA_MAP(CVegetableWindDlg)
51 DDX_Control(pDX
, IDC_STATIC_VEGETABLE_WIND_POWER
, StaticPower
);
52 DDX_Control(pDX
, IDC_STATIC_VEGETABLE_WIND_FREQUENCY
, StaticFrequency
);
53 DDX_Control(pDX
, IDC_STATIC_VEGETABLE_WIND_BENDSTART
, StaticBendStart
);
54 DDX_Control(pDX
, IDC_SLIDER_VEGETABLE_WIND_POWER
, SliderPower
);
55 DDX_Control(pDX
, IDC_SLIDER_VEGETABLE_WIND_FREQUENCY
, SliderFrequency
);
56 DDX_Control(pDX
, IDC_SLIDER_VEGETABLE_WIND_BENDSTART
, SliderBendStart
);
61 BEGIN_MESSAGE_MAP(CVegetableWindDlg
, CDialog
)
62 //{{AFX_MSG_MAP(CVegetableWindDlg)
63 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_SLIDER_VEGETABLE_WIND_BENDSTART
, OnReleasedcaptureSliderVegetableWindBendstart
)
64 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_SLIDER_VEGETABLE_WIND_FREQUENCY
, OnReleasedcaptureSliderVegetableWindFrequency
)
65 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_SLIDER_VEGETABLE_WIND_POWER
, OnReleasedcaptureSliderVegetableWindPower
)
66 ON_BN_CLICKED(IDC_BUTTON_CLOSE
, OnButtonClose
)
72 // ***************************************************************************
73 void CVegetableWindDlg::updateView()
78 a
= _ObjViewer
->getVegetableWindPower();
79 StaticPower
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
80 NLMISC::clamp(a
, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER
);
81 SliderPower
.SetPos((sint
)(a
*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
/ NL_VEGETABLE_EDIT_WIND_MAX_POWER
));
84 a
= _ObjViewer
->getVegetableWindBendStart();
85 StaticBendStart
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
86 NLMISC::clamp(a
, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART
);
87 SliderBendStart
.SetPos((sint
)(a
*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
/ NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART
));
90 a
= _ObjViewer
->getVegetableWindFrequency();
91 StaticFrequency
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
92 NLMISC::clamp(a
, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY
);
93 SliderFrequency
.SetPos((sint
)(a
*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
/ NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY
));
97 // ***************************************************************************
98 // ***************************************************************************
99 // CVegetableWindDlg message handlers
100 // ***************************************************************************
101 // ***************************************************************************
104 // ***************************************************************************
105 BOOL
CVegetableWindDlg::OnInitDialog()
107 CDialog::OnInitDialog();
109 SliderPower
.SetRange(0, NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
);
110 SliderBendStart
.SetRange(0, NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
);
111 SliderFrequency
.SetRange(0, NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
);
113 // Init them and static.
116 return TRUE
; // return TRUE unless you set the focus to a control
117 // EXCEPTION: OCX Property Pages should return FALSE
122 // ***************************************************************************
123 void CVegetableWindDlg::OnHScroll(UINT nSBCode
, UINT nPos
, CScrollBar
* pScrollBar
)
125 // test if one of my sliders.
126 CSliderCtrl
*sliderCtrl
= (CSliderCtrl
*)pScrollBar
;
127 if( (sliderCtrl
==&SliderPower
|| sliderCtrl
==&SliderBendStart
|| sliderCtrl
==&SliderFrequency
)
128 && nSBCode
==SB_THUMBPOSITION
|| nSBCode
==SB_THUMBTRACK
)
131 if(sliderCtrl
== &SliderPower
)
133 a
= (float)nPos
* NL_VEGETABLE_EDIT_WIND_MAX_POWER
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
134 _ObjViewer
->setVegetableWindPower(a
);
135 StaticPower
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
137 else if(sliderCtrl
== &SliderBendStart
)
139 a
= (float)nPos
* NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
140 _ObjViewer
->setVegetableWindBendStart(a
);
141 StaticBendStart
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
143 else if(sliderCtrl
== &SliderFrequency
)
146 a
= (float)nPos
* NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
147 _ObjViewer
->setVegetableWindFrequency(a
);
148 StaticFrequency
.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a
)));
153 CDialog::OnHScroll(nSBCode
, nPos
, pScrollBar
);
157 // ***************************************************************************
158 void CVegetableWindDlg::OnReleasedcaptureSliderVegetableWindPower(NMHDR
* pNMHDR
, LRESULT
* pResult
)
161 a
= (float)SliderPower
.GetPos() * NL_VEGETABLE_EDIT_WIND_MAX_POWER
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
162 _ObjViewer
->setVegetableWindPower(a
);
170 // ***************************************************************************
171 void CVegetableWindDlg::OnReleasedcaptureSliderVegetableWindBendstart(NMHDR
* pNMHDR
, LRESULT
* pResult
)
174 a
= (float)SliderBendStart
.GetPos() * NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
175 _ObjViewer
->setVegetableWindBendStart(a
);
183 // ***************************************************************************
184 void CVegetableWindDlg::OnReleasedcaptureSliderVegetableWindFrequency(NMHDR
* pNMHDR
, LRESULT
* pResult
)
187 a
= (float)SliderFrequency
.GetPos() * NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY
/ NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE
;
188 _ObjViewer
->setVegetableWindFrequency(a
);
198 // ***************************************************************************
199 void CVegetableWindDlg::OnButtonClose()