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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Defines the interface that tools implement to allow views to call
// through them.
//
//===========================================================================//
#ifndef TOOLINTERFACE_H
#define TOOLINTERFACE_H
#ifdef _WIN32
#pragma once
#endif
class CMapView2D;
class CMapView3D;
class CMapViewLogical;
class CRender2D;
class CRender3D;
class CMapDoc;
class CMapClass;
class Vector2D;
class CChunkFile;
class CSaveInfo;
#define HANDLE_RADIUS 4
enum ChunkFileResult_t;
enum ToolID_t
{
TOOL_NONE = -1,
TOOL_POINTER,
TOOL_BLOCK,
TOOL_ENTITY,
TOOL_CAMERA,
TOOL_DECAL,
TOOL_MAGNIFY,
TOOL_MORPH,
TOOL_CLIPPER,
TOOL_EDITCORDON,
TOOL_FACEEDIT_MATERIAL,
TOOL_FACEEDIT_DISP,
TOOL_OVERLAY,
TOOL_AXIS_HANDLE,
TOOL_POINT_HANDLE,
TOOL_SPHERE,
TOOL_PICK_FACE,
TOOL_PICK_ENTITY,
TOOL_PICK_ANGLES,
TOOL_SWEPT_HULL,
TOOL_PLAYERHULL_HANDLE,
};
enum
{
constrainNone = 0x00, // transformation with no constrains
constrainOnlyHorz = 0x01, // only horizontal translations
constrainOnlyVert = 0x02, // only vertical translations
constrainSnap = 0x04, // rounds to document snap grid
constrainIntSnap = 0x08, // rounds value to one unit (integer)
constrainHalfSnap = 0x10, // rounds to half of snap grid
constrainCenter = 0x20,
constrainMoveAll = 0x40, // translate all handles
};
class CBaseTool
{
public:
inline CBaseTool();
virtual ~CBaseTool() {}
//
// Called by the tool manager to activate/deactivate tools.
//
virtual void Init( CMapDoc *pDocument );
void Activate();
void Deactivate();
virtual bool CanDeactivate( void ) { return true; }
virtual bool IsTranslating(void) { return false; } // return true if tool is currently changing objects
inline bool IsActiveTool( void ) { return m_bActiveTool; }
// true if tool has objects to work on
virtual bool IsEmpty() { return m_bEmpty; }
// detach tool from any object working on
virtual void SetEmpty() { m_bEmpty = true; }
// attach a certain object to that tool
virtual void Attach(CMapClass *pObject) {};
//
// Notifications for tool activation/deactivation.
//
virtual void OnActivate() {}
virtual void OnDeactivate() {}
virtual ToolID_t GetToolID(void) { return TOOL_NONE; }
virtual const char* GetVMFChunkName() { return NULL; }
virtual ChunkFileResult_t LoadVMF(CChunkFile *pFile) { return (ChunkFileResult_t)0; /*ChunkFile_Ok*/ }
virtual ChunkFileResult_t SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo) { return (ChunkFileResult_t)0 ; /*ChunkFile_Ok*/ }
//
// Messages sent by the 3D view:
//
virtual bool OnContextMenu3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
virtual bool OnLMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseDblClk3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnMouseMove3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnMouseWheel3D( CMapView3D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
virtual bool OnKeyDown3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnKeyUp3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnChar3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
//
// Messages sent by the 2D view:
//
virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
virtual bool OnLMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseDblClk2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnMouseMove2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
virtual bool OnMouseWheel2D( CMapView2D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
virtual bool OnKeyDown2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnKeyUp2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnChar2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
//
// Messages sent by the logical view:
//
virtual bool OnContextMenuLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
virtual bool OnLMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnLMouseDblClkLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnRMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
virtual bool OnMouseMoveLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
virtual bool OnMouseWheelLogical( CMapViewLogical *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
virtual bool OnKeyDownLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnKeyUpLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
virtual bool OnCharLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
//
// Rendering.
//
virtual void RenderTool2D( CRender2D *pRender ) {}
virtual void RenderToolLogical( CRender2D *pRender ) {}
virtual void RenderTool3D( CRender3D *pRender ) {}
virtual void UpdateStatusBar( void ) {}
protected:
bool m_bActiveTool; // Set to true when this is the active tool.
bool m_bEmpty; // true if the tool has objects to work on
CMapDoc *m_pDocument;
};
//-----------------------------------------------------------------------------
// Purpose: Constructor.
//-----------------------------------------------------------------------------
CBaseTool::CBaseTool()
{
m_bEmpty = true;
m_bActiveTool = false;
m_pDocument = NULL;
}
#endif // TOOLINTERFACE_H
|