forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewVisGroupDlg.cpp
173 lines (135 loc) · 5.07 KB
/
NewVisGroupDlg.cpp
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A dialog that is invoked when a new visgroup is created.
// It lets the user pick an existing visgroup or create a new one.
//
//=============================================================================//
#include "stdafx.h"
#include "MapDoc.h"
#include "NewVisGroupDlg.h"
#include "hammer.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
static const unsigned int g_uSelChangeMsg = ::RegisterWindowMessage(GROUPLIST_MSG_SEL_CHANGE);
static BOOL s_bLastHideObjects = TRUE;
BEGIN_MESSAGE_MAP(CNewVisGroupDlg, CDialog)
//{{AFX_MSG_MAP(CNewVisGroupDlg)
ON_REGISTERED_MESSAGE(g_uSelChangeMsg, OnSelChangeGroupList)
ON_COMMAND(IDC_PLACE_IN_EXISTING_VISGROUP, OnPlaceInExistingVisGroup)
ON_COMMAND(IDC_CREATE_NEW_VISGROUP, OnCreateNewVisGroup)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
// Purpose:
// Input : pParent -
//-----------------------------------------------------------------------------
CNewVisGroupDlg::CNewVisGroupDlg(CString &str, CWnd *pParent)
: CDialog(CNewVisGroupDlg::IDD, pParent)
{
m_pPickedVisGroup = NULL;
//{{AFX_DATA_INIT(CNewVisGroupDlg)
m_strName = str;
//}}AFX_DATA_INIT
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : pDX -
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewVisGroupDlg)
DDX_Check(pDX, IDC_REMOVE_FROM_ALL, m_bRemoveFromOtherGroups);
DDX_Check(pDX, IDC_HIDE_OBJECTS, m_bHideObjects);
DDX_Text(pDX, IDC_VISGROUP_NAME, m_strName);
//}}AFX_DATA_MAP
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
BOOL CNewVisGroupDlg::OnInitDialog(void)
{
m_bHideObjects = s_bLastHideObjects;
CDialog::OnInitDialog();
CButton *pButton = (CButton *)GetDlgItem(IDC_CREATE_NEW_VISGROUP);
pButton->SetCheck(1);
m_cGroupList.SubclassDlgItem(IDC_GROUP_LIST, this);
UpdateGroupList();
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_GROUP_LIST);
pEdit->EnableWindow(FALSE);
return TRUE;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the visgroup name that was entered in the dialog.
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::GetName(CString &str)
{
str = m_strName;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::OnOK()
{
CDialog::OnOK();
s_bLastHideObjects = m_bHideObjects;
}
//-----------------------------------------------------------------------------
// Purpose: Switches the mode of the dialog to pick an existing visgroup rather than
// create a new one.
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::OnPlaceInExistingVisGroup()
{
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_VISGROUP_NAME);
pEdit->EnableWindow(FALSE);
pEdit = (CEdit *)GetDlgItem(IDC_GROUP_LIST);
pEdit->EnableWindow(TRUE);
}
//-----------------------------------------------------------------------------
// Purpose: Switches the mode of the dialog to create a new visgroup rather than
// pick an existing one.
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::OnCreateNewVisGroup()
{
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_VISGROUP_NAME);
pEdit->EnableWindow(TRUE);
pEdit = (CEdit *)GetDlgItem(IDC_GROUP_LIST);
pEdit->EnableWindow(FALSE);
m_pPickedVisGroup = NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Handles selection change in the visgroup list.
//-----------------------------------------------------------------------------
LRESULT CNewVisGroupDlg::OnSelChangeGroupList(WPARAM wParam, LPARAM lParam)
{
m_pPickedVisGroup = m_cGroupList.GetSelectedVisGroup();
return 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNewVisGroupDlg::UpdateGroupList(void)
{
m_cGroupList.SetRedraw(false);
m_cGroupList.DeleteAllItems();
CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
if (pDoc != NULL)
{
int nCount = pDoc->VisGroups_GetRootCount();
for (int i = 0; i < nCount; i++)
{
CVisGroup *pGroup = pDoc->VisGroups_GetRootVisGroup(i);
m_cGroupList.AddVisGroup(pGroup);
}
}
m_cGroupList.ExpandAll();
m_cGroupList.SetRedraw(true);
m_cGroupList.Invalidate();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CVisGroup *CNewVisGroupDlg::GetPickedVisGroup(void)
{
return m_pPickedVisGroup;
}