doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TextureBar.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 "TextureBar.h"
35 
36 //++timo TODO : the whole CTextureBar has to be modified for the new texture code
37 
38 #ifdef _DEBUG
39 #define new DEBUG_NEW
40 #undef THIS_FILE
41 static char THIS_FILE[] = __FILE__;
42 #endif
43 
45 // CTextureBar dialog
46 
47 
49  : CDialogBar()
50 {
51  //{{AFX_DATA_INIT(CTextureBar)
52  m_nHShift = 0;
53  m_nHScale = 0;
54  m_nRotate = 0;
55  m_nVShift = 0;
56  m_nVScale = 0;
57  m_nRotateAmt = 45;
58  //}}AFX_DATA_INIT
59 }
60 
61 
62 void CTextureBar::DoDataExchange(CDataExchange* pDX)
63 {
64  CDialogBar::DoDataExchange(pDX);
65  //{{AFX_DATA_MAP(CTextureBar)
66  DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);
67  DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);
68  DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);
69  DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);
70  DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);
71  DDX_Text(pDX, IDC_HSHIFT, m_nHShift);
72  DDX_Text(pDX, IDC_HSCALE, m_nHScale);
73  DDX_Text(pDX, IDC_ROTATE, m_nRotate);
74  DDX_Text(pDX, IDC_VSHIFT, m_nVShift);
75  DDX_Text(pDX, IDC_VSCALE, m_nVScale);
76  DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);
77  //}}AFX_DATA_MAP
78 }
79 
80 
81 BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)
82  //{{AFX_MSG_MAP(CTextureBar)
83  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)
84  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)
85  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)
86  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)
87  ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)
88  ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
89  ON_WM_CREATE()
90  ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)
91  //}}AFX_MSG_MAP
92 END_MESSAGE_MAP()
93 
95 // CTextureBar message handlers
96 
97 void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult)
98 {
99  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
100  *pResult = 0;
101 
102  if (pNMUpDown->iDelta < 0)
103  Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
104  else
105  Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
106  GetSurfaceAttributes();
107 }
108 
109 void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult)
110 {
111  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
112  // TODO: Add your control notification handler code here
113 
114  *pResult = 0;
115  if (pNMUpDown->iDelta < 0)
116  Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
117  else
118  Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
120 }
121 
122 void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult)
123 {
124  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
125  // TODO: Add your control notification handler code here
126 
127  *pResult = 0;
128  if (pNMUpDown->iDelta < 0)
129  Select_ScaleTexture((float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
130  else
131  Select_ScaleTexture((float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
133 }
134 
135 void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult)
136 {
137  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
138  // TODO: Add your control notification handler code here
139 
140  *pResult = 0;
141  if (pNMUpDown->iDelta < 0)
142  Select_ScaleTexture(0, (float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
143  else
144  Select_ScaleTexture(0, (float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
146 }
147 
148 void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult)
149 {
150  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
151  *pResult = 0;
152  UpdateData(TRUE);
153  if (pNMUpDown->iDelta < 0)
155  else
158 }
159 
160 
162 {
163  // TODO: Add your command handler code here
164 
165 }
166 
167 int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
168 {
169  if (CDialogBar::OnCreate(lpCreateStruct) == -1)
170  return -1;
171  return 0;
172 }
173 
174 
176 {
178 }
179 
181 {
182  texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;
183 
184  if (pt)
185  {
186  m_nHShift = pt->shift[0];
187  m_nVShift = pt->shift[1];
188  m_nHScale = pt->scale[0];
189  m_nVScale = pt->scale[1];
190  m_nRotate = pt->rotate;
191  UpdateData(FALSE);
192  }
193 }
194 
195 //++timo implement brush primitive here
197 {
198  if (g_ptrSelectedFaces.GetSize() > 0)
199  {
200  if (g_qeglobals.m_bBrushPrimitMode)
201  {
202  common->Printf("Warning : brush primitive mode not implemented in CTextureBar");
203  }
204  face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
205 
206  texdef_t* pt = &selFace->texdef;
207  UpdateData(TRUE);
208  pt->shift[0] = m_nHShift;
209  pt->shift[1] = m_nVShift;
210  pt->scale[0] = m_nHScale;
211  pt->scale[1] = m_nVScale;
212  pt->rotate = m_nRotate;
213  Sys_UpdateWindows(W_CAMERA);
214  }
215 }
void WINAPI Sys_UpdateWindows(int nBits)
Definition: MainFrm.cpp:3974
#define IDC_ROTATE
afx_msg void OnDeltaposSpinRotate(NMHDR *pNMHDR, LRESULT *pResult)
Definition: TextureBar.cpp:148
CSpinButtonCtrl m_spinVScale
Definition: TextureBar.h:52
afx_msg void OnDeltaposSpinHScale(NMHDR *pNMHDR, LRESULT *pResult)
Definition: TextureBar.cpp:122
int m_nHShift
Definition: TextureBar.h:56
#define IDC_HSCALE
void GetSurfaceAttributes()
Definition: TextureBar.cpp:180
#define IDC_SPIN_VSCALE
CSpinButtonCtrl m_spinHScale
Definition: TextureBar.h:54
afx_msg void OnSelectionPrint()
Definition: TextureBar.cpp:161
int m_nRotate
Definition: TextureBar.h:58
#define ID_SELECTION_PRINT
int m_nHScale
Definition: TextureBar.h:57
afx_msg void OnBtnApplytexturestuff()
Definition: TextureBar.cpp:175
#define IDC_SPIN_HSHIFT
void SetSurfaceAttributes()
Definition: TextureBar.cpp:196
#define IDC_EDIT_ROTATEAMT
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Definition: TextureBar.cpp:167
afx_msg void OnDeltaposSpinVshift(NMHDR *pNMHDR, LRESULT *pResult)
Definition: TextureBar.cpp:109
idCommon * common
Definition: Common.cpp:206
int m_nRotateAmt
Definition: TextureBar.h:61
#define IDC_VSHIFT
void Select_RotateTexture(float amt, bool absolute)
CPtrArray & g_ptrSelectedFaces
CSpinButtonCtrl m_spinHShift
Definition: TextureBar.h:55
virtual void Printf(const char *fmt,...) id_attribute((format(printf
#define IDC_HSHIFT
virtual void DoDataExchange(CDataExchange *pDX)
Definition: TextureBar.cpp:62
#define IDC_SPIN_VSHIFT
#define IDC_VSCALE
CSpinButtonCtrl m_spinVShift
Definition: TextureBar.h:53
#define IDC_BTN_APPLYTEXTURESTUFF
#define FALSE
Definition: mprintf.c:70
#define IDC_SPIN_ROTATE
afx_msg void OnDeltaposSpinVScale(NMHDR *pNMHDR, LRESULT *pResult)
Definition: TextureBar.cpp:135
#define TRUE
Definition: mprintf.c:69
int m_nVShift
Definition: TextureBar.h:59
CSpinButtonCtrl m_spinRotate
Definition: TextureBar.h:51
#define IDC_SPIN_HSCALE
int m_nVScale
Definition: TextureBar.h:60