doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NewTexWnd.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 "qe3.h"
33 #include "Radiant.h"
34 #include "NewTexWnd.h"
35 #include "io.h"
36 
37 #include "../../renderer/tr_local.h"
38 
39 #ifdef _DEBUG
40  #define new DEBUG_NEW
41  #undef THIS_FILE
42 static char THIS_FILE[] = __FILE__;
43 #endif
44 
45 /*
46  =======================================================================================================================
47  =======================================================================================================================
48  */
49 bool Sys_KeyDown( int key ) {
50  return ( ( ::GetAsyncKeyState( key ) & 0x8000 ) != 0 );
51 }
52 
53 // CNewTexWnd
55 
56 /*
57  =======================================================================================================================
58  =======================================================================================================================
59  */
61  m_bNeedRange = true;
63  hdcTexture = NULL;
64  cursor.x = cursor.y = 0;
65  origin.x = origin.y = 0;
66 }
67 
68 /*
69  =======================================================================================================================
70  =======================================================================================================================
71  */
73 }
74 
75 BEGIN_MESSAGE_MAP(CNewTexWnd, CWnd)
76 //{{AFX_MSG_MAP(CNewTexWnd)
77  ON_WM_CREATE()
78  ON_WM_SIZE()
79  ON_WM_PARENTNOTIFY()
80  ON_WM_KEYDOWN()
81  ON_WM_KEYUP()
82  ON_WM_PAINT()
83  ON_WM_VSCROLL()
84  ON_WM_LBUTTONDOWN()
85  ON_WM_MBUTTONDOWN()
86  ON_WM_RBUTTONDOWN()
87  ON_WM_LBUTTONUP()
88  ON_WM_MBUTTONUP()
89  ON_WM_RBUTTONUP()
90  ON_WM_MOUSEMOVE()
91  ON_WM_MOUSEWHEEL()
92  //}}AFX_MSG_MAP
93  ON_WM_SETFOCUS()
94 END_MESSAGE_MAP()
95 //
96 // =======================================================================================================================
97 // CNewTexWnd message handlers
98 // =======================================================================================================================
99 //
100 BOOL CNewTexWnd::PreCreateWindow(CREATESTRUCT &cs) {
101  WNDCLASS wc;
102  HINSTANCE hInstance = AfxGetInstanceHandle();
103  if (::GetClassInfo(hInstance, TEXTURE_WINDOW_CLASS, &wc) == FALSE) {
104  // Register a new class
105  memset(&wc, 0, sizeof(wc));
106  wc.style = CS_NOCLOSE | CS_PARENTDC; // | CS_OWNDC;
107  wc.lpszClassName = TEXTURE_WINDOW_CLASS;
108  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
109  wc.lpfnWndProc = ::DefWindowProc;
110  if (AfxRegisterClass(&wc) == FALSE) {
111  Error("CNewTexWnd RegisterClass: failed");
112  }
113  }
114 
115  cs.lpszClass = TEXTURE_WINDOW_CLASS;
116  cs.lpszName = "TEX";
117  if (cs.style != QE3_CHILDSTYLE && cs.style != QE3_STYLE) {
118  cs.style = QE3_SPLITTER_STYLE;
119  }
120 
121  return CWnd::PreCreateWindow(cs);
122 }
123 
124 /*
125  =======================================================================================================================
126  =======================================================================================================================
127  */
128 int CNewTexWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) {
129  if (CWnd::OnCreate(lpCreateStruct) == -1) {
130  return -1;
131  }
132 
133  ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);
134  m_bNeedRange = true;
135 
136  hdcTexture = GetDC();
137  QEW_SetupPixelFormat(hdcTexture->m_hDC, false);
138 
139  EnableToolTips(TRUE);
140  EnableTrackingToolTips(TRUE);
141 
142  return 0;
143 }
144 
145 /*
146  =======================================================================================================================
147  =======================================================================================================================
148  */
149 void CNewTexWnd::OnSize(UINT nType, int cx, int cy) {
150  CWnd::OnSize(nType, cx, cy);
151  GetClientRect(rectClient);
152  m_bNeedRange = true;
153 }
154 
155 /*
156  =======================================================================================================================
157  =======================================================================================================================
158  */
159 void CNewTexWnd::OnParentNotify(UINT message, LPARAM lParam) {
160  CWnd::OnParentNotify(message, lParam);
161 }
162 
163 /*
164  =======================================================================================================================
165  =======================================================================================================================
166  */
168  ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);
169  m_bNeedRange = true;
170  Invalidate();
171  UpdateWindow();
172 }
173 
174 /*
175  =======================================================================================================================
176  =======================================================================================================================
177  */
178 void CNewTexWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
179  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);
180 }
181 
182 /*
183  =======================================================================================================================
184  =======================================================================================================================
185  */
186 void CNewTexWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
187  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);
188 }
189 
190 /*
191  =======================================================================================================================
192  =======================================================================================================================
193  */
195  const idMaterial *mat = NULL;
196  while (1) {
198  return NULL;
199  }
200 
202 
203  currentIndex++;
204 
205  //if (mat->getName()[0] == '(') { // fake color texture
206  // continue;
207  //}
208 
209  if ( !mat->IsValid() ) {
210  continue;
211  }
212 
213  if (!mat->TestMaterialFlag(MF_EDITOR_VISIBLE)) {
214  continue;
215  }
216  break;
217  }
218 
219  // ensure it is uploaded
221 
224 
225  if (current.x + width > rectClient.Width() - 8 && currentRow) {
226  // go to the next row unless the texture is the first on the row
227  current.x = 8;
228  current.y -= currentRow + FONT_HEIGHT + 4;
229  currentRow = 0;
230  }
231 
232  draw = current;
233 
234  // Is our texture larger than the row? If so, grow the row height to match it
235  if (currentRow < height) {
236  currentRow = height;
237  }
238 
239  // never go less than 64, or the names get all crunched up
240  current.x += width < 64 ? 64 : width;
241  current.x += 8;
242  return mat;
243 }
244 
245 /*
246  =======================================================================================================================
247  =======================================================================================================================
248  */
250 
251  CPaintDC dc(this); // device context for painting
252 
253  int nOld = g_qeglobals.d_texturewin.m_nTotalHeight;
254 
255  //hdcTexture = GetDC();
256  if (!qwglMakeCurrent(dc.GetSafeHdc(), win32.hGLRC)) {
257  common->Printf("ERROR: wglMakeCurrent failed..\n ");
258  }
259  else {
260  const char *name;
262  (
263  g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][0],
264  g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][1],
265  g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][2],
266  0
267  );
268  qglViewport(0, 0, rectClient.Width(), rectClient.Height());
269  qglScissor(0, 0, rectClient.Width(), rectClient.Height());
270  qglMatrixMode(GL_PROJECTION);
271  qglLoadIdentity();
272  qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
273  qglDisable(GL_DEPTH_TEST);
274  qglDisable(GL_BLEND);
275  qglOrtho(0, rectClient.Width(), origin.y - rectClient.Height(), origin.y, -100, 100);
276  qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
277 
278  // init stuff
279  current.x = 8;
280  current.y = -8;
281  currentRow = 0;
282  currentIndex = 0;
283  while (1) {
284  const idMaterial *mat = NextPos();
285  if (mat == NULL) {
286  break;
287  }
288 
291 
292  // Is this texture visible?
293  if ((draw.y - height - FONT_HEIGHT < origin.y) && (draw.y > origin.y - rectClient.Height())) {
294  // if in use, draw a background
295  qglLineWidth(1);
296  qglColor3f(1, 1, 1);
298  qglBegin(GL_LINE_LOOP);
299  qglVertex2f(draw.x - 1, draw.y + 1 - FONT_HEIGHT);
300  qglVertex2f(draw.x - 1, draw.y - height - 1 - FONT_HEIGHT);
301  qglVertex2f(draw.x + 1 + width, draw.y - height - 1 - FONT_HEIGHT);
302  qglVertex2f(draw.x + 1 + width, draw.y + 1 - FONT_HEIGHT);
303  qglEnd();
304 
305  // Draw the texture
306  float fScale = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? ((float)g_PrefsDlg.m_nTextureScale / 100) : 1.0;
307 
308  mat->GetEditorImage()->Bind();
309  QE_CheckOpenGLForErrors();
310  qglColor3f(1, 1, 1);
311  qglBegin(GL_QUADS);
312  qglTexCoord2f(0, 0);
313  qglVertex2f(draw.x, draw.y - FONT_HEIGHT);
314  qglTexCoord2f(1, 0);
315  qglVertex2f(draw.x + width, draw.y - FONT_HEIGHT);
316  qglTexCoord2f(1, 1);
317  qglVertex2f(draw.x + width, draw.y - FONT_HEIGHT - height);
318  qglTexCoord2f(0, 1);
319  qglVertex2f(draw.x, draw.y - FONT_HEIGHT - height);
320  qglEnd();
321 
322  // draw the selection border
323  if ( !idStr::Icmp(g_qeglobals.d_texturewin.texdef.name, mat->GetName()) ) {
324  qglLineWidth(3);
325  qglColor3f(1, 0, 0);
327 
328  qglBegin(GL_LINE_LOOP);
329  qglVertex2f(draw.x - 4, draw.y - FONT_HEIGHT + 4);
330  qglVertex2f(draw.x - 4, draw.y - FONT_HEIGHT - height - 4);
331  qglVertex2f(draw.x + 4 + width, draw.y - FONT_HEIGHT - height - 4);
332  qglVertex2f(draw.x + 4 + width, draw.y - FONT_HEIGHT + 4);
333  qglEnd();
334 
335  qglLineWidth(1);
336  }
337 
338  // draw the texture name
340  qglColor3f(1, 1, 1);
341  qglRasterPos2f(draw.x, draw.y - FONT_HEIGHT + 2);
342 
343  // don't draw the directory name
344  for (name = mat->GetName(); *name && *name != '/' && *name != '\\'; name++) {
345  ;
346  }
347 
348  if (!*name) {
349  name = mat->GetName();
350  }
351  else {
352  name++;
353  }
354  qglCallLists(strlen(name), GL_UNSIGNED_BYTE, name);
355  //qglCallLists(va("%s -- %d, %d" strlen(name), GL_UNSIGNED_BYTE, name);
356  }
357  }
358 
359  g_qeglobals.d_texturewin.m_nTotalHeight = abs(draw.y) + 100;
360 
361  // reset the current texture
363  qglFinish();
364  qwglSwapBuffers(dc.GetSafeHdc());
365  TRACE("Texture Paint\n");
366  }
367 
368  if (g_PrefsDlg.m_bTextureScrollbar && (m_bNeedRange || g_qeglobals.d_texturewin.m_nTotalHeight != nOld)) {
369  m_bNeedRange = false;
370  SetScrollRange(SB_VERT, 0, g_qeglobals.d_texturewin.m_nTotalHeight, TRUE);
371  }
372 
373  //ReleaseDC(hdcTexture);
374 }
375 
376 /*
377  =======================================================================================================================
378  =======================================================================================================================
379  */
380 void CNewTexWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
381  CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
382 
383  int n = GetScrollPos(SB_VERT);
384  switch (nSBCode)
385  {
386  case SB_LINEUP: {
387  n = (n - 15 > 0) ? n - 15 : 0;
388  break;
389  }
390 
391  case SB_LINEDOWN: {
392  n = (n + 15 < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + 15 : n;
393  break;
394  }
395 
396  case SB_PAGEUP: {
397  n = (n - g_qeglobals.d_texturewin.height > 0) ? n - g_qeglobals.d_texturewin.height : 0;
398  break;
399  }
400 
401  case SB_PAGEDOWN: {
402  n = (n + g_qeglobals.d_texturewin.height < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + g_qeglobals.d_texturewin.height : n;
403  break;
404  }
405 
406  case SB_THUMBPOSITION: {
407  n = nPos;
408  break;
409  }
410 
411  case SB_THUMBTRACK: {
412  n = nPos;
413  break;
414  }
415  }
416 
417  SetScrollPos(SB_VERT, n);
418  origin.y = -n;
419  Invalidate();
420  UpdateWindow();
421 
422  // Sys_UpdateWindows(W_TEXTURE);
423 }
424 
426  ReleaseDC(hdcTexture);
427  return CWnd::DestroyWindow();
428 }
429 
430 /*
431  =======================================================================================================================
432  =======================================================================================================================
433  */
435 (
436  LPCTSTR lpszClassName,
437  LPCTSTR lpszWindowName,
438  DWORD dwStyle,
439  const RECT &rect,
440  CWnd *pParentWnd,
441  UINT nID,
442  CCreateContext *pContext
443 ) {
444  BOOL ret = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
445  if (ret) {
446  hdcTexture = GetDC();
447  QEW_SetupPixelFormat(hdcTexture->m_hDC, false);
448  }
449 
450  return ret;
451 }
452 
454 
455  // init stuff
456  int my = rectClient.Height() - 1 - point.y;
457  my += origin.y - rectClient.Height();
458 
459  current.x = 8;
460  current.y = -8;
461  currentRow = 0;
462  currentIndex = 0;
463 
464  while (1) {
465  const idMaterial *mat = NextPos();
466  if (mat == NULL) {
467  return NULL;
468  }
469 
472  //if (point.x > draw.x && point.x - draw.x < width && my < draw.y && my + draw.y < height + FONT_HEIGHT) {
473  if (point.x > draw.x && point.x - draw.x < width && my < draw.y && draw.y - my < height + FONT_HEIGHT) {
474  return mat;
475  }
476 
477  }
478 
479 }
480 /*
481  =======================================================================================================================
482  =======================================================================================================================
483  */
484 void CNewTexWnd::OnLButtonDown(UINT nFlags, CPoint point) {
485  cursor = point;
486 
487  SetFocus();
488  bool fitScale = Sys_KeyDown(VK_CONTROL);
489  bool edit = Sys_KeyDown(VK_SHIFT) && !fitScale;
490 
491  const idMaterial *mat = getMaterialAtPoint(point);
492  if (mat) {
493  Select_SetDefaultTexture(mat, fitScale, true);
494  } else {
495  Sys_Status("Did not select a texture\n", 0);
496  }
497 
498  //
501 }
502 
503 /*
504  =======================================================================================================================
505  =======================================================================================================================
506  */
507 void CNewTexWnd::OnMButtonDown(UINT nFlags, CPoint point) {
508  CWnd::OnMButtonDown(nFlags, point);
509 
510 }
511 
512 /*
513  =======================================================================================================================
514  =======================================================================================================================
515  */
516 void CNewTexWnd::OnRButtonDown(UINT nFlags, CPoint point) {
517  cursor = point;
518  SetFocus();
519 }
520 
521 /*
522  ===============================t========================================================================================
523  =======================================================================================================================
524  */
525 void CNewTexWnd::OnLButtonUp(UINT nFlags, CPoint point) {
526  CWnd::OnLButtonUp(nFlags, point);
527  g_pParentWnd->SetFocus();
528 }
529 
530 /*
531  =======================================================================================================================
532  =======================================================================================================================
533  */
534 void CNewTexWnd::OnMButtonUp(UINT nFlags, CPoint point) {
535  CWnd::OnMButtonUp(nFlags, point);
536 }
537 
538 /*
539  =======================================================================================================================
540  =======================================================================================================================
541  */
542 void CNewTexWnd::OnRButtonUp(UINT nFlags, CPoint point) {
543  CWnd::OnRButtonUp(nFlags, point);
544 }
545 
546 extern float fDiff(float f1, float f2);
547 
548 /*
549  =======================================================================================================================
550  =======================================================================================================================
551  */
552 void CNewTexWnd::OnMouseMove(UINT nFlags, CPoint point) {
553  int scale = 1;
554 
555  if (Sys_KeyDown(VK_SHIFT)) {
556  scale = 4;
557  }
558 
559  // rbutton = drag texture origin
560  if (Sys_KeyDown(VK_RBUTTON)) {
561  if (point.y != cursor.y) {
562  if (Sys_KeyDown(VK_MENU)) {
563  long *px = &point.x;
564  long *px2 = &cursor.x;
565 
566  if (fDiff(point.y, cursor.y) > fDiff(point.x, cursor.x)) {
567  px = &point.y;
568  px2 = &cursor.y;
569  }
570 
571  if (*px > *px2) {
572  // zoom in
574  if (g_PrefsDlg.m_nTextureScale > 500) {
576  }
577  }
578  else if (*px < *px2) {
579  // zoom out
581  if (g_PrefsDlg.m_nTextureScale < 1) {
583  }
584  }
585 
586  *px2 = *px;
587  CPoint screen = cursor;
588  ClientToScreen(&screen);
589  SetCursorPos(screen.x, screen.y);
590  //Sys_SetCursorPos(cursor.x, cursor.y);
591  InvalidateRect(NULL, false);
592  UpdateWindow();
593  }
594  else if (point.y != cursor.y || point.x != cursor.x) {
595  origin.y += (point.y - cursor.y) * scale;
596  if (origin.y > 0) {
597  origin.y = 0;
598  }
599 
600  //Sys_SetCursorPos(cursor.x, cursor.y);
601  CPoint screen = cursor;
602  ClientToScreen(&screen);
603  SetCursorPos(screen.x, screen.y);
605  SetScrollPos(SB_VERT, abs(origin.y));
606  }
607 
608  InvalidateRect(NULL, false);
609  UpdateWindow();
610  }
611  }
612 
613  return;
614  }
615 }
616 
617 /*
618  =======================================================================================================================
619  =======================================================================================================================
620  */
622 }
623 
624 
625 void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, bool bSetSelection) {
626 
627  if (texdef->name[0] == '(') {
628  Sys_Status("Can't select an entity texture\n", 0);
629  return;
630  }
631 
632  g_qeglobals.d_texturewin.texdef = *texdef;
633 
634  //
635  // store the texture coordinates for new brush primitive mode be sure that all the
636  // callers are using the default 2x2 texture
637  //
638  if (g_qeglobals.m_bBrushPrimitMode) {
639  g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
640  }
641 
642  g_dlgFind.updateTextures(texdef->name);
643 
644  if (!g_dlgFind.isOpen() && bSetSelection) {
645  Select_SetTexture(texdef, brushprimit_texdef, bFitScale);
646  }
647 
649 
650  if ( g_Inspectors->mediaDlg.IsWindowVisible() ) {
651  g_Inspectors->mediaDlg.SelectCurrentItem(true, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
652  }
653 
654  g_qeglobals.d_texturewin.texdef = *texdef;
655  // store the texture coordinates for new brush primitive mode be sure that all the
656  // callers are using the default 2x2 texture
657  //
658  if (g_qeglobals.m_bBrushPrimitMode) {
659  g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
660  }
661 
662 
663  Sys_UpdateWindows(W_TEXTURE);
664 
665 
666 }
667 
668 const idMaterial *Texture_LoadLight(const char *name) {
669  return declManager->FindMaterial(name);
670 }
671 
672 
673 void Texture_ClearInuse(void) {
674 }
675 
676 void Texture_ShowAll(void) {
678  for (int i = 0; i < count; i++) {
679  const idMaterial *mat = declManager->MaterialByIndex(i, false);
680  if ( mat ) {
682  }
683  }
684  g_Inspectors->SetWindowText("Textures (all)");
685  Sys_UpdateWindows(W_TEXTURE);
686 }
687 
690  for (int i = 0; i < count; i++) {
691  const idMaterial *mat = declManager->MaterialByIndex(i, false);
692  if ( mat ) {
694  }
695  }
696  g_Inspectors->SetWindowText("Textures (all)");
697  Sys_UpdateWindows(W_TEXTURE);
698 }
699 
700 const idMaterial *Texture_ForName(const char *name) {
701  const idMaterial *mat = declManager->FindMaterial(name);
702  if ( !mat ) {
703  mat = declManager->FindMaterial("_default");
704  } else {
706  }
707  return mat;
708 }
709 
710 void Texture_ShowInuse(void) {
711  Texture_HideAll();
712 
713  brush_t *b;
714  for (b = active_brushes.next; b != NULL && b != &active_brushes; b = b->next) {
715  if (b->pPatch) {
716  Texture_ForName(b->pPatch->d_texture->GetName());
717  } else {
718  for (face_t *f = b->brush_faces; f; f = f->next) {
719  Texture_ForName(f->texdef.name);
720  }
721  }
722  }
723 
724  for (b = selected_brushes.next; b != NULL && b != &selected_brushes; b = b->next) {
725  if (b->pPatch) {
726  Texture_ForName(b->pPatch->d_texture->GetName());
727  } else {
728  for (face_t *f = b->brush_faces; f; f = f->next) {
729  Texture_ForName(f->texdef.name);
730  }
731  }
732  }
733 
734  Sys_UpdateWindows(W_TEXTURE);
735 
736  g_Inspectors->SetWindowText("Textures (in use)");
737 }
738 
739 void Texture_Cleanup(CStringList *pList) {
740 }
741 
742 int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
743 bool texture_showinuse = true;
744 
745 
746 /*
747  =======================================================================================================================
748  Texture_SetMode
749  =======================================================================================================================
750  */
751 void Texture_SetMode(int iMenu) {
752  int iMode;
753  HMENU hMenu;
754  bool texturing = true;
755 
756  hMenu = GetMenu(g_pParentWnd->GetSafeHwnd());
757 
758  switch (iMenu)
759  {
760  case ID_VIEW_NEAREST:
761  iMode = GL_NEAREST;
762  break;
764  iMode = GL_NEAREST_MIPMAP_NEAREST;
765  break;
766  case ID_VIEW_LINEAR:
767  iMode = GL_NEAREST_MIPMAP_LINEAR;
768  break;
769  case ID_VIEW_BILINEAR:
770  iMode = GL_LINEAR;
771  break;
773  iMode = GL_LINEAR_MIPMAP_NEAREST;
774  break;
775  case ID_VIEW_TRILINEAR:
776  iMode = GL_LINEAR_MIPMAP_LINEAR;
777  break;
778 
780  iMode = 0;
781  texturing = false;
782  break;
783 
785  default:
786  iMode = 0;
787  texturing = false;
788  break;
789  }
790 
791  CheckMenuItem(hMenu, ID_VIEW_NEAREST, MF_BYCOMMAND | MF_UNCHECKED);
792  CheckMenuItem(hMenu, ID_VIEW_NEARESTMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);
793  CheckMenuItem(hMenu, ID_VIEW_LINEAR, MF_BYCOMMAND | MF_UNCHECKED);
794  CheckMenuItem(hMenu, ID_VIEW_BILINEARMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);
795  CheckMenuItem(hMenu, ID_VIEW_BILINEAR, MF_BYCOMMAND | MF_UNCHECKED);
796  CheckMenuItem(hMenu, ID_VIEW_TRILINEAR, MF_BYCOMMAND | MF_UNCHECKED);
797  CheckMenuItem(hMenu, ID_TEXTURES_WIREFRAME, MF_BYCOMMAND | MF_UNCHECKED);
798  CheckMenuItem(hMenu, ID_TEXTURES_FLATSHADE, MF_BYCOMMAND | MF_UNCHECKED);
799 
800  CheckMenuItem(hMenu, iMenu, MF_BYCOMMAND | MF_CHECKED);
801 
802  g_qeglobals.d_savedinfo.iTexMenu = iMenu;
803  texture_mode = iMode;
804 
805  if (!texturing && iMenu == ID_TEXTURES_WIREFRAME) {
808  Sys_UpdateWindows(W_ALL);
809  return;
810  }
811  else if (!texturing && iMenu == ID_TEXTURES_FLATSHADE) {
814  Sys_UpdateWindows(W_ALL);
815  return;
816  }
817 
821  }
822 
823  Sys_UpdateWindows(W_ALL);
824 }
825 
826 
827 
829  // scroll origin so the texture is completely on screen
830  // init stuff
831  current.x = 8;
832  current.y = -8;
833  currentRow = 0;
834  currentIndex = 0;
835 
836  while (1) {
837  const idMaterial *mat = NextPos();
838  if (mat == NULL) {
839  break;
840  }
841 
844 
845  if ( !idStr::Icmp(name, mat->GetName()) ) {
846  if (current.y > origin.y) {
847  origin.y = current.y;
848  Sys_UpdateWindows(W_TEXTURE);
849  return;
850  }
851 
852  if (current.y - height - 2 * FONT_HEIGHT < origin.y - rectClient.Height()) {
853  origin.y = current.y - height - 2 * FONT_HEIGHT + rectClient.Height();
854  Sys_UpdateWindows(W_TEXTURE);
855  return;
856  }
857 
858  return;
859  }
860  }
861 
862 }
863 
864 
865 BOOL CNewTexWnd::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) {
866  static char tip[1024];
867  CPoint point;
868  GetCursorPos(&point);
869  const idMaterial *mat = getMaterialAtPoint(point);
870 
871  if (mat) {
872  TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
873  strcpy(tip, mat->GetDescription());
874  pTTT->lpszText = tip;
875  pTTT->hinst = NULL;
876  return(TRUE);
877  }
878  return(FALSE);
879 }
880 
881 int CNewTexWnd::OnToolHitTest(CPoint point, TOOLINFO * pTI)
882 {
883  const idMaterial *mat = getMaterialAtPoint(point);
884  if (mat) {
885  return 0;
886  }
887  return -1;
888 }
889 
890 BOOL CNewTexWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
891 {
892  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
893  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
894  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
895  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
896  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
897  OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
898  return TRUE;
899 }
900 
902 {
903  if (pMsg->message == WM_KEYDOWN) {
904  if (pMsg->wParam == VK_ESCAPE) {
905  g_pParentWnd->GetCamera()->SetFocus();
906  Select_Deselect();
907  return TRUE;
908  }
909  if (pMsg->wParam == VK_RIGHT || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN) {
910  g_pParentWnd->PostMessage(WM_KEYDOWN, pMsg->wParam);
911  return TRUE;
912  }
913  }
914  return CWnd::PreTranslateMessage(pMsg);
915 }
916 
917 void CNewTexWnd::OnSetFocus(CWnd* pOldWnd)
918 {
919  CWnd::OnSetFocus(pOldWnd);
920  Invalidate();
921  RedrawWindow();
922 }
CMainFrame * g_pParentWnd
Definition: MainFrm.cpp:73
BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
Definition: NewTexWnd.cpp:865
idImage * GetEditorImage(void) const
Definition: Material.cpp:190
void WINAPI Sys_UpdateWindows(int nBits)
Definition: MainFrm.cpp:3974
virtual ~CNewTexWnd()
Definition: NewTexWnd.cpp:72
#define qglScissor
Definition: qgl_linked.h:280
afx_msg void OnMButtonUp(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:534
void EnsureTextureIsVisible(const char *name)
Definition: NewTexWnd.cpp:828
const idMaterial * getMaterialAtPoint(CPoint point)
Definition: NewTexWnd.cpp:453
void SelectCurrentItem(bool collapse, const char *name, int id)
CFindTextureDlg & g_dlgFind
#define qglDisable
Definition: qgl_linked.h:92
afx_msg void OnSize(UINT nType, int cx, int cy)
Definition: NewTexWnd.cpp:149
void Map_BuildBrushData(void)
Definition: EditorMap.cpp:121
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Definition: NewTexWnd.cpp:128
bool m_bNeedRange
Definition: NewTexWnd.h:80
brush_t selected_brushes
Definition: EditorMap.cpp:40
int currentIndex
Definition: NewTexWnd.h:90
afx_msg void OnLButtonDown(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:484
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Definition: NewTexWnd.cpp:890
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
brush_t active_brushes
Definition: EditorMap.cpp:39
HGLRC hGLRC
Definition: win_local.h:122
#define qglClearColor
Definition: qgl_linked.h:41
#define ID_VIEW_BILINEAR
#define ID_TEXTURES_FLATSHADE
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:4804
float fDiff(float f1, float f2)
Definition: XYWnd.cpp:117
void LoadMaterials()
Definition: NewTexWnd.cpp:621
DWORD
Definition: win_qgl.cpp:61
GLenum GLsizei n
Definition: glext.h:3705
afx_msg void OnMButtonDown(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:507
void Texture_ShowAll(void)
Definition: NewTexWnd.cpp:676
CPoint current
Definition: NewTexWnd.h:87
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
Definition: NewTexWnd.cpp:380
#define ID_VIEW_NEARESTMIPMAP
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
Definition: NewTexWnd.cpp:178
#define qglBegin
Definition: qgl_linked.h:33
void Sys_Status(const char *psz, int part)
Definition: Radiant.cpp:465
camera_t & Camera()
Definition: CamWnd.h:90
const char * GetName(void) const
Definition: DeclManager.h:140
case const float
Definition: Callbacks.cpp:62
HGLRC hglrcTexture
Definition: NewTexWnd.h:81
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
Definition: NewTexWnd.cpp:186
IMPLEMENT_DYNCREATE(CNewTexWnd, CWnd)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
#define qglViewport
Definition: qgl_linked.h:364
bool Sys_KeyDown(int key)
Definition: NewTexWnd.cpp:49
void Texture_ClearInuse(void)
Definition: NewTexWnd.cpp:673
int i
Definition: process.py:33
#define BOOL
Definition: mprintf.c:71
virtual BOOL PreTranslateMessage(MSG *pMsg)
Definition: NewTexWnd.cpp:901
int OnToolHitTest(CPoint point, TOOLINFO *pTI)
Definition: NewTexWnd.cpp:881
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:552
void Texture_HideAll()
Definition: NewTexWnd.cpp:688
int Icmp(const char *text) const
Definition: Str.h:667
int currentRow
Definition: NewTexWnd.h:89
afx_msg void OnRButtonUp(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:542
CPoint origin
Definition: NewTexWnd.h:84
camera_draw_mode draw_mode
Definition: CamWnd.h:51
#define ID_VIEW_NEAREST
#define ID_TEXTURES_WIREFRAME
void UpdatePatchInspector()
int texture_mode
Definition: NewTexWnd.cpp:742
void Error(const char *pFormat,...)
Definition: cmdlib.cpp:45
static bool isOpen()
GLuint GLuint GLsizei count
Definition: glext.h:2845
CCamWnd * GetCamera()
Definition: MainFrm.h:123
afx_msg void OnParentNotify(UINT message, LPARAM lParam)
Definition: NewTexWnd.cpp:159
bool IsValid(void) const
Definition: DeclManager.h:154
void SetMaterialFlag(const int flag) const
Definition: Material.h:488
const idMaterial * Texture_ForName(const char *name)
Definition: NewTexWnd.cpp:700
#define ID_VIEW_TRILINEAR
afx_msg void OnSetFocus(CWnd *pOldWnd)
Definition: NewTexWnd.cpp:917
#define qglPolygonMode
Definition: qgl_linked.h:229
idCommon * common
Definition: Common.cpp:206
#define NULL
Definition: Lib.h:88
#define qglTexCoord2f
Definition: qgl_linked.h:296
#define qglOrtho
Definition: qgl_linked.h:218
#define qglEnd
Definition: qgl_linked.h:103
idImageManager * globalImages
Definition: Image_init.cpp:74
#define qglColor3f
Definition: qgl_linked.h:50
afx_msg void OnPaint()
Definition: NewTexWnd.cpp:249
void HandleKey(UINT nChar, UINT nRepCnt, UINT nFlags, bool bDown=true)
Definition: MainFrm.h:70
BOOL m_bHiColorTextures
Definition: PrefsDlg.h:91
const idMaterial * Texture_LoadLight(const char *name)
Definition: NewTexWnd.cpp:668
Definition: CamWnd.h:37
GLenum GLsizei width
Definition: glext.h:2846
virtual void Printf(const char *fmt,...) id_attribute((format(printf
CInspectorDialog * g_Inspectors
afx_msg void OnRButtonDown(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:516
GLenum GLsizei GLsizei height
Definition: glext.h:2856
idDeclManager * declManager
int uploadHeight
Definition: Image.h:249
GLubyte GLubyte b
Definition: glext.h:4662
virtual BOOL DestroyWindow()
Definition: NewTexWnd.cpp:425
virtual int GetNumDecls(declType_t type)=0
void Texture_Cleanup(CStringList *pList)
Definition: NewTexWnd.cpp:739
void Texture_SetMode(int iMenu)
Definition: NewTexWnd.cpp:751
int uploadWidth
Definition: Image.h:249
bool texture_showinuse
Definition: NewTexWnd.cpp:743
int m_nTextureScale
Definition: PrefsDlg.h:111
CDialogTextures mediaDlg
void Texture_ShowInuse(void)
Definition: NewTexWnd.cpp:710
tuple f
Definition: idal.py:89
void UpdateSurfaceDialog()
Definition: SurfaceDlg.cpp:273
#define qglLineWidth
Definition: qgl_linked.h:184
virtual const idMaterial * MaterialByIndex(int index, bool forceParse=true)=0
CDC * hdcTexture
Definition: NewTexWnd.h:82
const GLcharARB * name
Definition: glext.h:3629
CPoint draw
Definition: NewTexWnd.h:85
CPrefsDlg & g_PrefsDlg
Definition: MainFrm.cpp:75
#define ID_VIEW_BILINEARMIPMAP
#define qglClear
Definition: qgl_linked.h:39
#define qglVertex2f
Definition: qgl_linked.h:341
#define FALSE
Definition: mprintf.c:70
#define qglFinish
Definition: qgl_linked.h:118
bool TestMaterialFlag(const int flag) const
Definition: Material.h:494
const char * GetDescription(void) const
Definition: Material.h:506
void ClearMaterialFlag(const int flag) const
Definition: Material.h:491
static void updateTextures(const char *p)
CPoint cursor
Definition: NewTexWnd.h:83
#define qglCallLists
Definition: qgl_linked.h:38
CRect rectClient
Definition: NewTexWnd.h:88
#define TRUE
Definition: mprintf.c:69
#define qglLoadIdentity
Definition: qgl_linked.h:186
void UpdatePrefs()
Definition: NewTexWnd.cpp:167
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CCreateContext *pContext=NULL)
Definition: NewTexWnd.cpp:435
Win32Vars_t win32
Definition: win_main.cpp:65
void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, bool bSetSelection)
Definition: NewTexWnd.cpp:625
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
Definition: NewTexWnd.cpp:525
void Bind()
const idMaterial * NextPos()
Definition: NewTexWnd.cpp:194
#define qglMatrixMode
Definition: qgl_linked.h:203
BOOL m_bTextureScrollbar
Definition: PrefsDlg.h:93
#define qglRasterPos2f
Definition: qgl_linked.h:243
#define ID_VIEW_LINEAR