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 // global_wind_dlg.cpp : implementation file
22 #include "object_viewer.h"
23 #include "global_wind_dlg.h"
26 #define NL_GLOBAL_WIND_SLIDER_RANGE 1000
28 /////////////////////////////////////////////////////////////////////////////
29 // CGlobalWindDlg dialog
32 CGlobalWindDlg::CGlobalWindDlg(CObjectViewer
*objViewer
, CWnd
* pParent
/*=NULL*/)
33 : CDialog(CGlobalWindDlg::IDD
, pParent
), _ObjViewer(objViewer
)
35 //{{AFX_DATA_INIT(CGlobalWindDlg)
36 // NOTE: the ClassWizard will add member initialization here
41 void CGlobalWindDlg::DoDataExchange(CDataExchange
* pDX
)
43 CDialog::DoDataExchange(pDX
);
44 //{{AFX_DATA_MAP(CGlobalWindDlg)
45 DDX_Control(pDX
, IDC_STATIC_GLOBAL_WIND_POWER
, StaticPower
);
46 DDX_Control(pDX
, IDC_SLIDER_GLOBAL_WIND_POWER
, SliderPower
);
51 BEGIN_MESSAGE_MAP(CGlobalWindDlg
, CDialog
)
52 //{{AFX_MSG_MAP(CGlobalWindDlg)
53 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_SLIDER_GLOBAL_WIND_POWER
, OnReleasedcaptureSliderGlobalWindPower
)
60 // ***************************************************************************
61 void CGlobalWindDlg::updateView()
67 a
= _ObjViewer
->getGlobalWindPower();
68 _stprintf(str
, _T("%.2f"), a
);
69 StaticPower
.SetWindowText(str
);
70 NLMISC::clamp(a
, 0.f
, 1.f
);
71 SliderPower
.SetPos((sint
)(a
*NL_GLOBAL_WIND_SLIDER_RANGE
));
74 // ***************************************************************************
75 // ***************************************************************************
76 // CVegetableWindDlg message handlers
77 // ***************************************************************************
78 // ***************************************************************************
81 // ***************************************************************************
82 BOOL
CGlobalWindDlg::OnInitDialog()
84 CDialog::OnInitDialog();
86 SliderPower
.SetRange(0, NL_GLOBAL_WIND_SLIDER_RANGE
);
88 // Init them and static.
91 return TRUE
; // return TRUE unless you set the focus to a control
92 // EXCEPTION: OCX Property Pages should return FALSE
95 // ***************************************************************************
96 void CGlobalWindDlg::OnReleasedcaptureSliderGlobalWindPower(NMHDR
* pNMHDR
, LRESULT
* pResult
)
99 a
= (float)SliderPower
.GetPos() / NL_GLOBAL_WIND_SLIDER_RANGE
;
100 _ObjViewer
->setGlobalWindPower(a
);
108 // ***************************************************************************
109 void CGlobalWindDlg::OnHScroll(UINT nSBCode
, UINT nPos
, CScrollBar
* pScrollBar
)
111 // test if one of my sliders.
112 CSliderCtrl
*sliderCtrl
= (CSliderCtrl
*)pScrollBar
;
113 if( sliderCtrl
==&SliderPower
&& nSBCode
==SB_THUMBPOSITION
|| nSBCode
==SB_THUMBTRACK
)
118 a
= (float)nPos
/ NL_GLOBAL_WIND_SLIDER_RANGE
;
119 _ObjViewer
->setGlobalWindPower(a
);
120 _stprintf(str
, _T("%.2f"), a
);
121 StaticPower
.SetWindowText(str
);
125 CDialog::OnHScroll(nSBCode
, nPos
, pScrollBar
);
129 void CGlobalWindDlg::OnDestroy()
131 setRegisterWindowState (this, REGKEY_OBJ_GLOBAL_WIND_DLG
);
133 CDialog::OnDestroy();