doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogAFConstraintSlider.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../../sys/win32/rc/AFEditor_resource.h"
33 
34 #include "DialogAF.h"
35 #include "DialogAFConstraint.h"
37 
38 
39 // DialogAFConstraintSlider dialog
40 
42  { IDC_RADIO_SLIDER_AXIS_BONE, "use a bone for the slider axis" },
43  { IDC_RADIO_SLIDER_AXIS_ANGLES, "use angles to set the orientation of the slider axis" },
44  { IDC_COMBO_SLIDER_AXIS_JOINT1, "bone start joint" },
45  { IDC_COMBO_SLIDER_AXIS_JOINT2, "bone end joint" },
46  { IDC_EDIT_SLIDER_AXIS_PITCH, "pitch angle" },
47  { IDC_EDIT_SLIDER_AXIS_YAW, "yaw angle" },
48  { 0, NULL }
49 };
50 
51 IMPLEMENT_DYNAMIC(DialogAFConstraintSlider, CDialog)
52 
53 /*
54 ================
55 DialogAFConstraintSlider::DialogAFConstraintSlider
56 ================
57 */
59  : CDialog(DialogAFConstraintSlider::IDD, pParent)
60  , m_axisPitch(0)
61  , m_axisYaw(0)
62  , constraint(NULL)
63  , file(NULL)
64 {
65  Create( IDD_DIALOG_AF_CONSTRAINT_SLIDER, pParent );
66  EnableToolTips( TRUE );
67 }
68 
69 /*
70 ================
71 DialogAFConstraintSlider::~DialogAFConstraintSlider
72 ================
73 */
75 }
76 
77 /*
78 ================
79 DialogAFConstraintSlider::DoDataExchange
80 ================
81 */
82 void DialogAFConstraintSlider::DoDataExchange(CDataExchange* pDX) {
83  CDialog::DoDataExchange(pDX);
84  //{{AFX_DATA_MAP(DialogAFConstraintSlider)
88  DDX_Text(pDX, IDC_EDIT_SLIDER_AXIS_YAW, m_axisYaw);
89  //}}AFX_DATA_MAP
90 }
91 
92 /*
93 ================
94 DialogAFConstraintSlider::InitJointLists
95 ================
96 */
98  m_comboAxisJoint1.ResetContent();
99  m_comboAxisJoint2.ResetContent();
100 
101  if ( !file ) {
102  return;
103  }
104 
106  if ( !model ) {
107  return;
108  }
109 
110  int numJoints = model->NumJoints();
111  for ( int i = 0; i < numJoints; i++ ) {
112  const char *jointName = model->GetJointName( (jointHandle_t) i );
113  m_comboAxisJoint1.AddString( jointName );
114  m_comboAxisJoint2.AddString( jointName );
115  }
116 }
117 
118 /*
119 ================
120 DialogAFConstraintSlider::LoadFile
121 ================
122 */
124  file = af;
125  constraint = NULL;
126  InitJointLists();
127 }
128 
129 /*
130 ================
131 DialogAFConstraintSlider::SaveFile
132 ================
133 */
135  SaveConstraint();
136 }
137 
138 /*
139 ================
140 DialogAFConstraintSlider::LoadConstraint
141 ================
142 */
144  int i, s1, s2;
145  idAngles angles;
146 
147  constraint = c;
148 
149  // slider axis
152  angles = constraint->axis.ToVec3().ToAngles();
153  m_axisPitch = angles.pitch;
154  m_axisYaw = angles.yaw;
157  }
158  else {
161  }
163 
164  // update displayed values
165  UpdateData( FALSE );
166 }
167 
168 /*
169 ================
170 DialogAFConstraintSlider::SaveConstraint
171 ================
172 */
174  int s1, s2;
175  CString str;
176 
177  if ( !file || !constraint ) {
178  return;
179  }
180  UpdateData( TRUE );
181 
182  // slider axis
185  constraint->axis.joint1 = str;
187  constraint->axis.joint2 = str;
188  }
189  else {
191  }
192 
194 }
195 
196 /*
197 ================
198 DialogAFConstraintSlider::UpdateFile
199 ================
200 */
202  SaveConstraint();
203  if ( file ) {
205  }
206 }
207 
208 /*
209 ================
210 DialogAFConstraintSlider::OnToolHitTest
211 ================
212 */
213 int DialogAFConstraintSlider::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
214  CDialog::OnToolHitTest( point, pTI );
215  return DefaultOnToolHitTest( toolTips, this, point, pTI );
216 }
217 
218 
219 BEGIN_MESSAGE_MAP(DialogAFConstraintSlider, CDialog)
220  ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
221  ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
222  ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_BONE, OnBnClickedRadioSliderAxisBone)
223  ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_ANGLES, OnBnClickedRadioSliderAxisAngles)
224  ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT1, OnCbnSelchangeComboSliderAxisJoint1)
225  ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT2, OnCbnSelchangeComboSliderAxisJoint2)
226  ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_PITCH, OnEnChangeEditSliderAxisPitch)
227  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_PITCH, OnDeltaposSpinSliderAxisPitch)
228  ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_YAW, OnEnChangeEditSliderAxisYaw)
229  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_YAW, OnDeltaposSpinSliderAxisYaw)
230 END_MESSAGE_MAP()
231 
232 
233 // DialogAFConstraintSlider message handlers
234 
235 BOOL DialogAFConstraintSlider::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
236  return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
237 }
238 
240  if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_BONE ) ) {
241  if ( constraint ) {
243  UpdateFile();
244  }
245  }
246 }
247 
249  if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_ANGLES ) ) {
250  if ( constraint ) {
252  UpdateFile();
253  }
254  }
255 }
256 
258  CString str;
261  UpdateFile();
262 }
263 
265  CString str;
268  UpdateFile();
269 }
270 
272  if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) ) ) {
273  UpdateFile();
274  }
275  else {
276  EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) );
277  }
278 }
279 
280 void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
281  LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
282  if ( pNMUpDown->iDelta < 0 ) {
283  m_axisPitch += 1.0f;
284  }
285  else {
286  m_axisPitch -= 1.0f;
287  }
288  UpdateData( FALSE );
289  UpdateFile();
290  *pResult = 0;
291 }
292 
294  if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) ) ) {
295  UpdateFile();
296  }
297  else {
298  EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) );
299  }
300 }
301 
302 void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
303  LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
304  if ( pNMUpDown->iDelta < 0 ) {
305  m_axisYaw += 1.0f;
306  }
307  else {
308  m_axisYaw -= 1.0f;
309  }
310  UpdateData( FALSE );
311  UpdateFile();
312  *pResult = 0;
313 }
jointHandle_t
Definition: Model.h:156
BOOL DefaultOnToolTipNotify(const toolTip_t *toolTips, UINT id, NMHDR *pNMHDR, LRESULT *pResult)
Definition: StdAfx.cpp:104
#define IDC_EDIT_SLIDER_AXIS_PITCH
#define IDC_COMBO_SLIDER_AXIS_JOINT2
afx_msg void OnCbnSelchangeComboSliderAxisJoint1()
virtual void AF_UpdateEntities(const char *fileName)
Definition: AFEntity.cpp:2856
#define IDC_EDIT_SLIDER_AXIS_YAW
int SetSafeComboBoxSelection(CComboBox *combo, const char *string, int skip)
Definition: StdAfx.cpp:319
afx_msg void OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult)
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
const char * GetName(void) const
Definition: DeclManager.h:140
int i
Definition: process.py:33
#define BOOL
Definition: mprintf.c:71
#define IDC_COMBO_SLIDER_AXIS_JOINT1
idGameEdit * gameEdit
Definition: GameEdit.cpp:668
#define IDC_SPIN_SLIDER_AXIS_YAW
virtual const char * GetJointName(jointHandle_t handle) const =0
idStr joint1
Definition: DeclAF.h:68
virtual void DoDataExchange(CDataExchange *pDX)
idAngles ToAngles(void) const
Definition: Vector.cpp:130
const idVec3 & ToVec3(void) const
Definition: DeclAF.h:78
const GLubyte * c
Definition: glext.h:4677
void LoadConstraint(idDeclAF_Constraint *c)
idVec3 ToForward(void) const
Definition: Angles.cpp:117
#define NULL
Definition: Lib.h:88
idAFVector axis
Definition: DeclAF.h:128
int DefaultOnToolHitTest(const toolTip_t *toolTips, const CDialog *dialog, CPoint point, TOOLINFO *pTI)
Definition: StdAfx.cpp:75
virtual idRenderModel * ANIM_GetModelFromName(const char *modelName)
int UnsetSafeComboBoxSelection(CComboBox *combo, CString &string)
Definition: StdAfx.cpp:366
#define IDC_RADIO_SLIDER_AXIS_BONE
afx_msg void OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult)
bool EditControlEnterHit(CEdit *edit)
Definition: StdAfx.cpp:154
afx_msg void OnCbnSelchangeComboSliderAxisJoint2()
int GetSafeComboBoxSelection(CComboBox *combo, CString &string, int skip)
Definition: StdAfx.cpp:341
void AFDialogSetFileModified(void)
Definition: DialogAF.cpp:613
tuple f
Definition: idal.py:89
idStr model
Definition: DeclAF.h:172
#define IDC_SPIN_SLIDER_AXIS_PITCH
#define IDD_DIALOG_AF_CONSTRAINT_SLIDER
idDeclAF_Constraint * constraint
const char * c_str(void) const
Definition: Str.h:487
#define FALSE
Definition: mprintf.c:70
enum idAFVector::@48 type
virtual int NumJoints(void) const =0
#define TRUE
Definition: mprintf.c:69
virtual int OnToolHitTest(CPoint point, TOOLINFO *pTI) const
float EditVerifyFloat(CEdit *edit, bool allowNegative)
Definition: StdAfx.cpp:175
#define IDC_RADIO_SLIDER_AXIS_ANGLES
idStr joint2
Definition: DeclAF.h:69