SurfaceDlg.cpp 17 KB

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