00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "Radiant.h"
00027 #include "EntityListDlg.h"
00028
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034
00036
00037
00038
00039 CEntityListDlg::CEntityListDlg(CWnd* pParent )
00040 : CDialog(CEntityListDlg::IDD, pParent)
00041 {
00042
00043
00044 }
00045
00046
00047 void CEntityListDlg::DoDataExchange(CDataExchange* pDX)
00048 {
00049 CDialog::DoDataExchange(pDX);
00050
00051 DDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);
00052 DDX_Control(pDX, IDC_TREE_ENTITY, m_treeEntity);
00053
00054 }
00055
00056
00057 BEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)
00058
00059 ON_BN_CLICKED(IDSELECT, OnSelect)
00060 ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_ENTITY, OnSelchangedTreeEntity)
00061 ON_NOTIFY(NM_DBLCLK, IDC_TREE_ENTITY, OnDblclkTreeEntity)
00062
00063 END_MESSAGE_MAP()
00064
00066
00067
00068 void CEntityListDlg::OnSelect()
00069 {
00070 HTREEITEM hItem = m_treeEntity.GetSelectedItem();
00071 if (hItem)
00072 {
00073 entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));
00074 if (pEntity)
00075 {
00076 Select_Deselect();
00077 Select_Brush (pEntity->brushes.onext);
00078 }
00079 }
00080 Sys_UpdateWindows(W_ALL);
00081 }
00082
00083 BOOL CEntityListDlg::OnInitDialog()
00084 {
00085 CDialog::OnInitDialog();
00086
00087 CMapStringToPtr mapEntity;
00088
00089 HTREEITEM hParent = m_treeEntity.InsertItem(world_entity->eclass->name);
00090 HTREEITEM hChild = m_treeEntity.InsertItem(world_entity->eclass->name, hParent);
00091 m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(world_entity));
00092
00093 for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)
00094 {
00095 hParent = NULL;
00096 if (mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(hParent)) == FALSE)
00097 {
00098 hParent = m_treeEntity.InsertItem(pEntity->eclass->name);
00099 mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void*>(hParent));
00100 }
00101 hChild = m_treeEntity.InsertItem(pEntity->eclass->name, hParent);
00102 m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(pEntity));
00103 }
00104
00105 CRect rct;
00106 m_lstEntity.GetClientRect(rct);
00107 m_lstEntity.InsertColumn(0, "Key", LVCFMT_LEFT, rct.Width() / 2);
00108 m_lstEntity.InsertColumn(1, "Value", LVCFMT_LEFT, rct.Width() / 2);
00109 m_lstEntity.DeleteColumn(2);
00110 UpdateData(FALSE);
00111
00112 return TRUE;
00113
00114 }
00115
00116 void CEntityListDlg::OnSelchangedTreeEntity(NMHDR* pNMHDR, LRESULT* pResult)
00117 {
00118 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
00119 HTREEITEM hItem = m_treeEntity.GetSelectedItem();
00120 m_lstEntity.DeleteAllItems();
00121 if (hItem)
00122 {
00123 CString strList;
00124 entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));
00125 if (pEntity)
00126 {
00127 for (epair_t* pEpair = pEntity->epairs ; pEpair ; pEpair = pEpair->next)
00128 {
00129 if (strlen(pEpair->key) > 8)
00130 strList.Format("%s\t%s", pEpair->key, pEpair->value);
00131 else
00132 strList.Format("%s\t\t%s", pEpair->key, pEpair->value);
00133 int nParent = m_lstEntity.InsertItem(0, pEpair->key);
00134 m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEpair->value, 0, 0, 0, reinterpret_cast<DWORD>(pEntity));
00135
00136 }
00137 }
00138 }
00139 *pResult = 0;
00140 }
00141
00142 void CEntityListDlg::OnDblclkListInfo()
00143 {
00144
00145
00146 }
00147
00148 void CEntityListDlg::OnDblclkTreeEntity(NMHDR* pNMHDR, LRESULT* pResult)
00149 {
00150 OnSelect();
00151 *pResult = 0;
00152 }