29 #include "../../idlib/precompiled.h"
37 #include "../../renderer/tr_local.h"
42 static char THIS_FILE[] = __FILE__;
50 return ( ( ::GetAsyncKeyState( key ) & 0x8000 ) != 0 );
102 HINSTANCE hInstance = AfxGetInstanceHandle();
103 if (::GetClassInfo(hInstance, TEXTURE_WINDOW_CLASS, &wc) ==
FALSE) {
105 memset(&wc, 0,
sizeof(wc));
106 wc.style = CS_NOCLOSE | CS_PARENTDC;
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");
115 cs.lpszClass = TEXTURE_WINDOW_CLASS;
117 if (cs.style != QE3_CHILDSTYLE && cs.style != QE3_STYLE) {
118 cs.style = QE3_SPLITTER_STYLE;
121 return CWnd::PreCreateWindow(cs);
129 if (CWnd::OnCreate(lpCreateStruct) == -1) {
137 QEW_SetupPixelFormat(
hdcTexture->m_hDC,
false);
139 EnableToolTips(
TRUE);
140 EnableTrackingToolTips(
TRUE);
150 CWnd::OnSize(nType, cx, cy);
160 CWnd::OnParentNotify(message, lParam);
253 int nOld = g_qeglobals.d_texturewin.m_nTotalHeight;
256 if (!qwglMakeCurrent(dc.GetSafeHdc(),
win32.
hGLRC)) {
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],
272 qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
309 QE_CheckOpenGLForErrors();
344 for (name = mat->
GetName(); *name && *name !=
'/' && *name !=
'\\'; name++) {
359 g_qeglobals.d_texturewin.m_nTotalHeight = abs(
draw.y) + 100;
364 qwglSwapBuffers(dc.GetSafeHdc());
365 TRACE(
"Texture Paint\n");
370 SetScrollRange(SB_VERT, 0, g_qeglobals.d_texturewin.m_nTotalHeight,
TRUE);
381 CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
383 int n = GetScrollPos(SB_VERT);
387 n = (n - 15 > 0) ? n - 15 : 0;
392 n = (n + 15 < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + 15 : n;
397 n = (n - g_qeglobals.d_texturewin.height > 0) ? n - g_qeglobals.d_texturewin.height : 0;
402 n = (n + g_qeglobals.d_texturewin.height < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + g_qeglobals.d_texturewin.height : n;
406 case SB_THUMBPOSITION: {
411 case SB_THUMBTRACK: {
417 SetScrollPos(SB_VERT, n);
427 return CWnd::DestroyWindow();
436 LPCTSTR lpszClassName,
437 LPCTSTR lpszWindowName,
442 CCreateContext *pContext
444 BOOL ret = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
446 hdcTexture = GetDC();
447 QEW_SetupPixelFormat(hdcTexture->m_hDC,
false);
473 if (point.x >
draw.x && point.x -
draw.x < width && my <
draw.y &&
draw.y - my < height + FONT_HEIGHT) {
493 Select_SetDefaultTexture(mat, fitScale,
true);
508 CWnd::OnMButtonDown(nFlags, point);
526 CWnd::OnLButtonUp(nFlags, point);
535 CWnd::OnMButtonUp(nFlags, point);
543 CWnd::OnRButtonUp(nFlags, point);
546 extern float fDiff(
float f1,
float f2);
561 if (point.y !=
cursor.y) {
578 else if (*px < *px2) {
588 ClientToScreen(&screen);
589 SetCursorPos(screen.x, screen.y);
591 InvalidateRect(
NULL,
false);
602 ClientToScreen(&screen);
603 SetCursorPos(screen.x, screen.y);
605 SetScrollPos(SB_VERT, abs(
origin.y));
608 InvalidateRect(
NULL,
false);
625 void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef,
bool bFitScale,
bool bSetSelection) {
627 if (texdef->name[0] ==
'(') {
628 Sys_Status(
"Can't select an entity texture\n", 0);
632 g_qeglobals.d_texturewin.texdef = *texdef;
638 if (g_qeglobals.m_bBrushPrimitMode) {
639 g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
645 Select_SetTexture(texdef, brushprimit_texdef, bFitScale);
654 g_qeglobals.d_texturewin.texdef = *texdef;
658 if (g_qeglobals.m_bBrushPrimitMode) {
659 g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
718 for (face_t *
f = b->brush_faces;
f;
f =
f->next) {
728 for (face_t *
f = b->brush_faces;
f;
f =
f->next) {
754 bool texturing =
true;
764 iMode = GL_NEAREST_MIPMAP_NEAREST;
767 iMode = GL_NEAREST_MIPMAP_LINEAR;
773 iMode = GL_LINEAR_MIPMAP_NEAREST;
776 iMode = GL_LINEAR_MIPMAP_LINEAR;
793 CheckMenuItem(hMenu,
ID_VIEW_LINEAR, MF_BYCOMMAND | MF_UNCHECKED);
800 CheckMenuItem(hMenu, iMenu, MF_BYCOMMAND | MF_CHECKED);
802 g_qeglobals.d_savedinfo.iTexMenu = iMenu;
803 texture_mode = iMode;
866 static char tip[1024];
868 GetCursorPos(&point);
872 TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
874 pTTT->lpszText = tip;
903 if (pMsg->message == WM_KEYDOWN) {
904 if (pMsg->wParam == VK_ESCAPE) {
909 if (pMsg->wParam == VK_RIGHT || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN) {
914 return CWnd::PreTranslateMessage(pMsg);
919 CWnd::OnSetFocus(pOldWnd);
CMainFrame * g_pParentWnd
BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
idImage * GetEditorImage(void) const
void WINAPI Sys_UpdateWindows(int nBits)
afx_msg void OnMButtonUp(UINT nFlags, CPoint point)
void EnsureTextureIsVisible(const char *name)
const idMaterial * getMaterialAtPoint(CPoint point)
void SelectCurrentItem(bool collapse, const char *name, int id)
CFindTextureDlg & g_dlgFind
afx_msg void OnSize(UINT nType, int cx, int cy)
void Map_BuildBrushData(void)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point)
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
CONST PIXELFORMATDESCRIPTOR UINT
#define ID_TEXTURES_FLATSHADE
GLenum GLenum GLenum GLenum GLenum scale
float fDiff(float f1, float f2)
afx_msg void OnMButtonDown(UINT nFlags, CPoint point)
void Texture_ShowAll(void)
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
#define ID_VIEW_NEARESTMIPMAP
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
void Sys_Status(const char *psz, int part)
const char * GetName(void) const
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
IMPLEMENT_DYNCREATE(CNewTexWnd, CWnd)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
bool Sys_KeyDown(int key)
void Texture_ClearInuse(void)
virtual BOOL PreTranslateMessage(MSG *pMsg)
int OnToolHitTest(CPoint point, TOOLINFO *pTI)
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
int Icmp(const char *text) const
afx_msg void OnRButtonUp(UINT nFlags, CPoint point)
camera_draw_mode draw_mode
#define ID_TEXTURES_WIREFRAME
void UpdatePatchInspector()
void Error(const char *pFormat,...)
GLuint GLuint GLsizei count
afx_msg void OnParentNotify(UINT message, LPARAM lParam)
void SetMaterialFlag(const int flag) const
const idMaterial * Texture_ForName(const char *name)
#define ID_VIEW_TRILINEAR
afx_msg void OnSetFocus(CWnd *pOldWnd)
idImageManager * globalImages
void HandleKey(UINT nChar, UINT nRepCnt, UINT nFlags, bool bDown=true)
const idMaterial * Texture_LoadLight(const char *name)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
CInspectorDialog * g_Inspectors
afx_msg void OnRButtonDown(UINT nFlags, CPoint point)
GLenum GLsizei GLsizei height
idDeclManager * declManager
virtual BOOL DestroyWindow()
virtual int GetNumDecls(declType_t type)=0
void Texture_Cleanup(CStringList *pList)
void Texture_SetMode(int iMenu)
void Texture_ShowInuse(void)
void UpdateSurfaceDialog()
virtual const idMaterial * MaterialByIndex(int index, bool forceParse=true)=0
#define ID_VIEW_BILINEARMIPMAP
bool TestMaterialFlag(const int flag) const
const char * GetDescription(void) const
void ClearMaterialFlag(const int flag) const
static void updateTextures(const char *p)
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CCreateContext *pContext=NULL)
void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, bool bSetSelection)
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
const idMaterial * NextPos()