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 "tools/edit_gui_common.h"
30
31
32 #include "qe3.h"
33 #include "Radiant.h"
34 #include "SurfaceDlg.h"
35 #include "mainfrm.h"
36
37 #ifdef _DEBUG
38 #define new DEBUG_NEW
39 #undef THIS_FILE
40 static char THIS_FILE[] = __FILE__;
41 #endif
42
43 /////////////////////////////////////////////////////////////////////////////
44 // CSurfaceDlg dialog
45
46 CSurfaceDlg g_dlgSurface;
47
48
CSurfaceDlg(CWnd * pParent)49 CSurfaceDlg::CSurfaceDlg(CWnd* pParent /*=NULL*/)
50 : CDialog(CSurfaceDlg::IDD, pParent) {
51 //{{AFX_DATA_INIT(CSurfaceDlg)
52 m_nHorz = 3;
53 m_nVert = 3;
54 m_horzScale = 1.0f;
55 m_horzShift = 0.5f;
56 m_rotate = 15.0f;
57 m_vertScale = 1.0f;
58 m_vertShift = 0.5f;
59 m_strMaterial = _T("");
60 m_subdivide = FALSE;
61 m_fHeight = 1.0f;
62 m_fWidth = 1.0f;
63 m_absolute = FALSE;
64 //}}AFX_DATA_INIT
65 }
66
67
DoDataExchange(CDataExchange * pDX)68 void CSurfaceDlg::DoDataExchange(CDataExchange* pDX) {
69 CDialog::DoDataExchange(pDX);
70 //{{AFX_DATA_MAP(CSurfaceDlg)
71 DDX_Control(pDX, IDC_ROTATE, m_wndRotateEdit);
72 DDX_Control(pDX, IDC_EDIT_VERT, m_wndVert);
73 DDX_Control(pDX, IDC_EDIT_HORZ, m_wndHorz);
74 DDX_Control(pDX, IDC_SLIDER_VERT, m_wndVerticalSubdivisions);
75 DDX_Control(pDX, IDC_SLIDER_HORZ, m_wndHorzSubdivisions);
76 DDX_Control(pDX, IDC_SPIN_WIDTH, m_wndWidth);
77 DDX_Control(pDX, IDC_SPIN_HEIGHT, m_wndHeight);
78 DDX_Control(pDX, IDC_SPIN_VSHIFT, m_wndVShift);
79 DDX_Control(pDX, IDC_SPIN_ROTATE, m_wndRotate);
80 DDX_Control(pDX, IDC_SPIN_HSHIFT, m_wndHShift);
81 DDX_Text(pDX, IDC_EDIT_HORZ, m_nHorz);
82 DDV_MinMaxInt(pDX, m_nHorz, 1, 64);
83 DDX_Text(pDX, IDC_EDIT_VERT, m_nVert);
84 DDV_MinMaxInt(pDX, m_nVert, 1, 64);
85 DDX_Text(pDX, IDC_HSCALE, m_horzScale);
86 DDX_Text(pDX, IDC_HSHIFT, m_horzShift);
87 DDX_Text(pDX, IDC_ROTATE, m_rotate);
88 DDX_Text(pDX, IDC_VSCALE, m_vertScale);
89 DDX_Text(pDX, IDC_VSHIFT, m_vertShift);
90 DDX_Text(pDX, IDC_TEXTURE, m_strMaterial);
91 DDX_Check(pDX, IDC_CHECK_SUBDIVIDE, m_subdivide);
92 DDX_Text(pDX, IDC_EDIT_HEIGHT, m_fHeight);
93 DDX_Text(pDX, IDC_EDIT_WIDTH, m_fWidth);
94 DDX_Check(pDX, IDC_CHECK_ABSOLUTE, m_absolute);
95 //}}AFX_DATA_MAP
96 }
97
98
99 BEGIN_MESSAGE_MAP(CSurfaceDlg, CDialog)
100 //{{AFX_MSG_MAP(CSurfaceDlg)
101 ON_WM_HSCROLL()
102 ON_WM_KEYDOWN()
103 ON_WM_VSCROLL()
104 ON_WM_CLOSE()
105 ON_WM_DESTROY()
106 ON_BN_CLICKED(IDCANCEL, OnBtnCancel)
107 ON_BN_CLICKED(IDC_BTN_COLOR, OnBtnColor)
108 ON_WM_CTLCOLOR()
109 ON_WM_CREATE()
110 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaPosSpin)
111 ON_BN_CLICKED(IDC_BTN_PATCHDETAILS, OnBtnPatchdetails)
112 ON_BN_CLICKED(IDC_BTN_PATCHNATURAL, OnBtnPatchnatural)
113 ON_BN_CLICKED(IDC_BTN_PATCHRESET, OnBtnPatchreset)
114 ON_BN_CLICKED(IDC_BTN_AXIAL, OnBtnAxial)
115 ON_BN_CLICKED(IDC_BTN_BRUSHFIT, OnBtnBrushfit)
116 ON_BN_CLICKED(IDC_BTN_FACEFIT, OnBtnFacefit)
117 ON_BN_CLICKED(IDC_CHECK_SUBDIVIDE, OnCheckSubdivide)
118 ON_EN_CHANGE(IDC_EDIT_HORZ, OnChangeEditHorz)
119 ON_EN_CHANGE(IDC_EDIT_VERT, OnChangeEditVert)
120 ON_EN_SETFOCUS(IDC_HSCALE, OnSetfocusHscale)
121 ON_EN_KILLFOCUS(IDC_HSCALE, OnKillfocusHscale)
122 ON_EN_KILLFOCUS(IDC_VSCALE, OnKillfocusVscale)
123 ON_EN_SETFOCUS(IDC_VSCALE, OnSetfocusVscale)
124 ON_EN_KILLFOCUS(IDC_EDIT_WIDTH, OnKillfocusEditWidth)
125 ON_EN_SETFOCUS(IDC_EDIT_WIDTH, OnSetfocusEditWidth)
126 ON_EN_KILLFOCUS(IDC_EDIT_HEIGHT, OnKillfocusEditHeight)
127 ON_EN_SETFOCUS(IDC_EDIT_HEIGHT, OnSetfocusEditHeight)
128 ON_BN_CLICKED(IDC_BTN_FLIPX, OnBtnFlipx)
129 ON_BN_CLICKED(IDC_BTN_FLIPY, OnBtnFlipy)
130 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaPosSpin)
131 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaPosSpin)
132 ON_EN_KILLFOCUS(IDC_ROTATE, OnKillfocusRotate)
133 ON_EN_SETFOCUS(IDC_ROTATE, OnSetfocusRotate)
134 //}}AFX_MSG_MAP
135 END_MESSAGE_MAP()
136
137 /////////////////////////////////////////////////////////////////////////////
138 // CSurfaceDlg message handlers
139
140
141 /*
142 ===================================================
143
144 SURFACE INSPECTOR
145
146 ===================================================
147 */
148
149 texdef_t g_old_texdef;
150 texdef_t g_patch_texdef;
151 HWND g_surfwin = NULL;
152 bool g_changed_surface;
153
154 /*
155 ==============
156 SetTexMods
157
158 Set the fields to the current texdef
159 if one face selected -> will read this face texdef, else current texdef
160 if only patches selected, will read the patch texdef
161 ===============
162 */
163 extern void Face_GetScale_BrushPrimit(face_t *face, float *s, float *t, float *rot);
SetTexMods()164 void CSurfaceDlg::SetTexMods() {
165 UpdateData(TRUE);
166 m_strMaterial = g_qeglobals.d_texturewin.texdef.name;
167 patchMesh_t *p = SinglePatchSelected();
168 if (p) {
169 m_subdivide = p->explicitSubdivisions;
170 m_strMaterial = p->d_texture->GetName();
171 } else {
172 m_subdivide = false;
173 }
174
175 int faceCount = g_ptrSelectedFaces.GetSize();
176 face_t *selFace = NULL;
177 if (faceCount) {
178 selFace = reinterpret_cast < face_t * > (g_ptrSelectedFaces.GetAt(0));
179 } else {
180 if (selected_brushes.next != &selected_brushes) {
181 brush_t *b = selected_brushes.next;
182 if (!b->pPatch) {
183 selFace = b->brush_faces;
184 }
185 }
186 }
187
188 if (selFace) {
189 float rot;
190 Face_GetScale_BrushPrimit(selFace, &m_horzScale, &m_vertScale, &rot);
191 } else {
192 m_horzScale = 1.0f;
193 m_vertScale = 1.0f;
194 }
195
196 UpdateData(FALSE);
197 }
198
199
200 bool g_bNewFace = false;
201 bool g_bNewApplyHandling = false;
202 bool g_bGatewayhack = false;
203
204
205 /*
206 =================
207 UpdateSpinners
208 =================
209 */
210
UpdateSpinners(bool up,int nID)211 void CSurfaceDlg::UpdateSpinners(bool up, int nID) {
212 UpdateData(TRUE);
213 float hdiv = 0.0f;
214 float vdiv = 0.0f;
215 switch (nID) {
216 case IDC_SPIN_ROTATE :
217 Select_RotateTexture((up) ? m_rotate : -m_rotate);
218 break;
219 case IDC_SPIN_HSCALE :
220 m_horzScale += (up) ? 0.1f : -0.1f;
221 hdiv = (m_horzScale == 0.0f) ? 1.0f : m_horzScale;
222 Select_ScaleTexture( 1.0f / hdiv, 0.0f, true, ( m_absolute != FALSE ) );
223 UpdateData(FALSE);
224 break;
225 case IDC_SPIN_VSCALE :
226 m_vertScale += (up) ? 0.1f : -0.1f;
227 vdiv = (m_vertScale == 0.0f) ? 1.0f : m_vertScale;
228 Select_ScaleTexture( 0.0f, 1.0f / vdiv, true, ( m_absolute != FALSE ) );
229 UpdateData(FALSE);
230 break;
231 case IDC_SPIN_HSHIFT :
232 Select_ShiftTexture((up) ? m_horzShift : -m_horzShift, 0);
233 break;
234 case IDC_SPIN_VSHIFT :
235 Select_ShiftTexture(0, (up) ? m_vertShift : -m_vertShift);
236 break;
237 }
238 g_changed_surface = true;
239 }
240
UpdateSpinners(int nScrollCode,int nPos,CScrollBar * pBar)241 void CSurfaceDlg::UpdateSpinners(int nScrollCode, int nPos, CScrollBar* pBar) {
242
243 return;
244 UpdateData(TRUE);
245 if ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN)) {
246 return;
247 }
248
249 bool up = (nScrollCode == SB_LINEUP);
250
251 // FIXME: bad resource define
252 #define IDC_ROTATEA 0
253 #define IDC_HSCALEA 0
254 #define IDC_VSCALEA 0
255 #define IDC_HSHIFTA 0
256 #define IDC_VSHIFTA 0
257
258 if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_ROTATEA)) {
259 Select_RotateTexture((up) ? m_rotate : -m_rotate);
260 } else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSCALEA)) {
261 Select_ScaleTexture((up) ? -m_horzScale : m_horzScale, 0, true, ( m_absolute != FALSE ) );
262 } else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSCALEA)) {
263 Select_ScaleTexture(0, (up) ? -m_vertScale : m_vertScale, true, ( m_absolute != FALSE ) );
264 } else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSHIFTA)) {
265 Select_ShiftTexture((up) ? -m_horzShift : m_horzShift, 0);
266 } else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSHIFTA)) {
267 Select_ShiftTexture((up) ? -m_vertShift : m_vertShift, 0);
268 }
269
270 g_changed_surface = true;
271 }
272
UpdateSurfaceDialog()273 void UpdateSurfaceDialog() {
274 if (g_surfwin) {
275 g_dlgSurface.SetTexMods();
276 }
277 g_pParentWnd->UpdateTextureBar();
278 }
279
280 bool ByeByeSurfaceDialog();
281
DoSurface(void)282 void DoSurface (void) {
283
284 g_bNewFace = ( g_PrefsDlg.m_bFace != FALSE );
285 g_bNewApplyHandling = ( g_PrefsDlg.m_bNewApplyHandling != FALSE );
286 g_bGatewayhack = ( g_PrefsDlg.m_bGatewayHack != FALSE );
287 // save current state for cancel
288 g_old_texdef = g_qeglobals.d_texturewin.texdef;
289 g_changed_surface = false;
290
291 if (g_surfwin == NULL && g_dlgSurface.GetSafeHwnd() == NULL) {
292 g_patch_texdef.scale[0] = 0.05f;
293 g_patch_texdef.scale[1] = 0.05f;
294 g_patch_texdef.shift[0] = 0.05f;
295 g_patch_texdef.shift[1] = 0.05f;
296 // use rotation increment from preferences
297 g_patch_texdef.rotate = g_PrefsDlg.m_nRotation;
298
299 g_dlgSurface.Create(IDD_SURFACE);
300 CRect rct;
301 LONG lSize = sizeof(rct);
302 if (LoadRegistryInfo("radiant_SurfaceWindow", &rct, &lSize)) {
303 g_dlgSurface.SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
304 }
305 g_dlgSurface.ShowWindow(SW_SHOW);
306 Sys_UpdateWindows(W_ALL);
307 } else {
308 g_surfwin = g_dlgSurface.GetSafeHwnd();
309 g_dlgSurface.SetTexMods ();
310 g_dlgSurface.ShowWindow(SW_SHOW);
311 }
312 }
313
ByeByeSurfaceDialog()314 bool ByeByeSurfaceDialog() {
315 if (g_surfwin) {
316 if (g_bGatewayhack) {
317 PostMessage(g_surfwin, WM_COMMAND, IDC_APPLY, 0);
318 } else {
319 PostMessage(g_surfwin, WM_COMMAND, IDCANCEL, 0);
320 }
321 return true;
322 } else {
323 return false;
324 }
325 }
326
OnInitDialog()327 BOOL CSurfaceDlg::OnInitDialog() {
328 CDialog::OnInitDialog();
329
330 g_surfwin = GetSafeHwnd();
331 SetTexMods ();
332
333 //m_wndHScale.SetRange(0, 100);
334 //m_wndVScale.SetRange(0, 100);
335 m_wndHShift.SetRange(0, 100);
336 m_wndVShift.SetRange(0, 100);
337 m_wndRotate.SetRange(0, 100);
338 m_wndWidth.SetRange(1, 32);
339 m_wndHeight.SetRange(1, 32);
340
341 m_wndVerticalSubdivisions.SetRange(1, 32);
342 m_wndVerticalSubdivisions.SetBuddy(&m_wndVert, FALSE);
343 m_wndHorzSubdivisions.SetRange(1, 32);
344 m_wndHorzSubdivisions.SetBuddy(&m_wndHorz, FALSE);
345 m_wndVerticalSubdivisions.SetPos(m_nVert);
346 m_wndHorzSubdivisions.SetPos(m_nHorz);
347
348 return TRUE; // return TRUE unless you set the focus to a control
349 // EXCEPTION: OCX Property Pages should return FALSE
350 }
351
OnHScroll(UINT nSBCode,UINT nPos,CScrollBar * pScrollBar)352 void CSurfaceDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
353 UpdateData(TRUE);
354 if (pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl))) {
355 CSliderCtrl *ctrl = reinterpret_cast<CSliderCtrl*>(pScrollBar);
356 assert(ctrl);
357 if (ctrl == &m_wndVerticalSubdivisions) {
358 m_nVert = ctrl->GetPos();
359 } else {
360 m_nHorz = ctrl->GetPos();
361 }
362 UpdateData(FALSE);
363
364 if (m_subdivide) {
365 Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
366 }
367 }
368 Sys_UpdateWindows(W_CAMERA | W_XY);
369 }
370
OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags)371 void CSurfaceDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
372
373 CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
374 }
375
OnVScroll(UINT nSBCode,UINT nPos,CScrollBar * pScrollBar)376 void CSurfaceDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
377 //UpdateSpinners(nSBCode, nPos, pScrollBar);
378 //Sys_UpdateWindows(W_CAMERA);
379 }
380
381
OnOK()382 void CSurfaceDlg::OnOK() {
383 //GetTexMods();
384 UpdateData(TRUE);
385 if (m_strMaterial.Find(":") >= 0) {
386 const idMaterial *mat = declManager->FindMaterial(m_strMaterial);
387 Select_UpdateTextureName(m_strMaterial);
388 }
389 g_surfwin = NULL;
390 CDialog::OnOK();
391 Sys_UpdateWindows(W_ALL);
392 }
393
OnClose()394 void CSurfaceDlg::OnClose() {
395 g_surfwin = NULL;
396 CDialog::OnClose();
397 }
398
OnCancel()399 void CSurfaceDlg::OnCancel() {
400 if (g_bGatewayhack) {
401 OnOK();
402 } else {
403 OnBtnCancel();
404 }
405 }
406
OnDestroy()407 void CSurfaceDlg::OnDestroy() {
408 if (GetSafeHwnd()) {
409 CRect rct;
410 GetWindowRect(rct);
411 SaveRegistryInfo("radiant_SurfaceWindow", &rct, sizeof(rct));
412 }
413 CDialog::OnDestroy();
414 g_surfwin = NULL;
415 Sys_UpdateWindows(W_ALL);
416 }
417
OnBtnCancel()418 void CSurfaceDlg::OnBtnCancel() {
419 g_qeglobals.d_texturewin.texdef = g_old_texdef;
420 if (g_changed_surface) {
421 //++timo if !g_qeglobals.m_bBrushPrimitMode send a NULL brushprimit_texdef
422 if (!g_qeglobals.m_bBrushPrimitMode) {
423 common->Printf("Warning : non brush primitive mode call to CSurfaceDlg::GetTexMods broken\n");
424 common->Printf(" ( Select_SetTexture not called )\n");
425 }
426 // Select_SetTexture(&g_qeglobals.d_texturewin.texdef);
427 }
428 g_surfwin = NULL;
429 DestroyWindow();
430 }
431
OnBtnColor()432 void CSurfaceDlg::OnBtnColor() {
433 }
434
OnCtlColor(CDC * pDC,CWnd * pWnd,UINT nCtlColor)435 HBRUSH CSurfaceDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
436 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
437 return hbr;
438 }
439
OnCreate(LPCREATESTRUCT lpCreateStruct)440 int CSurfaceDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) {
441 if (CDialog::OnCreate(lpCreateStruct) == -1)
442 return -1;
443
444 return 0;
445 }
446
PreCreateWindow(CREATESTRUCT & cs)447 BOOL CSurfaceDlg::PreCreateWindow(CREATESTRUCT& cs) {
448 // TODO: Add your specialized code here and/or call the base class
449
450 return CDialog::PreCreateWindow(cs);
451 }
452
453
OnDeltaPosSpin(NMHDR * pNMHDR,LRESULT * pResult)454 void CSurfaceDlg::OnDeltaPosSpin(NMHDR* pNMHDR, LRESULT* pResult) {
455 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
456 UpdateSpinners((pNMUpDown->iDelta > 0), pNMUpDown->hdr.idFrom);
457 *pResult = 0;
458 }
459
OnBtnPatchdetails()460 void CSurfaceDlg::OnBtnPatchdetails() {
461 Patch_NaturalizeSelected(true);
462 g_pParentWnd->GetCamera()->MarkWorldDirty ();
463 Sys_UpdateWindows(W_ALL);
464 }
465
OnBtnPatchnatural()466 void CSurfaceDlg::OnBtnPatchnatural() {
467 Select_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false);
468 Patch_NaturalizeSelected();
469 g_pParentWnd->GetCamera()->MarkWorldDirty ();
470 g_changed_surface = true;
471 Sys_UpdateWindows(W_ALL);
472 }
473
OnBtnPatchreset()474 void CSurfaceDlg::OnBtnPatchreset() {
475 //CTextureLayout dlg;
476 //if (dlg.DoModal() == IDOK) {
477 // Patch_ResetTexturing(dlg.m_fX, dlg.m_fY);
478 //}
479 //Sys_UpdateWindows(W_ALL);
480 }
481
OnBtnAxial()482 void CSurfaceDlg::OnBtnAxial() {
483 }
484
OnBtnBrushfit()485 void CSurfaceDlg::OnBtnBrushfit() {
486 // TODO: Add your control notification handler code here
487
488 }
489
OnBtnFacefit()490 void CSurfaceDlg::OnBtnFacefit() {
491 UpdateData(TRUE);
492 /*
493 brush_t *b;
494 for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) {
495 if (!b->patchBrush) {
496 for (face_t* pFace = b->brush_faces; pFace; pFace = pFace->next) {
497 g_ptrSelectedFaces.Add(pFace);
498 g_ptrSelectedFaceBrushes.Add(b);
499 }
500 }
501 }
502 */
503 Select_FitTexture(m_fHeight, m_fWidth);
504 g_pParentWnd->GetCamera()->MarkWorldDirty ();
505 //SetTexMods();
506 g_changed_surface = true;
507 Sys_UpdateWindows(W_ALL);
508 }
509
510
OnCheckSubdivide()511 void CSurfaceDlg::OnCheckSubdivide() {
512 UpdateData( TRUE );
513 // turn any patches in explicit subdivides
514 Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
515 g_pParentWnd->GetCamera()->MarkWorldDirty ();
516 Sys_UpdateWindows( W_CAMERA | W_XY );
517 }
518
OnChangeEditHorz()519 void CSurfaceDlg::OnChangeEditHorz()
520 {
521 // TODO: If this is a RICHEDIT control, the control will not
522 // send this notification unless you override the CDialog::OnInitDialog()
523 // function and call CRichEditCtrl().SetEventMask()
524 // with the ENM_CHANGE flag ORed into the mask.
525
526 // TODO: Add your control notification handler code here
527 UpdateData(TRUE);
528 // turn any patches in explicit subdivides
529 Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
530 Sys_UpdateWindows(W_CAMERA | W_XY);
531
532 }
533
OnChangeEditVert()534 void CSurfaceDlg::OnChangeEditVert()
535 {
536 // TODO: If this is a RICHEDIT control, the control will not
537 // send this notification unless you override the CDialog::OnInitDialog()
538 // function and call CRichEditCtrl().SetEventMask()
539 // with the ENM_CHANGE flag ORed into the mask.
540
541 // TODO: Add your control notification handler code here
542 UpdateData(TRUE);
543 // turn any patches in explicit subdivides
544 Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
545 Sys_UpdateWindows(W_CAMERA | W_XY);
546
547 }
548
PreTranslateMessage(MSG * pMsg)549 BOOL CSurfaceDlg::PreTranslateMessage(MSG* pMsg)
550 {
551 if (pMsg->message == WM_KEYDOWN) {
552 if (pMsg->wParam == VK_RETURN) {
553 if (focusControl) {
554 UpdateData(TRUE);
555 if (focusControl == &m_wndHScale) {
556 Select_ScaleTexture( m_horzScale, 1.0f, true, ( m_absolute != FALSE ) );
557 } else if (focusControl == &m_wndVScale) {
558 Select_ScaleTexture( 1.0f, m_vertScale, true, ( m_absolute != FALSE ) );
559 } else if (focusControl == &m_wndRotateEdit) {
560 Select_RotateTexture( m_rotate, true );
561 } else if (focusControl == &m_wndHeight || focusControl == &m_wndWidth) {
562 Select_FitTexture( m_fHeight, m_fWidth );
563 }
564 }
565 return TRUE;
566 }
567 }
568 return CDialog::PreTranslateMessage(pMsg);
569 }
570
OnSetfocusHscale()571 void CSurfaceDlg::OnSetfocusHscale()
572 {
573 focusControl = &m_wndHScale;
574 }
575
OnKillfocusHscale()576 void CSurfaceDlg::OnKillfocusHscale()
577 {
578 focusControl = NULL;
579 }
580
OnKillfocusVscale()581 void CSurfaceDlg::OnKillfocusVscale()
582 {
583 focusControl = NULL;
584 }
585
OnSetfocusVscale()586 void CSurfaceDlg::OnSetfocusVscale()
587 {
588 focusControl = &m_wndVScale;
589 }
590
OnKillfocusEditWidth()591 void CSurfaceDlg::OnKillfocusEditWidth()
592 {
593 focusControl = NULL;
594 }
595
OnSetfocusEditWidth()596 void CSurfaceDlg::OnSetfocusEditWidth()
597 {
598 focusControl = &m_wndWidth;
599 }
600
OnKillfocusEditHeight()601 void CSurfaceDlg::OnKillfocusEditHeight()
602 {
603 focusControl = NULL;
604 }
605
OnSetfocusEditHeight()606 void CSurfaceDlg::OnSetfocusEditHeight()
607 {
608 focusControl = &m_wndHeight;
609 }
610
OnBtnFlipx()611 void CSurfaceDlg::OnBtnFlipx()
612 {
613 Select_FlipTexture(false);
614 }
615
OnBtnFlipy()616 void CSurfaceDlg::OnBtnFlipy()
617 {
618 Select_FlipTexture(true);
619 }
620
OnKillfocusRotate()621 void CSurfaceDlg::OnKillfocusRotate()
622 {
623 focusControl = NULL;
624 }
625
OnSetfocusRotate()626 void CSurfaceDlg::OnSetfocusRotate()
627 {
628 focusControl = &m_wndRotateEdit;
629 }
630