aboutsummaryrefslogtreecommitdiffstats
path: root/q3radiant/TextureBar.cpp
blob: 4a48e26f9217313f680a6f8bd352ac029511eb8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/
//++timo TODO : the whole CTextureBar has to be modified for the new texture code

// TextureBar.cpp : implementation file
//

#include "stdafx.h"
#include "Radiant.h"
#include "TextureBar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTextureBar dialog


CTextureBar::CTextureBar()
	: CDialogBar()
{
	//{{AFX_DATA_INIT(CTextureBar)
	m_nHShift = 0;
	m_nHScale = 0;
	m_nRotate = 0;
	m_nVShift = 0;
	m_nVScale = 0;
	m_nRotateAmt = 45;
	//}}AFX_DATA_INIT
}


void CTextureBar::DoDataExchange(CDataExchange* pDX)
{
	CDialogBar::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTextureBar)
	DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);
	DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);
	DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);
	DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);
	DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);
	DDX_Text(pDX, IDC_HSHIFT, m_nHShift);
	DDX_Text(pDX, IDC_HSCALE, m_nHScale);
	DDX_Text(pDX, IDC_ROTATE, m_nRotate);
	DDX_Text(pDX, IDC_VSHIFT, m_nVShift);
	DDX_Text(pDX, IDC_VSCALE, m_nVScale);
	DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)
	//{{AFX_MSG_MAP(CTextureBar)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)
	ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
	ON_WM_CREATE()
	ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTextureBar message handlers

void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	*pResult = 0;

  if (pNMUpDown->iDelta < 0)
    Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  else
    Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  GetSurfaceAttributes();
}

void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
  if (pNMUpDown->iDelta < 0)
    Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  else
    Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  GetSurfaceAttributes();
}

void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
  if (pNMUpDown->iDelta < 0)
	  Select_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  else
	  Select_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  GetSurfaceAttributes();
}

void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
  if (pNMUpDown->iDelta < 0)
	  Select_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  else
	  Select_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  GetSurfaceAttributes();
}

void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	*pResult = 0;
  UpdateData(TRUE);
  if (pNMUpDown->iDelta < 0)
    Select_RotateTexture(abs(m_nRotateAmt));
  else
    Select_RotateTexture(-abs(m_nRotateAmt));
  GetSurfaceAttributes();
}


void CTextureBar::OnSelectionPrint() 
{
	// TODO: Add your command handler code here
	
}

int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialogBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	return 0;
}


void CTextureBar::OnBtnApplytexturestuff() 
{
  SetSurfaceAttributes();
}

void CTextureBar::GetSurfaceAttributes()
{
  texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;

  if (pt)
  {
    m_nHShift = pt->shift[0];
    m_nVShift = pt->shift[1];
    m_nHScale = pt->scale[0];
    m_nVScale = pt->scale[1];
    m_nRotate = pt->rotate;
    UpdateData(FALSE);
  }
}

//++timo implement brush primitive here
void CTextureBar::SetSurfaceAttributes()
{
  if (g_ptrSelectedFaces.GetSize() > 0)
  {
	  if (g_qeglobals.m_bBrushPrimitMode)
    {
		  Sys_Printf("Warning : brush primitive mode not implemented in CTextureBar");
    }
    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));

	  texdef_t* pt = &selFace->texdef;
    UpdateData(TRUE);
    pt->shift[0] = m_nHShift;
    pt->shift[1] = m_nVShift;
    pt->scale[0] = m_nHScale; 
    pt->scale[1] = m_nVScale; 
    pt->rotate = m_nRotate; 
    Sys_UpdateWindows(W_CAMERA);
  }
}