2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
34 #include "EntityListDlg.h"
39 static char THIS_FILE[] = __FILE__;
42 CEntityListDlg g_EntityListDlg;
43 /////////////////////////////////////////////////////////////////////////////
44 // CEntityListDlg dialog
46 void CEntityListDlg::ShowDialog() {
47 if (g_EntityListDlg.GetSafeHwnd() == NULL) {
48 g_EntityListDlg.Create(IDD_DLG_ENTITYLIST);
50 g_EntityListDlg.UpdateList();
51 g_EntityListDlg.ShowWindow(SW_SHOW);
55 CEntityListDlg::CEntityListDlg(CWnd* pParent /*=NULL*/)
56 : CDialog(CEntityListDlg::IDD, pParent)
58 //{{AFX_DATA_INIT(CEntityListDlg)
63 void CEntityListDlg::DoDataExchange(CDataExchange* pDX)
65 CDialog::DoDataExchange(pDX);
66 //{{AFX_DATA_MAP(CEntityListDlg)
67 DDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);
69 DDX_Control(pDX, IDC_LIST_ENTITIES, listEntities);
72 BEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)
73 //{{AFX_MSG_MAP(CEntityListDlg)
74 ON_BN_CLICKED(IDC_SELECT, OnSelect)
78 ON_LBN_SELCHANGE(IDC_LIST_ENTITIES, OnLbnSelchangeListEntities)
79 ON_LBN_DBLCLK(IDC_LIST_ENTITIES, OnLbnDblclkListEntities)
82 /////////////////////////////////////////////////////////////////////////////
83 // CEntityListDlg message handlers
85 void CEntityListDlg::OnSelect()
87 int index = listEntities.GetCurSel();
88 if (index != LB_ERR) {
89 entity_t *ent = reinterpret_cast<entity_t*>(listEntities.GetItemDataPtr(index));
92 Select_Brush (ent->brushes.onext);
95 Sys_UpdateWindows(W_ALL);
98 void CEntityListDlg::UpdateList() {
99 listEntities.ResetContent();
100 for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next) {
101 int index = listEntities.AddString(pEntity->epairs.GetString("name"));
102 if (index != LB_ERR) {
103 listEntities.SetItemDataPtr(index, (void*)pEntity);
108 void CEntityListDlg::OnSysCommand(UINT nID, LPARAM lParam) {
109 if (nID == SC_CLOSE) {
114 void CEntityListDlg::OnCancel() {
118 BOOL CEntityListDlg::OnInitDialog()
120 CDialog::OnInitDialog();
125 m_lstEntity.GetClientRect(rct);
126 m_lstEntity.InsertColumn(0, "Key", LVCFMT_LEFT, rct.Width() / 2);
127 m_lstEntity.InsertColumn(1, "Value", LVCFMT_LEFT, rct.Width() / 2);
128 m_lstEntity.DeleteColumn(2);
131 return TRUE; // return TRUE unless you set the focus to a control
132 // EXCEPTION: OCX Property Pages should return FALSE
135 void CEntityListDlg::OnClose() {
139 void CEntityListDlg::OnLbnSelchangeListEntities()
141 int index = listEntities.GetCurSel();
142 if (index != LB_ERR) {
143 m_lstEntity.DeleteAllItems();
144 entity_t* pEntity = reinterpret_cast<entity_t*>(listEntities.GetItemDataPtr(index));
146 int count = pEntity->epairs.GetNumKeyVals();
147 for (int i = 0; i < count; i++) {
148 int nParent = m_lstEntity.InsertItem(0, pEntity->epairs.GetKeyVal(i)->GetKey());
149 m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEntity->epairs.GetKeyVal(i)->GetValue(), 0, 0, 0, reinterpret_cast<DWORD>(pEntity));
155 void CEntityListDlg::OnLbnDblclkListEntities()