GroupDlg.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // GroupDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "Radiant.h"
  22. #include "GroupDlg.h"
  23. #include "NameDlg.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. #define IMG_PATCH 0
  30. #define IMG_BRUSH 1
  31. #define IMG_GROUP 2
  32. #define IMG_ENTITY 3
  33. #define IMG_ENTITYGROUP 4
  34. #define IMG_MODEL 5
  35. #define IMG_SCRIPT 6
  36. // misc group support
  37. #define MAX_GROUPS 4096
  38. #define GROUP_DELIMETER '@'
  39. #define GROUPNAME "QER_Group_%i"
  40. CGroupDlg g_wndGroup;
  41. CGroupDlg *g_pGroupDlg = &g_wndGroup;
  42. // group_t are loaded / saved through "group_info" entities
  43. // they hold epairs for group settings and additionnal access info (tree nodes)
  44. group_t *g_pGroups = NULL;
  45. void Group_Add(entity_t *e)
  46. {
  47. group_t *g = (group_t*)qmalloc(sizeof(group_t));
  48. g->epairs = e->epairs;
  49. g->next = NULL;
  50. e->epairs = NULL;
  51. // create a new group node
  52. HTREEITEM hItem = g_wndGroup.m_wndTree.GetSelectedItem();
  53. TVINSERTSTRUCT tvInsert;
  54. memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
  55. tvInsert.item.iImage = IMG_GROUP;
  56. tvInsert.item.iSelectedImage = tvInsert.item.iImage;
  57. //++timo wasat?
  58. // tvInsert.hParent = (hItem) ? hItem : m_hWorld;
  59. tvInsert.hParent = g_wndGroup.m_hWorld;
  60. tvInsert.hInsertAfter = NULL;
  61. tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  62. char *pipo = ValueForKey(e->epairs, "group");
  63. tvInsert.item.pszText = _T(ValueForKey(g->epairs, "group"));
  64. g->itemOwner = g_wndGroup.m_wndTree.InsertItem(&tvInsert);
  65. g->next = g_pGroups;
  66. g_pGroups = g;
  67. }
  68. group_t* Group_Alloc(char *name)
  69. {
  70. group_t *g = (group_t*)qmalloc(sizeof(group_t));
  71. SetKeyValue( g->epairs, "group", name );
  72. return g;
  73. }
  74. group_t* Group_ForName(const char * name)
  75. {
  76. group_t *g = g_pGroups;
  77. while (g != NULL)
  78. {
  79. if (strcmp( ValueForKey(g->epairs,"group"), name ) == 0)
  80. break;
  81. g = g->next;
  82. }
  83. return g;
  84. }
  85. void Group_AddToItem(brush_t *b, HTREEITEM item)
  86. {
  87. char cBuff[1024];
  88. int nImage = IMG_BRUSH;
  89. if (!g_qeglobals.m_bBrushPrimitMode)
  90. {
  91. return;
  92. }
  93. const char *pName = NULL;
  94. const char *pNamed = Brush_GetKeyValue(b, "name");
  95. if (!b->owner || (b->owner == world_entity))
  96. {
  97. if (b->patchBrush)
  98. {
  99. pName = "Generic Patch";
  100. nImage = IMG_PATCH;
  101. }
  102. else
  103. {
  104. pName = "Generic Brush";
  105. nImage = IMG_BRUSH;
  106. }
  107. }
  108. else
  109. {
  110. pName = b->owner->eclass->name;
  111. if (b->owner->eclass->fixedsize)
  112. {
  113. nImage = IMG_ENTITY;
  114. }
  115. else
  116. {
  117. nImage = IMG_ENTITYGROUP;
  118. }
  119. }
  120. strcpy(cBuff, pName);
  121. TVINSERTSTRUCT tvInsert;
  122. memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
  123. tvInsert.item.iImage = (b->patchBrush) ? IMG_PATCH : IMG_BRUSH;
  124. tvInsert.item.iSelectedImage = tvInsert.item.iImage;
  125. tvInsert.hParent = item;
  126. tvInsert.hInsertAfter = NULL;
  127. tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  128. tvInsert.item.pszText = cBuff;
  129. HTREEITEM itemNew = g_pGroupDlg->m_wndTree.InsertItem(&tvInsert);
  130. g_pGroupDlg->m_wndTree.SetItemData(itemNew, reinterpret_cast<DWORD>(b));
  131. b->itemOwner = itemNew;
  132. g_pGroupDlg->m_wndTree.RedrawWindow();
  133. }
  134. void Group_RemoveBrush(brush_t *b)
  135. {
  136. if (!g_qeglobals.m_bBrushPrimitMode)
  137. {
  138. return;
  139. }
  140. if (b->itemOwner)
  141. {
  142. g_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);
  143. b->itemOwner = NULL;
  144. g_pGroupDlg->m_wndTree.RedrawWindow();
  145. }
  146. DeleteKey(b->epairs, "group");
  147. }
  148. void Group_AddToWorld(brush_t *b)
  149. {
  150. if (!g_qeglobals.m_bBrushPrimitMode)
  151. {
  152. return;
  153. }
  154. HTREEITEM itemParent = g_pGroupDlg->m_wndTree.GetRootItem();
  155. Group_AddToItem(b, itemParent);
  156. }
  157. void Group_AddToProperGroup(brush_t *b)
  158. {
  159. if (!g_qeglobals.m_bBrushPrimitMode)
  160. {
  161. return;
  162. }
  163. // NOTE: we do a local copy of the "group" key because it gets erased by Group_RemoveBrush
  164. const char *pGroup = Brush_GetKeyValue(b, "group");
  165. // remove the entry in the tree if there's one
  166. if (b->itemOwner)
  167. {
  168. g_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);
  169. b->itemOwner = NULL;
  170. g_pGroupDlg->m_wndTree.RedrawWindow();
  171. }
  172. if (*pGroup != 0)
  173. {
  174. // find the item
  175. group_t *g = Group_ForName(pGroup);
  176. if (g)
  177. Group_AddToItem(b, g->itemOwner);
  178. #ifdef _DEBUG
  179. else
  180. Sys_Printf("WARNING: unexpected Group_ForName not found in Group_AddToProperGroup\n");
  181. #endif
  182. }
  183. else
  184. {
  185. Group_AddToWorld(b);
  186. }
  187. }
  188. void Group_AddToSelected(brush_t *b)
  189. {
  190. if (!g_qeglobals.m_bBrushPrimitMode)
  191. {
  192. return;
  193. }
  194. HTREEITEM hItem = g_pGroupDlg->m_wndTree.GetSelectedItem();
  195. if (hItem == NULL)
  196. {
  197. hItem = g_pGroupDlg->m_wndTree.GetRootItem();
  198. }
  199. Group_AddToItem(b, hItem);
  200. }
  201. void Group_Save(FILE *f)
  202. {
  203. group_t *g = g_pGroups;
  204. while (g)
  205. {
  206. fprintf(f,"{\n\"classname\" \"group_info\"\n\"group\" \"%s\"\n}\n", ValueForKey( g->epairs, "group" ));
  207. g = g->next;
  208. }
  209. }
  210. void Group_Init()
  211. {
  212. if (!g_qeglobals.m_bBrushPrimitMode)
  213. {
  214. return;
  215. }
  216. // start by cleaning everything
  217. // clean the groups
  218. //++timo FIXME: we leak, delete the groups on the way (I don't have time to do it now)
  219. #ifdef _DEBUG
  220. Sys_Printf("TODO: fix leak in Group_Init\n");
  221. #endif
  222. group_t *g = g_pGroups;
  223. while (g)
  224. {
  225. epair_t *ep,*enext;
  226. for (ep = g->epairs ; ep ; ep=enext )
  227. {
  228. enext = ep->next;
  229. free (ep->key);
  230. free (ep->value);
  231. free (ep);
  232. }
  233. g = g->next;
  234. }
  235. g_pGroups = NULL;
  236. g_wndGroup.m_wndTree.DeleteAllItems();
  237. TVINSERTSTRUCT tvInsert;
  238. memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
  239. tvInsert.hParent = NULL;
  240. tvInsert.hInsertAfter = NULL;
  241. tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  242. tvInsert.item.pszText = _T("World");
  243. tvInsert.item.iImage = IMG_GROUP;
  244. tvInsert.item.iSelectedImage = IMG_GROUP;
  245. HTREEITEM hWorld = g_wndGroup.m_wndTree.InsertItem(&tvInsert);
  246. // walk through all the brushes, remove the itemOwner key and add them back where they belong
  247. brush_t *b;
  248. for (b = active_brushes.next; b != &active_brushes; b = b->next)
  249. {
  250. b->itemOwner = NULL;
  251. Group_AddToProperGroup(b);
  252. }
  253. for (b = selected_brushes.next ; b != &selected_brushes ; b = b->next)
  254. {
  255. b->itemOwner = NULL;
  256. Group_AddToProperGroup(b);
  257. }
  258. }
  259. // scan through world_entity for groups in this map?
  260. // we use GROUPNAME "QER_group_%i" to look for existing groups and their naming
  261. //++timo FIXME: is this actually needed for anything?
  262. void Group_GetListFromWorld(CStringArray *pArray)
  263. {
  264. if (!g_qeglobals.m_bBrushPrimitMode)
  265. {
  266. return;
  267. }
  268. if (world_entity == NULL)
  269. {
  270. return;
  271. }
  272. pArray->RemoveAll();
  273. char cBuff[1024];
  274. for (int i =0; i < MAX_GROUPS; i++)
  275. {
  276. sprintf(cBuff, GROUPNAME, i);
  277. char *pGroup = ValueForKey(world_entity, cBuff);
  278. if (pGroup && strlen(pGroup) > 0)
  279. {
  280. pArray->Add(pGroup);
  281. }
  282. else
  283. {
  284. break;
  285. }
  286. }
  287. }
  288. void Group_RemoveListFromWorld()
  289. {
  290. if (!g_qeglobals.m_bBrushPrimitMode)
  291. {
  292. return;
  293. }
  294. CStringArray array;
  295. Group_GetListFromWorld(&array);
  296. int nCount = array.GetSize();
  297. for (int i = 0; i < nCount; i++)
  298. {
  299. DeleteKey(world_entity, array.GetAt(i));
  300. }
  301. }
  302. /*
  303. void Group_SetListToWorld(CStringArray *pArray)
  304. {
  305. if (!g_qeglobals.m_bBrushPrimitMode)
  306. {
  307. return;
  308. }
  309. char cBuff[1024];
  310. Group_RemoveListFromWorld();
  311. int nCount = pArray->GetSize();
  312. for (int i = 0; i < nCount; i++)
  313. {
  314. sprintf(cBuff, GROUPNAME, i);
  315. SetKeyValue(world_entity, cBuff, pArray->GetAt(i));
  316. }
  317. }
  318. */
  319. int CountChar(const char *p, char c)
  320. {
  321. int nCount = 0;
  322. int nLen = strlen(p)-1;
  323. while (nLen-- >= 0)
  324. {
  325. if (p[nLen] == c)
  326. {
  327. nCount++;
  328. }
  329. }
  330. return nCount;
  331. }
  332. /*
  333. // this is not very efficient but should get the job done
  334. // as our trees should never be too big
  335. void Group_BuildTree(CTreeCtrl *pTree)
  336. {
  337. if (!g_qeglobals.m_bBrushPrimitMode)
  338. {
  339. return;
  340. }
  341. CStringArray array;
  342. int i;
  343. CString strTemp;
  344. CString strRight;
  345. //++timo WARNING: this is very dangerous! delete all tree items, without checking the brushes
  346. pTree->DeleteAllItems();
  347. TVINSERTSTRUCT tvInsert;
  348. memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
  349. tvInsert.hParent = NULL;
  350. tvInsert.hInsertAfter = NULL;
  351. tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  352. tvInsert.item.pszText = _T("World");
  353. tvInsert.item.iImage = IMG_GROUP;
  354. tvInsert.item.iSelectedImage = IMG_GROUP;
  355. HTREEITEM hWorld = pTree->InsertItem(&tvInsert);
  356. Group_GetListFromWorld(&array);
  357. // groups use @ to delimit levels, the number of @ signs
  358. // start with ROOT item
  359. // nothing is a peer with world, it is ancestor to everything
  360. // expects things in order so first entry should be a 2nd level item
  361. HTREEITEM itemParent = pTree->GetRootItem();
  362. HTREEITEM itemLast = itemParent;
  363. int nCount = array.GetSize();
  364. int nLastLevel = 1;
  365. for (i = 0; i < nCount; i++)
  366. {
  367. strTemp = array.GetAt(i);
  368. int nLevel = CountChar(strTemp, GROUP_DELIMETER);
  369. if (nLevel < nLastLevel)
  370. {
  371. int nLevelsUp = nLastLevel - nLevel;
  372. while (nLevelsUp-- > 0)
  373. {
  374. itemParent = pTree->GetParentItem(itemParent);
  375. }
  376. }
  377. else if (nLevel > nLastLevel)
  378. {
  379. itemParent = itemLast;
  380. }
  381. nLastLevel = nLevel;
  382. char *pLast = strrchr(strTemp, GROUP_DELIMETER);
  383. pLast++;
  384. itemLast = pTree->InsertItem(pLast, itemParent);
  385. }
  386. }
  387. */
  388. void DecomposeSiblingList(const char *p, CStringArray *pArray, CTreeCtrl *pTree, HTREEITEM itemChild)
  389. {
  390. CString str = p;
  391. str += GROUP_DELIMETER;
  392. while (itemChild)
  393. {
  394. CString strAdd = str;
  395. strAdd += pTree->GetItemText(itemChild);
  396. // do not want to add brushes or things, just groups
  397. if (pTree->GetItemData(itemChild) == 0)
  398. {
  399. pArray->Add(strAdd);
  400. }
  401. if (pTree->ItemHasChildren(itemChild))
  402. {
  403. HTREEITEM itemOffspring = pTree->GetChildItem(itemChild);
  404. DecomposeSiblingList(strAdd, pArray, pTree, itemOffspring);
  405. }
  406. itemChild = pTree->GetNextSiblingItem(itemChild);
  407. }
  408. }
  409. /*
  410. void Group_DecomposeTree(CTreeCtrl *pTree)
  411. {
  412. if (!g_qeglobals.m_bBrushPrimitMode)
  413. {
  414. return;
  415. }
  416. CStringArray array;
  417. HTREEITEM itemParent = pTree->GetRootItem();
  418. if (pTree->ItemHasChildren(itemParent))
  419. {
  420. HTREEITEM itemChild = pTree->GetChildItem(itemParent);
  421. DecomposeSiblingList(pTree->GetItemText(itemParent), &array, pTree, itemChild);
  422. }
  423. Group_SetListToWorld(&array);
  424. }
  425. */
  426. /////////////////////////////////////////////////////////////////////////////
  427. // CGroupDlg dialog
  428. CGroupDlg::CGroupDlg(CWnd* pParent /*=NULL*/)
  429. : CDialog(CGroupDlg::IDD, pParent)
  430. {
  431. //{{AFX_DATA_INIT(CGroupDlg)
  432. // NOTE: the ClassWizard will add member initialization here
  433. //}}AFX_DATA_INIT
  434. }
  435. void CGroupDlg::DoDataExchange(CDataExchange* pDX)
  436. {
  437. CDialog::DoDataExchange(pDX);
  438. //{{AFX_DATA_MAP(CGroupDlg)
  439. DDX_Control(pDX, IDC_TREE_GROUP, m_wndTree);
  440. DDX_Control(pDX, IDC_BTN_EDIT, m_wndEdit);
  441. DDX_Control(pDX, IDC_BTN_DEL, m_wndDel);
  442. DDX_Control(pDX, IDC_BTN_ADD, m_wndAdd);
  443. //}}AFX_DATA_MAP
  444. }
  445. BEGIN_MESSAGE_MAP(CGroupDlg, CDialog)
  446. //{{AFX_MSG_MAP(CGroupDlg)
  447. ON_WM_SIZE()
  448. ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
  449. ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
  450. ON_BN_CLICKED(IDC_BTN_EDIT, OnBtnEdit)
  451. ON_NOTIFY(NM_RCLICK, IDC_TREE_GROUP, OnRclickTreeGroup)
  452. ON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREE_GROUP, OnEndlabeleditTreeGroup)
  453. ON_NOTIFY(NM_CLICK, IDC_TREE_GROUP, OnClickTreeGroup)
  454. ON_NOTIFY(TVN_SETDISPINFO, IDC_TREE_GROUP, OnSetdispinfoTreeGroup)
  455. ON_NOTIFY(TVN_BEGINDRAG, IDC_TREE_GROUP, OnBegindragTreeGroup)
  456. //}}AFX_MSG_MAP
  457. END_MESSAGE_MAP()
  458. /////////////////////////////////////////////////////////////////////////////
  459. // CGroupDlg message handlers
  460. void CGroupDlg::OnSize(UINT nType, int cx, int cy)
  461. {
  462. CDialog::OnSize(nType, cx, cy);
  463. CRect rct;
  464. GetClientRect(rct);
  465. if ( m_wndAdd.GetSafeHwnd())
  466. {
  467. //all borders at 4, spacing at 6
  468. CRect rctButton;
  469. m_wndAdd.GetWindowRect(rctButton);
  470. int nWidth = rctButton.Width();
  471. int nHeight = rctButton.Height();
  472. int nTop = rct.Height() - nHeight - 4;
  473. m_wndAdd.SetWindowPos(NULL, 4, nTop, 0, 0, SWP_NOSIZE);
  474. m_wndEdit.SetWindowPos(NULL, 8 + nWidth , nTop, 0, 0, SWP_NOSIZE);
  475. m_wndDel.SetWindowPos(NULL, 12 + (nWidth * 2), nTop, 0, 0, SWP_NOSIZE);
  476. rct.bottom = nTop;
  477. m_wndTree.SetWindowPos(NULL, rct.left + 4, rct.top + 4, rct.Width() - 8, rct.Height() - 8, SWP_SHOWWINDOW);
  478. }
  479. }
  480. BOOL CGroupDlg::OnInitDialog()
  481. {
  482. CDialog::OnInitDialog();
  483. m_imgList.Create(IDB_BITMAP_GROUPS, 16, 0, ILC_COLOR);
  484. m_wndTree.SetImageList(&m_imgList, TVSIL_NORMAL);
  485. InitGroups();
  486. return TRUE; // return TRUE unless you set the focus to a control
  487. // EXCEPTION: OCX Property Pages should return FALSE
  488. }
  489. void CGroupDlg::InitGroups()
  490. {
  491. Group_Init();
  492. }
  493. // add a new group, put all selected brushes into the group
  494. void CGroupDlg::OnBtnAdd()
  495. {
  496. CNameDlg dlg("New Group", this);
  497. if (dlg.DoModal() == IDOK)
  498. {
  499. // create a new group node
  500. HTREEITEM hItem = m_wndTree.GetSelectedItem();
  501. TVINSERTSTRUCT tvInsert;
  502. memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
  503. tvInsert.item.iImage = IMG_GROUP;
  504. tvInsert.item.iSelectedImage = tvInsert.item.iImage;
  505. //++timo wasat?
  506. // tvInsert.hParent = (hItem) ? hItem : m_hWorld;
  507. tvInsert.hParent = m_hWorld;
  508. tvInsert.hInsertAfter = NULL;
  509. tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  510. tvInsert.item.pszText = _T(dlg.m_strName.GetBuffer(0));
  511. // create a new group
  512. group_t *g = Group_Alloc( dlg.m_strName.GetBuffer(0) );
  513. g->itemOwner = m_wndTree.InsertItem(&tvInsert);
  514. g->next = g_pGroups;
  515. g_pGroups = g;
  516. // now add the selected brushes
  517. // NOTE: it would be much faster to give the group_t for adding
  518. // but Select_AddToGroup is the standard way for all other cases
  519. Select_AddToGroup( dlg.m_strName.GetBuffer(0) );
  520. }
  521. }
  522. void CGroupDlg::OnBtnDel()
  523. {
  524. }
  525. void CGroupDlg::OnBtnEdit()
  526. {
  527. }
  528. BOOL CGroupDlg::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
  529. {
  530. return CDialog::OnChildNotify(message, wParam, lParam, pLResult);
  531. }
  532. BOOL CGroupDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  533. {
  534. return CDialog::OnNotify(wParam, lParam, pResult);
  535. }
  536. void CGroupDlg::OnRclickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult)
  537. {
  538. // TODO: Add your control notification handler code here
  539. *pResult = 0;
  540. }
  541. void CGroupDlg::OnEndlabeleditTreeGroup(NMHDR* pNMHDR, LRESULT* pResult)
  542. {
  543. TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
  544. const char *pText = pTVDispInfo->item.pszText;
  545. if (pText && strlen(pText) > 0)
  546. {
  547. HTREEITEM item = pTVDispInfo->item.hItem;
  548. if (m_wndTree.GetRootItem() != item)
  549. {
  550. m_wndTree.SetItemText(item, pText);
  551. if (pTVDispInfo->item.iImage != IMG_GROUP)
  552. {
  553. // if it is an entity
  554. }
  555. }
  556. else
  557. {
  558. Sys_Printf("Cannot rename the world\n");
  559. }
  560. }
  561. m_wndTree.RedrawWindow();
  562. *pResult = 0;
  563. }
  564. void CGroupDlg::OnClickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult)
  565. {
  566. // TODO: Add your control notification handler code here
  567. *pResult = 0;
  568. }
  569. void CGroupDlg::OnSetdispinfoTreeGroup(NMHDR* pNMHDR, LRESULT* pResult)
  570. {
  571. TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
  572. // TODO: Add your control notification handler code here
  573. *pResult = 0;
  574. }
  575. void CGroupDlg::OnCancel()
  576. {
  577. TreeView_EndEditLabelNow(m_wndTree.GetSafeHwnd(), TRUE);
  578. }
  579. void CGroupDlg::OnOK()
  580. {
  581. TreeView_EndEditLabelNow(m_wndTree.GetSafeHwnd(), FALSE);
  582. }
  583. void CGroupDlg::OnBegindragTreeGroup(NMHDR* pNMHDR, LRESULT* pResult)
  584. {
  585. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  586. // TODO: Add your control notification handler code here
  587. *pResult = 0;
  588. }