Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / 3d / object_viewer / tune_mrm_dlg.cpp
blob4814d37ff07e3bd2957b79a2edd02142f9318e49
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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
20 #include "std_afx.h"
21 #include "object_viewer.h"
22 #include "tune_mrm_dlg.h"
23 #include "main_frame.h"
25 /////////////////////////////////////////////////////////////////////////////
26 // CTuneMrmDlg dialog
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("");
40 //}}AFX_DATA_INIT
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);
55 //}}AFX_DATA_MAP
59 BEGIN_MESSAGE_MAP(CTuneMrmDlg, CDialog)
60 //{{AFX_MSG_MAP(CTuneMrmDlg)
61 ON_WM_DESTROY()
62 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_TMD_SLIDER, OnReleasedcaptureTmdSlider)
63 ON_WM_HSCROLL()
64 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_TMD_SLIDER_MAX, OnReleasedcaptureTmdSliderMax)
65 ON_WM_CLOSE()
66 //}}AFX_MSG_MAP
67 END_MESSAGE_MAP()
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);
82 // init scene/texts
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);
92 CDialog::OnDestroy();
95 void CTuneMrmDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
97 bool handled= false;
98 if(nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK)
100 if(pScrollBar->GetDlgCtrlID()==FaceSlider.GetDlgCtrlID())
102 applySlider(nPos, MaxValueSlider.GetPos());
103 handled= true;
105 else if(pScrollBar->GetDlgCtrlID()==MaxValueSlider.GetDlgCtrlID())
107 applySlider(FaceSlider.GetPos(), nPos);
108 handled= true;
112 if(!handled)
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());
120 *pResult = 0;
123 void CTuneMrmDlg::OnReleasedcaptureTmdSliderMax(NMHDR* pNMHDR, LRESULT* pResult)
125 // Get value from slider
126 applySlider(FaceSlider.GetPos(), MaxValueSlider.GetPos());
127 *pResult = 0;
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;
136 if(_Scene)
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();
145 UpdateData(FALSE);
150 void CTuneMrmDlg::OnClose()
152 _ObjViewer->getMainFrame()->OnWindowTuneMRM();