TextureBar.cpp (6012B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 //++timo TODO : the whole CTextureBar has to be modified for the new texture code 23 24 // TextureBar.cpp : implementation file 25 // 26 27 #include "stdafx.h" 28 #include "Radiant.h" 29 #include "TextureBar.h" 30 31 #ifdef _DEBUG 32 #define new DEBUG_NEW 33 #undef THIS_FILE 34 static char THIS_FILE[] = __FILE__; 35 #endif 36 37 ///////////////////////////////////////////////////////////////////////////// 38 // CTextureBar dialog 39 40 41 CTextureBar::CTextureBar() 42 : CDialogBar() 43 { 44 //{{AFX_DATA_INIT(CTextureBar) 45 m_nHShift = 0; 46 m_nHScale = 0; 47 m_nRotate = 0; 48 m_nVShift = 0; 49 m_nVScale = 0; 50 m_nRotateAmt = 45; 51 //}}AFX_DATA_INIT 52 } 53 54 55 void CTextureBar::DoDataExchange(CDataExchange* pDX) 56 { 57 CDialogBar::DoDataExchange(pDX); 58 //{{AFX_DATA_MAP(CTextureBar) 59 DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate); 60 DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale); 61 DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift); 62 DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale); 63 DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift); 64 DDX_Text(pDX, IDC_HSHIFT, m_nHShift); 65 DDX_Text(pDX, IDC_HSCALE, m_nHScale); 66 DDX_Text(pDX, IDC_ROTATE, m_nRotate); 67 DDX_Text(pDX, IDC_VSHIFT, m_nVShift); 68 DDX_Text(pDX, IDC_VSCALE, m_nVScale); 69 DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt); 70 //}}AFX_DATA_MAP 71 } 72 73 74 BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar) 75 //{{AFX_MSG_MAP(CTextureBar) 76 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift) 77 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift) 78 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale) 79 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale) 80 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate) 81 ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint) 82 ON_WM_CREATE() 83 ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff) 84 //}}AFX_MSG_MAP 85 END_MESSAGE_MAP() 86 87 ///////////////////////////////////////////////////////////////////////////// 88 // CTextureBar message handlers 89 90 void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult) 91 { 92 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 93 *pResult = 0; 94 95 if (pNMUpDown->iDelta < 0) 96 Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0); 97 else 98 Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0); 99 GetSurfaceAttributes(); 100 } 101 102 void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult) 103 { 104 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 105 // TODO: Add your control notification handler code here 106 107 *pResult = 0; 108 if (pNMUpDown->iDelta < 0) 109 Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak)); 110 else 111 Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak)); 112 GetSurfaceAttributes(); 113 } 114 115 void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult) 116 { 117 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 118 // TODO: Add your control notification handler code here 119 120 *pResult = 0; 121 if (pNMUpDown->iDelta < 0) 122 Select_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0); 123 else 124 Select_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0); 125 GetSurfaceAttributes(); 126 } 127 128 void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult) 129 { 130 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 131 // TODO: Add your control notification handler code here 132 133 *pResult = 0; 134 if (pNMUpDown->iDelta < 0) 135 Select_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak)); 136 else 137 Select_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak)); 138 GetSurfaceAttributes(); 139 } 140 141 void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult) 142 { 143 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 144 *pResult = 0; 145 UpdateData(TRUE); 146 if (pNMUpDown->iDelta < 0) 147 Select_RotateTexture(abs(m_nRotateAmt)); 148 else 149 Select_RotateTexture(-abs(m_nRotateAmt)); 150 GetSurfaceAttributes(); 151 } 152 153 154 void CTextureBar::OnSelectionPrint() 155 { 156 // TODO: Add your command handler code here 157 158 } 159 160 int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 161 { 162 if (CDialogBar::OnCreate(lpCreateStruct) == -1) 163 return -1; 164 return 0; 165 } 166 167 168 void CTextureBar::OnBtnApplytexturestuff() 169 { 170 SetSurfaceAttributes(); 171 } 172 173 void CTextureBar::GetSurfaceAttributes() 174 { 175 texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef; 176 177 if (pt) 178 { 179 m_nHShift = pt->shift[0]; 180 m_nVShift = pt->shift[1]; 181 m_nHScale = pt->scale[0]; 182 m_nVScale = pt->scale[1]; 183 m_nRotate = pt->rotate; 184 UpdateData(FALSE); 185 } 186 } 187 188 //++timo implement brush primitive here 189 void CTextureBar::SetSurfaceAttributes() 190 { 191 if (g_ptrSelectedFaces.GetSize() > 0) 192 { 193 if (g_qeglobals.m_bBrushPrimitMode) 194 { 195 Sys_Printf("Warning : brush primitive mode not implemented in CTextureBar"); 196 } 197 face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)); 198 199 texdef_t* pt = &selFace->texdef; 200 UpdateData(TRUE); 201 pt->shift[0] = m_nHShift; 202 pt->shift[1] = m_nVShift; 203 pt->scale[0] = m_nHScale; 204 pt->scale[1] = m_nVScale; 205 pt->rotate = m_nRotate; 206 Sys_UpdateWindows(W_CAMERA); 207 } 208 }