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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef VISGROUP_H
#define VISGROUP_H
#pragma once
#include "BaseTypes.h"
#include "utlvector.h"
class CChunkFile;
class CSaveInfo;
class CMapDoc;
struct LoadVisGroupData_t;
enum ChunkFileResult_t;
enum VisGroupState_t
{
VISGROUP_UNDEFINED = -1, // Used for initialization when updating state
VISGROUP_HIDDEN, // All members are currently hidden
VISGROUP_SHOWN, // All members are currently shown
VISGROUP_PARTIAL, // Some members are currently hidden, some are shown
};
class CVisGroup
{
public:
CVisGroup(void);
inline unsigned int GetID(void) { return(m_dwID); }
inline void SetID(unsigned int dwID) { m_dwID = dwID; }
inline const char *GetName(void)
{
return(m_szName);
}
inline void SetName(const char *pszName)
{
if (pszName != NULL)
{
strncpy(m_szName, pszName, sizeof(m_szName));
}
}
inline color32 GetColor(void);
inline void SetColor(color32 rgbColor);
inline void SetColor(unsigned char red, unsigned char green, unsigned char blue);
inline CVisGroup *GetParent(void);
inline void SetParent(CVisGroup *pNewParent);
inline int GetChildCount(void);
inline CVisGroup *GetChild(int nIndex);
void AddChild(CVisGroup *pChild);
void RemoveChild(CVisGroup *pChild);
bool FindDescendent(CVisGroup *pGroup);
void MoveUp(CVisGroup *pChild);
void MoveDown(CVisGroup *pChild);
bool CanMoveUp(CVisGroup *pChild);
bool CanMoveDown(CVisGroup *pChild);
VisGroupState_t GetVisible(void);
void VisGroups_UpdateParent( VisGroupState_t state );
inline void SetVisible(VisGroupState_t eVisible) { m_eVisible = eVisible; }
static bool IsShowAllActive(void);
static void ShowAllVisGroups(bool bShow);
//
// Serialization.
//
ChunkFileResult_t LoadVMF(CChunkFile *pFile, CMapDoc *pDoc);
ChunkFileResult_t SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
static ChunkFileResult_t LoadVisGroupCallback(CChunkFile *pFile, LoadVisGroupData_t *pLoadData);
static ChunkFileResult_t LoadVisGroupsCallback(CChunkFile *pFile, CMapDoc *pDoc);
static bool IsConvertingOldVisGroups();
bool IsAutoVisGroup(void);
void SetAuto( bool bAuto );
protected:
CUtlVector<CVisGroup *> m_Children;
CVisGroup *m_pParent;
bool m_bIsAuto;
static ChunkFileResult_t LoadKeyCallback(const char *szKey, const char *szValue, CVisGroup *pGroup);
static bool s_bShowAll;
static bool s_bIsConvertingOldVisGroups;
char m_szName[128];
color32 m_rgbColor;
unsigned int m_dwID;
VisGroupState_t m_eVisible;
};
//-----------------------------------------------------------------------------
// Purpose: Returns the render color of this visgroup.
//-----------------------------------------------------------------------------
inline color32 CVisGroup::GetColor(void)
{
return m_rgbColor;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the color of this visgroup.
//-----------------------------------------------------------------------------
inline void CVisGroup::SetColor(color32 rgbColor)
{
m_rgbColor = rgbColor;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the color of this visgroup using RGB values.
//-----------------------------------------------------------------------------
inline void CVisGroup::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
m_rgbColor.r = red;
m_rgbColor.g = green;
m_rgbColor.b = blue;
m_rgbColor.a = 0;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the number of visgroups that are children of this visgroup.
//-----------------------------------------------------------------------------
inline int CVisGroup::GetChildCount(void)
{
return m_Children.Count();
}
//-----------------------------------------------------------------------------
// Purpose: Returns the given child visgroup.
//-----------------------------------------------------------------------------
inline CVisGroup *CVisGroup::GetChild(int nIndex)
{
return m_Children.Element(nIndex);
}
//-----------------------------------------------------------------------------
// Purpose: Returns this visgroup's parent in the hierarchy.
//-----------------------------------------------------------------------------
inline CVisGroup *CVisGroup::GetParent(void)
{
return m_pParent;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
inline void CVisGroup::SetParent(CVisGroup *pNewParent)
{
m_pParent = pNewParent;
}
//-----------------------------------------------------------------------------
// A list of visgroups.
//-----------------------------------------------------------------------------
class CVisGroupList
{
public:
inline int AddToTail(CVisGroup *pVisGroup);
inline int Count(void);
inline CVisGroup *Element(int nElement);
inline int Find(CVisGroup *pVisGroup);
inline void FastRemove(int nElement);
inline void RemoveAll(void);
private:
CUtlVector<CVisGroup *> m_List;
};
int CVisGroupList::AddToTail(CVisGroup *pVisGroup)
{
return m_List.AddToTail(pVisGroup);
}
int CVisGroupList::Count(void)
{
return m_List.Count();
}
CVisGroup *CVisGroupList::Element(int nElement)
{
return m_List.Element(nElement);
}
int CVisGroupList::Find(CVisGroup *pVisGroup)
{
return m_List.Find(pVisGroup);
}
inline void CVisGroupList::FastRemove(int nElement)
{
m_List.FastRemove(nElement);
}
inline void CVisGroupList::RemoveAll(void)
{
m_List.RemoveAll();
}
#endif // VISGROUP_H
|