doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EntityListDlg.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "qe3.h"
33 #include "Radiant.h"
34 #include "EntityListDlg.h"
35 
36 #ifdef _DEBUG
37 #define new DEBUG_NEW
38 #undef THIS_FILE
39 static char THIS_FILE[] = __FILE__;
40 #endif
41 
44 // CEntityListDlg dialog
45 
47  if (g_EntityListDlg.GetSafeHwnd() == NULL) {
48  g_EntityListDlg.Create(IDD_DLG_ENTITYLIST);
49  }
50  g_EntityListDlg.UpdateList();
51  g_EntityListDlg.ShowWindow(SW_SHOW);
52 
53 }
54 
55 CEntityListDlg::CEntityListDlg(CWnd* pParent /*=NULL*/)
56  : CDialog(CEntityListDlg::IDD, pParent)
57 {
58  //{{AFX_DATA_INIT(CEntityListDlg)
59  //}}AFX_DATA_INIT
60 }
61 
62 
63 void CEntityListDlg::DoDataExchange(CDataExchange* pDX)
64 {
65  CDialog::DoDataExchange(pDX);
66  //{{AFX_DATA_MAP(CEntityListDlg)
67  DDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);
68  //}}AFX_DATA_MAP
69  DDX_Control(pDX, IDC_LIST_ENTITIES, listEntities);
70 }
71 
72 BEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)
73  //{{AFX_MSG_MAP(CEntityListDlg)
74  ON_BN_CLICKED(IDC_SELECT, OnSelect)
75  ON_WM_CLOSE()
76  ON_WM_DESTROY()
77  //}}AFX_MSG_MAP
78  ON_LBN_SELCHANGE(IDC_LIST_ENTITIES, OnLbnSelchangeListEntities)
79  ON_LBN_DBLCLK(IDC_LIST_ENTITIES, OnLbnDblclkListEntities)
80 END_MESSAGE_MAP()
81 
83 // CEntityListDlg message handlers
84 
85 void CEntityListDlg::OnSelect()
86 {
87  int index = listEntities.GetCurSel();
88  if (index != LB_ERR) {
89  entity_t *ent = reinterpret_cast<entity_t*>(listEntities.GetItemDataPtr(index));
90  if (ent) {
91  Select_Deselect();
92  Select_Brush (ent->brushes.onext);
93  }
94  }
95  Sys_UpdateWindows(W_ALL);
96 }
97 
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);
104  }
105  }
106 }
107 
109  if (nID == SC_CLOSE) {
110  DestroyWindow();
111  }
112 }
113 
115  DestroyWindow();
116 }
117 
119 {
120  CDialog::OnInitDialog();
121 
122  UpdateList();
123 
124  CRect rct;
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);
129  UpdateData(FALSE);
130 
131  return TRUE; // return TRUE unless you set the focus to a control
132  // EXCEPTION: OCX Property Pages should return FALSE
133 }
134 
136  DestroyWindow();
137 }
138 
140 {
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));
145  if (pEntity) {
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));
150  }
151  }
152  }
153 }
154 
156 {
157  OnSelect();
158 }
#define IDC_SELECT
virtual void DoDataExchange(CDataExchange *pDX)
void WINAPI Sys_UpdateWindows(int nBits)
Definition: MainFrm.cpp:3974
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
const idStr & GetKey(void) const
Definition: Dict.h:52
CListBox listEntities
Definition: EntityListDlg.h:77
DWORD
Definition: win_qgl.cpp:61
virtual void OnCancel()
CEntityListDlg g_EntityListDlg
int i
Definition: process.py:33
#define BOOL
Definition: mprintf.c:71
brush_t brushes
Definition: EditorEntity.h:35
#define IDC_LIST_ENTITY
GLuint GLuint GLsizei count
Definition: glext.h:2845
#define IDD_DLG_ENTITYLIST
GLuint index
Definition: glext.h:3476
afx_msg void OnSelect()
#define IDC_LIST_ENTITIES
#define NULL
Definition: Lib.h:88
virtual BOOL OnInitDialog()
struct entity_s * next
Definition: EditorEntity.h:34
afx_msg void OnClose()
afx_msg void OnLbnSelchangeListEntities()
const idStr & GetValue(void) const
Definition: Dict.h:53
afx_msg void OnSysCommand(UINT nID, LPARAM lParam)
static void ShowDialog()
entity_t entities
Definition: EditorMap.cpp:47
idDict epairs
Definition: EditorEntity.h:42
#define FALSE
Definition: mprintf.c:70
const idKeyValue * GetKeyVal(int index) const
Definition: Dict.h:294
afx_msg void OnLbnDblclkListEntities()
#define TRUE
Definition: mprintf.c:69
CListCtrl m_lstEntity
Definition: EntityListDlg.h:52
CEntityListDlg(CWnd *pParent=NULL)
int GetNumKeyVals(void) const
Definition: Dict.h:290