2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/AFEditor_resource.h"
35 #include "DialogAFProperties.h"
36 #include "DialogAFBody.h"
37 #include "DialogAFConstraint.h"
40 // DialogAFProperties dialog
42 toolTip_t DialogAFProperties::toolTips[] = {
43 { IDC_EDIT_MODEL, "model def" },
44 { IDC_BUTTON_BROWSE_MODEL, "browse model def" },
45 { IDC_EDIT_SKIN, "skin" },
46 { IDC_BUTTON_BROWSE_SKIN, "browse skin" },
47 { IDC_EDIT_LINEARFRICTION, "translational friction" },
48 { IDC_EDIT_ANGULARFRICTION, "rotational friction" },
49 { IDC_EDIT_CONTACTFRICTION, "friction with contact surfaces" },
50 { IDC_EDIT_CONSTRAINTFRICTION, "constraint friction" },
51 { IDC_CHECK_SELFCOLLISION, "allow bodies to collide with other bodies of this articulated figure" },
52 { IDC_EDIT_CONTENTS, "content of bodies" },
53 { IDC_EDIT_CLIPMASK, "collide with these content types" },
54 { IDC_EDIT_TOTALMASS, "scale the mass of each body to get this total mass" },
55 { IDC_EDIT_LINEARVELOCITY, "do not suspend simulation if the linear velocity is higher than this value" },
56 { IDC_EDIT_ANGULARVELOCITY, "do not suspend simulation if the angular velocity is higher than this value" },
57 { IDC_EDIT_LINEARACCELERATION, "do not suspend simulation if the linear acceleration is higher than this value" },
58 { IDC_EDIT_ANGULARACCELERATION, "do not suspend simulation if the angular acceleration is higher than this value" },
59 { IDC_EDIT_NO_MOVE_TIME, "suspend simulation if hardly any movement for this many seconds" },
60 { IDC_EDIT_MAXIMUM_MOVE_TIME, "always suspend simulation after running for this many seconds" },
61 { IDC_EDIT_LINEAR_TOLERANCE, "maximum translation considered no movement" },
62 { IDC_EDIT_ANGULAR_TOLERANCE, "maximum rotation considered no movement" },
66 IMPLEMENT_DYNAMIC(DialogAFProperties, CDialog)
70 DialogAFProperties::DialogAFProperties
73 DialogAFProperties::DialogAFProperties(CWnd* pParent /*=NULL*/)
74 : CDialog(DialogAFProperties::IDD, pParent)
75 , m_selfCollision(false)
77 , m_angularFriction(0)
78 , m_contactFriction(0)
79 , m_constraintFriction(0)
81 , m_suspendLinearVelocity(0)
82 , m_suspendAngularVelocity(0)
83 , m_suspendLinearAcceleration(0)
84 , m_suspendAngularAcceleration(0)
88 , m_linearTolerance(0)
89 , m_angularTolerance(0)
92 Create( IDD_DIALOG_AF_PROPERTIES, pParent );
93 EnableToolTips( TRUE );
98 DialogAFProperties::~DialogAFProperties
101 DialogAFProperties::~DialogAFProperties() {
106 DialogAFProperties::DoDataExchange
109 void DialogAFProperties::DoDataExchange(CDataExchange* pDX) {
110 CDialog::DoDataExchange(pDX);
111 //{{AFX_DATA_MAP(DialogAFProperties)
112 DDX_Control(pDX, IDC_EDIT_MODEL, m_editModel);
113 DDX_Control(pDX, IDC_EDIT_SKIN, m_editSkin);
114 DDX_Check(pDX, IDC_CHECK_SELFCOLLISION, m_selfCollision);
115 DDX_Control(pDX, IDC_EDIT_CONTENTS, m_editContents);
116 DDX_Control(pDX, IDC_EDIT_CLIPMASK, m_editClipMask);
117 DDX_Text(pDX, IDC_EDIT_LINEARFRICTION, m_linearFriction);
118 DDX_Text(pDX, IDC_EDIT_ANGULARFRICTION, m_angularFriction);
119 DDX_Text(pDX, IDC_EDIT_CONTACTFRICTION, m_contactFriction);
120 DDX_Text(pDX, IDC_EDIT_CONSTRAINTFRICTION, m_constraintFriction);
121 DDX_Text(pDX, IDC_EDIT_TOTALMASS, m_totalMass);
122 DDX_Text(pDX, IDC_EDIT_LINEARVELOCITY, m_suspendLinearVelocity);
123 DDX_Text(pDX, IDC_EDIT_ANGULARVELOCITY, m_suspendAngularVelocity);
124 DDX_Text(pDX, IDC_EDIT_LINEARACCELERATION, m_suspendLinearAcceleration);
125 DDX_Text(pDX, IDC_EDIT_ANGULARACCELERATION, m_suspendAngularAcceleration);
126 DDX_Text(pDX, IDC_EDIT_NO_MOVE_TIME, m_noMoveTime);
127 DDX_Text(pDX, IDC_EDIT_MINIMUM_MOVE_TIME, m_minMoveTime);
128 DDX_Text(pDX, IDC_EDIT_MAXIMUM_MOVE_TIME, m_maxMoveTime);
129 DDX_Text(pDX, IDC_EDIT_LINEAR_TOLERANCE, m_linearTolerance);
130 DDX_Text(pDX, IDC_EDIT_ANGULAR_TOLERANCE, m_angularTolerance);
136 DialogAFProperties::LoadFile
139 void DialogAFProperties::LoadFile( idDeclAF *af ) {
148 m_editModel.SetWindowText( file->model.c_str() );
149 m_editSkin.SetWindowText( file->skin.c_str() );
150 m_selfCollision = file->selfCollision;
151 idDeclAF::ContentsToString( file->contents, str );
152 m_editContents.SetWindowText( str );
153 idDeclAF::ContentsToString( file->clipMask, str );
154 m_editClipMask.SetWindowText( str );
155 m_linearFriction = file->defaultLinearFriction;
156 m_angularFriction = file->defaultAngularFriction;
157 m_contactFriction = file->defaultContactFriction;
158 m_constraintFriction = file->defaultConstraintFriction;
159 m_totalMass = file->totalMass;
160 m_suspendLinearVelocity = file->suspendVelocity[0];
161 m_suspendAngularVelocity = file->suspendVelocity[1];
162 m_suspendLinearAcceleration = file->suspendAcceleration[0];
163 m_suspendAngularAcceleration = file->suspendAcceleration[1];
164 m_noMoveTime = file->noMoveTime;
165 m_minMoveTime = file->minMoveTime;
166 m_maxMoveTime = file->maxMoveTime;
167 m_linearTolerance = file->noMoveTranslation;
168 m_angularTolerance = file->noMoveRotation;
174 DialogAFProperties::SetFile
177 void DialogAFProperties::SaveFile( void ) {
184 m_editModel.GetWindowText( str );
186 m_editSkin.GetWindowText( str );
188 file->selfCollision = ( m_selfCollision != FALSE );
189 m_editContents.GetWindowText( str );
190 file->contents = idDeclAF::ContentsFromString( str );
191 m_editClipMask.GetWindowText( str );
192 file->clipMask = idDeclAF::ContentsFromString( str );
193 file->defaultLinearFriction = m_linearFriction;
194 file->defaultAngularFriction = m_angularFriction;
195 file->defaultContactFriction = m_contactFriction;
196 file->defaultConstraintFriction = m_constraintFriction;
197 file->totalMass = m_totalMass;
198 file->suspendVelocity[0] = m_suspendLinearVelocity;
199 file->suspendVelocity[1] = m_suspendAngularVelocity;
200 file->suspendAcceleration[0] = m_suspendLinearAcceleration;
201 file->suspendAcceleration[1] = m_suspendAngularAcceleration;
202 file->noMoveTime = m_noMoveTime;
203 file->minMoveTime = m_minMoveTime;
204 file->maxMoveTime = m_maxMoveTime;
205 file->noMoveTranslation = m_linearTolerance;
206 file->noMoveRotation = m_angularTolerance;
208 AFDialogSetFileModified();
213 DialogAFProperties::UpdateFile
216 void DialogAFProperties::UpdateFile( void ) {
219 gameEdit->AF_UpdateEntities( file->GetName() );
225 DialogAFProperties::ClearFile
228 void DialogAFProperties::ClearFile( void ) {
229 m_editModel.SetWindowText( "" );
230 m_editSkin.SetWindowText( "" );
231 m_selfCollision = false;
232 m_editContents.SetWindowText( "" );
233 m_editClipMask.SetWindowText( "" );
234 m_linearFriction = 0.0f;
235 m_angularFriction = 0.0f;
236 m_contactFriction = 0.0f;
237 m_constraintFriction = 0.0f;
239 m_suspendLinearVelocity = 0.0f;
240 m_suspendAngularVelocity = 0.0f;
241 m_suspendLinearAcceleration = 0.0f;
242 m_suspendAngularAcceleration = 0.0f;
244 m_minMoveTime = 0.0f;
245 m_maxMoveTime = 0.0f;
246 m_linearTolerance = 0.0f;
247 m_angularTolerance = 0.0f;
253 DialogAFProperties::OnToolHitTest
256 int DialogAFProperties::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
257 CDialog::OnToolHitTest( point, pTI );
258 return DefaultOnToolHitTest( toolTips, this, point, pTI );
261 BEGIN_MESSAGE_MAP(DialogAFProperties, CDialog)
262 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
263 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
264 ON_EN_CHANGE(IDC_EDIT_MODEL, OnEnChangeEditModel)
265 ON_BN_CLICKED(IDC_BUTTON_BROWSE_MODEL, OnBnClickedButtonBrowseModel)
266 ON_EN_CHANGE(IDC_EDIT_SKIN, OnEnChangeEditSkin)
267 ON_BN_CLICKED(IDC_BUTTON_BROWSE_SKIN, OnBnClickedButtonBrowseSkin)
268 ON_EN_CHANGE(IDC_EDIT_LINEARFRICTION, OnEnChangeEditLinearfriction)
269 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_LINEARFRICTION, OnDeltaposSpinLinearfriction)
270 ON_EN_CHANGE(IDC_EDIT_ANGULARFRICTION, OnEnChangeEditAngularfriction)
271 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANGULARFRICTION, OnDeltaposSpinAngularfriction)
272 ON_EN_CHANGE(IDC_EDIT_CONTACTFRICTION, OnEnChangeEditContactfriction)
273 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONTACTFRICTION, OnDeltaposSpinContactfriction)
274 ON_EN_CHANGE(IDC_EDIT_CONSTRAINTFRICTION, OnEnChangeEditConstraintfriction)
275 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONSTRAINTFRICTION, OnDeltaposSpinConstraintfriction)
276 ON_BN_CLICKED(IDC_CHECK_SELFCOLLISION, OnBnClickedCheckSelfcollision)
277 ON_EN_CHANGE(IDC_EDIT_CONTENTS, OnEnChangeEditContents)
278 ON_EN_CHANGE(IDC_EDIT_CLIPMASK, OnEnChangeEditClipmask)
279 ON_EN_CHANGE(IDC_EDIT_TOTALMASS, OnEnChangeEditTotalmass)
280 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_TOTALMASS, OnDeltaposSpinTotalmass)
281 ON_EN_CHANGE(IDC_EDIT_LINEARVELOCITY, OnEnChangeEditLinearvelocity)
282 ON_EN_CHANGE(IDC_EDIT_ANGULARVELOCITY, OnEnChangeEditAngularvelocity)
283 ON_EN_CHANGE(IDC_EDIT_LINEARACCELERATION, OnEnChangeEditLinearacceleration)
284 ON_EN_CHANGE(IDC_EDIT_ANGULARACCELERATION, OnEnChangeEditAngularacceleration)
285 ON_EN_CHANGE(IDC_EDIT_NO_MOVE_TIME, OnEnChangeEditNomovetime)
286 ON_EN_CHANGE(IDC_EDIT_MINIMUM_MOVE_TIME, OnEnChangeEditMinimummovetime)
287 ON_EN_CHANGE(IDC_EDIT_MAXIMUM_MOVE_TIME, OnEnChangeEditMaximummovetime)
288 ON_EN_CHANGE(IDC_EDIT_LINEAR_TOLERANCE, OnEnChangeEditLineartolerance)
289 ON_EN_CHANGE(IDC_EDIT_ANGULAR_TOLERANCE, OnEnChangeEditAngulartolerance)
293 // DialogAFProperties message handlers
295 BOOL DialogAFProperties::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
296 return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
299 void DialogAFProperties::OnEnChangeEditModel() {
300 if ( EditControlEnterHit( &m_editModel ) ) {
305 void DialogAFProperties::OnEnChangeEditSkin() {
306 if ( EditControlEnterHit( &m_editSkin ) ) {
308 // reload the .af file
309 AFDialogReloadFile();
313 void DialogAFProperties::OnBnClickedCheckSelfcollision() {
315 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Self Collision", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
316 for ( int i = 0; i < file->bodies.Num(); i++ ) {
317 file->bodies[i]->selfCollision = file->selfCollision;
319 bodyDlg->LoadFile( file );
323 void DialogAFProperties::OnEnChangeEditContents() {
324 if ( EditControlEnterHit( &m_editContents ) ) {
326 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contents", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
327 for ( int i = 0; i < file->bodies.Num(); i++ ) {
328 file->bodies[i]->contents = file->contents;
330 bodyDlg->LoadFile( file );
335 void DialogAFProperties::OnEnChangeEditClipmask() {
336 if ( EditControlEnterHit( &m_editClipMask ) ) {
338 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Clip Mask", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
339 for ( int i = 0; i < file->bodies.Num(); i++ ) {
340 file->bodies[i]->clipMask = file->clipMask;
342 bodyDlg->LoadFile( file );
347 void DialogAFProperties::OnEnChangeEditLinearfriction() {
348 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ) ) ) {
350 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Linear Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
351 for ( int i = 0; i < file->bodies.Num(); i++ ) {
352 file->bodies[i]->linearFriction = file->defaultLinearFriction;
354 bodyDlg->LoadFile( file );
358 m_linearFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ), false );
362 void DialogAFProperties::OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult) {
363 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
364 m_linearFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_LINEARFRICTION ), pNMUpDown->iDelta < 0 );
369 void DialogAFProperties::OnEnChangeEditAngularfriction() {
370 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ) ) ) {
372 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Angular Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
373 for ( int i = 0; i < file->bodies.Num(); i++ ) {
374 file->bodies[i]->angularFriction = file->defaultAngularFriction;
376 bodyDlg->LoadFile( file );
380 m_angularFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ), false );
384 void DialogAFProperties::OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult) {
385 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
386 m_angularFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_ANGULARFRICTION ), pNMUpDown->iDelta < 0 );
391 void DialogAFProperties::OnEnChangeEditContactfriction() {
392 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ) ) ) {
394 if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contact Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
395 for ( int i = 0; i < file->bodies.Num(); i++ ) {
396 file->bodies[i]->contactFriction = file->defaultContactFriction;
398 bodyDlg->LoadFile( file );
402 m_contactFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ), false );
406 void DialogAFProperties::OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult) {
407 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
408 m_contactFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONTACTFRICTION ), pNMUpDown->iDelta < 0 );
413 void DialogAFProperties::OnEnChangeEditConstraintfriction() {
414 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ) ) ) {
416 if ( file && file->constraints.Num() && MessageBox( "Apply to all constraints ?", "Constraint Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
417 for ( int i = 0; i < file->constraints.Num(); i++ ) {
418 file->constraints[i]->friction = file->defaultConstraintFriction;
420 constraintDlg->LoadFile( file );
424 EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), false );
428 void DialogAFProperties::OnDeltaposSpinConstraintfriction(NMHDR *pNMHDR, LRESULT *pResult) {
429 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
430 m_constraintFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), pNMUpDown->iDelta < 0 );
435 void DialogAFProperties::OnEnChangeEditTotalmass() {
436 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_TOTALMASS ) ) ) {
441 void DialogAFProperties::OnDeltaposSpinTotalmass(NMHDR *pNMHDR, LRESULT *pResult) {
442 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
443 m_totalMass = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_TOTALMASS ), pNMUpDown->iDelta < 0 );
448 void DialogAFProperties::OnEnChangeEditLinearvelocity() {
449 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARVELOCITY ) ) ) {
454 void DialogAFProperties::OnEnChangeEditAngularvelocity() {
455 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARVELOCITY ) ) ) {
460 void DialogAFProperties::OnEnChangeEditLinearacceleration() {
461 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARACCELERATION ) ) ) {
466 void DialogAFProperties::OnEnChangeEditAngularacceleration() {
467 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARACCELERATION ) ) ) {
472 void DialogAFProperties::OnEnChangeEditNomovetime() {
473 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_NO_MOVE_TIME ) ) ) {
478 void DialogAFProperties::OnEnChangeEditMinimummovetime() {
479 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MINIMUM_MOVE_TIME ) ) ) {
484 void DialogAFProperties::OnEnChangeEditMaximummovetime() {
485 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MAXIMUM_MOVE_TIME ) ) ) {
490 void DialogAFProperties::OnEnChangeEditLineartolerance() {
491 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEAR_TOLERANCE ) ) ) {
496 void DialogAFProperties::OnEnChangeEditAngulartolerance() {
497 if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULAR_TOLERANCE ) ) ) {
502 void DialogAFProperties::OnBnClickedButtonBrowseModel() {
503 // m_editModel.SetWindowText( str );
507 void DialogAFProperties::OnBnClickedButtonBrowseSkin() {
508 // m_editSkin.SetWindowText( str );
510 // reload the .af file
511 // AFDialogReloadFile();