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/>.
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)
35 _ER
= new CEditableRangeUInt("CHOOSE_FRAME_DELAY", NULL
, 0, 500);
36 _ER
->enableLowerBound(0, false);
37 _ER
->enableUpperBound(10000, false);
38 _ER
->setWrapper(&_CFDWrapper
);
40 objectViewer
->registerMainLoopCallBack(this);
43 CChooseFrameDelay::~CChooseFrameDelay()
46 CObjectViewer
*ov
= _CFDWrapper
.OV
;
47 ov
->removeMainLoopCallBack(this);
52 //*****************************************************************************************************
53 void CChooseFrameDelay::lockToPS(bool lock
)
55 if (lock
== _LockToPS
) return;
56 _ER
->EnableWindow(!lock
);
65 //*****************************************************************************************************
66 void CChooseFrameDelay::DoDataExchange(CDataExchange
* pDX
)
68 CDialog::DoDataExchange(pDX
);
69 //{{AFX_DATA_MAP(CChooseFrameDelay)
74 BEGIN_MESSAGE_MAP(CChooseFrameDelay
, CDialog
)
75 //{{AFX_MSG_MAP(CChooseFrameDelay)
80 /////////////////////////////////////////////////////////////////////////////
81 // CChooseFrameDelay message handlers
83 //*****************************************************************************************************
84 BOOL
CChooseFrameDelay::OnInitDialog()
86 CDialog::OnInitDialog();
88 GetDlgItem(IDC_FRAME_DELAY
)->GetWindowRect(&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
);