Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / choose_frame_delay.cpp
blobb7691b8952c1c4207996a3141832197cbd93fdb5
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 #include "std_afx.h"
18 #include "object_viewer.h"
19 #include "choose_frame_delay.h"
20 #include "particle_dlg.h"
21 #include "nel/3d/particle_system.h"
23 /////////////////////////////////////////////////////////////////////////////
24 // CChooseFrameDelay dialog
27 //*****************************************************************************************************
28 CChooseFrameDelay::CChooseFrameDelay(CObjectViewer *objectViewer, CWnd* pParent)
29 : CDialog(CChooseFrameDelay::IDD, pParent), _LockToPS(false)
31 nlassert(objectViewer);
32 _CFDWrapper.OV = objectViewer;
33 //{{AFX_DATA_INIT(CChooseFrameDelay)
34 //}}AFX_DATA_INIT
35 _ER = new CEditableRangeUInt("CHOOSE_FRAME_DELAY", NULL, 0, 500);
36 _ER->enableLowerBound(0, false);
37 _ER->enableUpperBound(10000, false);
38 _ER->setWrapper(&_CFDWrapper);
39 //
40 objectViewer->registerMainLoopCallBack(this);
43 CChooseFrameDelay::~CChooseFrameDelay()
45 lockToPS(false);
46 CObjectViewer *ov = _CFDWrapper.OV;
47 ov->removeMainLoopCallBack(this);
48 _ER->DestroyWindow();
49 delete _ER;
52 //*****************************************************************************************************
53 void CChooseFrameDelay::lockToPS(bool lock)
55 if (lock == _LockToPS) return;
56 _ER->EnableWindow(!lock);
57 _LockToPS = lock;
58 if (!lock)
60 _CFDWrapper.set(0);
61 _ER->update();
65 //*****************************************************************************************************
66 void CChooseFrameDelay::DoDataExchange(CDataExchange* pDX)
68 CDialog::DoDataExchange(pDX);
69 //{{AFX_DATA_MAP(CChooseFrameDelay)
70 //}}AFX_DATA_MAP
74 BEGIN_MESSAGE_MAP(CChooseFrameDelay, CDialog)
75 //{{AFX_MSG_MAP(CChooseFrameDelay)
76 ON_WM_DESTROY()
77 //}}AFX_MSG_MAP
78 END_MESSAGE_MAP()
80 /////////////////////////////////////////////////////////////////////////////
81 // CChooseFrameDelay message handlers
83 //*****************************************************************************************************
84 BOOL CChooseFrameDelay::OnInitDialog()
86 CDialog::OnInitDialog();
87 RECT r;
88 GetDlgItem(IDC_FRAME_DELAY)->GetWindowRect(&r);
89 ScreenToClient(&r);
90 _ER->init(r.left, r.top, this);
91 return TRUE; // return TRUE unless you set the focus to a control
92 // EXCEPTION: OCX Property Pages should return FALSE
95 uint32 CChooseFrameDelay::CCFDWrapper::get(void) const { return OV->getFrameDelay(); }
96 void CChooseFrameDelay::CCFDWrapper::set(const uint32 &value) { OV->setFrameDelay(value); }
98 //*****************************************************************************************************
99 void CChooseFrameDelay::OnDestroy()
101 setRegisterWindowState (this, REGKEY_CHOOSE_FRAME_DELAY_DLG);
102 CDialog::OnDestroy();
105 //*****************************************************************************************************
106 void CChooseFrameDelay::goPreRender()
108 CObjectViewer *ov = _CFDWrapper.OV;
109 if (_LockToPS && ov->getParticleDialog()->getActiveNode())
111 CParticleWorkspace::CNode *activeNode = ov->getParticleDialog()->getActiveNode();
112 nlassert(activeNode->isLoaded());
113 // get integration step from ps
114 CObjectViewer *ov = _CFDWrapper.OV;
115 NL3D::CParticleSystem *ps = activeNode->getPSPointer();
116 uint integrationTime = (uint) (1000.f * ps->getTimeTheshold());
117 if (!ps->getBypassMaxNumIntegrationSteps())
119 integrationTime *= ps->getMaxNbIntegrations();
121 if (integrationTime != _CFDWrapper.get())
123 _CFDWrapper.set(integrationTime);
124 _ER->update();