summaryrefslogtreecommitdiff
path: root/hammer/faceeditsheet.h
blob: 3cbd71d9527742d25e661668fe1872c3a020e572 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef FACEEDITSHEET_H
#define FACEEDITSHEET_H
#pragma once

#include <afxtempl.h>
#include "FaceEdit_MaterialPage.h"
#include "FaceEdit_DispPage.h"

class CMapFace;
class CMapSolid;

//=============================================================================
//
// Face Edit Sheet
//
class CFaceEditSheet : public CPropertySheet
{
	DECLARE_DYNAMIC( CFaceEditSheet )

public:

	// solid/face selection structure
	typedef struct
	{
		CMapDoc *pMapDoc;	// From whence it came, so if we close the CMapDoc we can unselect it.
		CMapFace *pMapFace;
		CMapSolid *pMapSolid;
	} StoredFace_t;

	//=========================================================================
	//
	// Creation/Destruction
	//
					CFaceEditSheet( LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0 );
	virtual			~CFaceEditSheet();

	BOOL			Create( CWnd *pParentWnd );
	void			Setup( void );

	//=========================================================================
	//
	// Update
	//
	void			SetVisibility( bool bVisible );
	inline void		NotifyGraphicsChanged( void );

	void			CloseAllPageDialogs( void );

	void			UpdateControls( void );
	
	// Called when the CMapDoc goes away. Don't hang onto old face pointers that come from this doc.
	void			ClearFaceListByMapDoc( CMapDoc *pDoc );

	//=========================================================================
	//
	// Selection
	//
	enum { FACE_LIST_SIZE = 32 };

	enum
	{
		id_SwitchModeStart = 0x100,
		ModeLiftSelect,
		ModeLift,
		ModeSelect,
		ModeApply,
		ModeApplyAll,
		ModeApplyLightmapScale,
		ModeAlignToView,
		id_SwitchModeEnd
	};

	enum
	{
		cfToggle    = 0x01,			// toggle - if selected, then unselect
		cfSelect    = 0x02,			// select
		cfUnselect  = 0x04,			// unselect
		cfClear     = 0x08,			// clear face list
		cfEdgeAlign = 0x10			// align face texture coordinates to 3d view alignment - should be here???
	};

	void ClickFace( CMapSolid *pSolid, int faceIndex, int cmd, int clickMode = -1 );
	inline void SetClickMode( int mode );
	inline int GetClickMode( void );

	void EnableUpdate( bool bEnable );
	inline bool HasUpdateEnabled( void );
	
	inline int GetFaceListCount( void );
	inline CMapFace *GetFaceListDataFace( int index );
	inline CMapSolid *GetFaceListDataSolid( int index );

	// Called when a new material is detected.
	void NotifyNewMaterial( IEditorTexture *pTex );
	
	//=========================================================================
	//
	// Virtual Overrides
	//
	//{{AFX_VIRTUAL( CFaceEditSheet )
	virtual BOOL PreTranslateMessage( MSG *pMsg );
	//}}AFX_VIRTUAL

	CFaceEditMaterialPage				m_MaterialPage;			// material "page"
	CFaceEditDispPage					m_DispPage;				// displacement "page"

protected:

	CUtlVector<StoredFace_t>			m_Faces;				// face list

//	CFaceEditMaterialPage				m_MaterialPage;			// material "page"
//	CFaceEditDispPage					m_DispPage;				// displacement "page"

	int									m_ClickMode;			// lame this is here!!!! -- see CMapDoc (SelectFace)

	bool								m_bEnableUpdate;		// update the dialog (true/false)

	//=========================================================================
	//
	// Creation/Destruction
	//
	void SetupPages( void );
	void SetupButtons( void );

	//=========================================================================
	//
	// Selection
	//
	void ClearFaceList( void );
	int FindFaceInList( CMapFace *pFace );

	//=========================================================================
	//
	// Message Map
	//
	//{{AFX_MSG( CFaceEditSheet )
	afx_msg void OnClose( void );
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void CFaceEditSheet::NotifyGraphicsChanged( void )
{
	m_MaterialPage.NotifyGraphicsChanged();
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void CFaceEditSheet::SetClickMode( int mode )
{
	m_ClickMode = mode;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline int CFaceEditSheet::GetClickMode( void )
{ 
	return m_ClickMode; 
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline int CFaceEditSheet::GetFaceListCount( void )
{
	return m_Faces.Count();
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline CMapFace *CFaceEditSheet::GetFaceListDataFace( int index )
{
	return m_Faces[index].pMapFace;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline CMapSolid *CFaceEditSheet::GetFaceListDataSolid( int index )
{
	return m_Faces[index].pMapSolid;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline bool CFaceEditSheet::HasUpdateEnabled( void )
{
	return m_bEnableUpdate;
}


#endif // FACEEDITSHEET_H