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 // tune_mrm_dlg.cpp : implementation file
21 #include "object_viewer.h"
22 #include "tune_mrm_dlg.h"
23 #include "main_frame.h"
25 /////////////////////////////////////////////////////////////////////////////
29 #define NL_TMD_SLIDER_SIZE 10000
30 #define NL_TMD_SLIDER_MAX_STEP 20
31 #define NL_TMD_SLIDER_STEP_SIZE 5000
34 CTuneMrmDlg::CTuneMrmDlg(CObjectViewer
*viewer
, NL3D::CScene
*scene
, CWnd
* pParent
/*=NULL*/)
35 : CDialog(CTuneMrmDlg::IDD
, pParent
), _ObjViewer(viewer
), _Scene(scene
)
37 //{{AFX_DATA_INIT(CTuneMrmDlg)
38 ViewCurrentMaxPoly
= _T("");
39 ViewMaxValue
= _T("");
43 CTuneMrmDlg::~CTuneMrmDlg()
47 void CTuneMrmDlg::DoDataExchange(CDataExchange
* pDX
)
49 CDialog::DoDataExchange(pDX
);
50 //{{AFX_DATA_MAP(CTuneMrmDlg)
51 DDX_Control(pDX
, IDC_TMD_SLIDER_MAX
, MaxValueSlider
);
52 DDX_Control(pDX
, IDC_TMD_SLIDER
, FaceSlider
);
53 DDX_Text(pDX
, IDC_TDM_STATIC
, ViewCurrentMaxPoly
);
54 DDX_Text(pDX
, IDC_TDM_STATIC_MAX
, ViewMaxValue
);
59 BEGIN_MESSAGE_MAP(CTuneMrmDlg
, CDialog
)
60 //{{AFX_MSG_MAP(CTuneMrmDlg)
62 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_TMD_SLIDER
, OnReleasedcaptureTmdSlider
)
64 ON_NOTIFY(NM_RELEASEDCAPTURE
, IDC_TMD_SLIDER_MAX
, OnReleasedcaptureTmdSliderMax
)
69 /////////////////////////////////////////////////////////////////////////////
70 // CTuneMrmDlg message handlers
72 BOOL
CTuneMrmDlg::OnInitDialog()
74 CDialog::OnInitDialog();
76 // init sliders ranges
77 FaceSlider
.SetRange(0, NL_TMD_SLIDER_SIZE
);
78 FaceSlider
.SetPos(NL_TMD_SLIDER_SIZE
);
79 MaxValueSlider
.SetRange(0, NL_TMD_SLIDER_MAX_STEP
);
80 MaxValueSlider
.SetPos(NL_TMD_SLIDER_MAX_STEP
);
83 applySlider(FaceSlider
.GetPos(), MaxValueSlider
.GetPos());
85 return TRUE
; // return TRUE unless you set the focus to a control
86 // EXCEPTION: OCX Property Pages should return FALSE
89 void CTuneMrmDlg::OnDestroy()
91 setRegisterWindowState (this, REGKEY_TUNE_MRM_DLG
);
95 void CTuneMrmDlg::OnHScroll(UINT nSBCode
, UINT nPos
, CScrollBar
* pScrollBar
)
98 if(nSBCode
==SB_THUMBPOSITION
|| nSBCode
==SB_THUMBTRACK
)
100 if(pScrollBar
->GetDlgCtrlID()==FaceSlider
.GetDlgCtrlID())
102 applySlider(nPos
, MaxValueSlider
.GetPos());
105 else if(pScrollBar
->GetDlgCtrlID()==MaxValueSlider
.GetDlgCtrlID())
107 applySlider(FaceSlider
.GetPos(), nPos
);
113 CDialog::OnHScroll(nSBCode
, nPos
, pScrollBar
);
116 void CTuneMrmDlg::OnReleasedcaptureTmdSlider(NMHDR
* pNMHDR
, LRESULT
* pResult
)
118 // Get value from slider
119 applySlider(FaceSlider
.GetPos(), MaxValueSlider
.GetPos());
123 void CTuneMrmDlg::OnReleasedcaptureTmdSliderMax(NMHDR
* pNMHDR
, LRESULT
* pResult
)
125 // Get value from slider
126 applySlider(FaceSlider
.GetPos(), MaxValueSlider
.GetPos());
130 void CTuneMrmDlg::applySlider(UINT sliderCur
, UINT sliderMax
)
132 nlctassert(NL_TMD_SLIDER_SIZE
*NL_TMD_SLIDER_MAX_STEP
*NL_TMD_SLIDER_STEP_SIZE
< ((uint
)1<<31));
133 // compute actual max polygon
134 uint actualValue
= sliderCur
*sliderMax
*NL_TMD_SLIDER_STEP_SIZE
/ NL_TMD_SLIDER_SIZE
;
138 _Scene
->setGroupLoadMaxPolygon("Skin", actualValue
);
141 // refresh text views
142 ViewCurrentMaxPoly
= NLMISC::toString(actualValue
).c_str();
143 ViewMaxValue
= NLMISC::toString(sliderMax
*NL_TMD_SLIDER_STEP_SIZE
).c_str();
150 void CTuneMrmDlg::OnClose()
152 _ObjViewer
->getMainFrame()->OnWindowTuneMRM();