Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

GroupDlg.cpp File Reference

#include "stdafx.h"
#include "Radiant.h"
#include "GroupDlg.h"
#include "NameDlg.h"

Include dependency graph for GroupDlg.cpp:

Include dependency graph

Go to the source code of this file.

Defines

#define GROUP_DELIMETER   '@'
#define GROUPNAME   "QER_Group_%i"
#define IMG_BRUSH   1
#define IMG_ENTITY   3
#define IMG_ENTITYGROUP   4
#define IMG_GROUP   2
#define IMG_MODEL   5
#define IMG_PATCH   0
#define IMG_SCRIPT   6
#define MAX_GROUPS   4096

Functions

 BEGIN_MESSAGE_MAP (CGroupDlg, CDialog) ON_WM_SIZE() ON_BN_CLICKED(IDC_BTN_ADD
int CountChar (const char *p, char c)
void DecomposeSiblingList (const char *p, CStringArray *pArray, CTreeCtrl *pTree, HTREEITEM itemChild)
void Group_Add (entity_t *e)
void Group_AddToItem (brush_t *b, HTREEITEM item)
void Group_AddToProperGroup (brush_t *b)
void Group_AddToSelected (brush_t *b)
void Group_AddToWorld (brush_t *b)
group_tGroup_Alloc (char *name)
group_tGroup_ForName (const char *name)
void Group_GetListFromWorld (CStringArray *pArray)
void Group_Init ()
void Group_RemoveBrush (brush_t *b)
void Group_RemoveListFromWorld ()
void Group_Save (FILE *f)
OnBtnAdd ON_BN_CLICKED (IDC_BTN_DEL, OnBtnDel) ON_BN_CLICKED(IDC_BTN_EDIT
OnBtnAdd OnBtnEdit OnEndlabeleditTreeGroup
OnSetdispinfoTreeGroup 
ON_NOTIFY (TVN_BEGINDRAG, IDC_TREE_GROUP, OnBegindragTreeGroup) END_MESSAGE_MAP() void CGroupDlg
OnBtnAdd OnBtnEdit OnEndlabeleditTreeGroup ON_NOTIFY (NM_CLICK, IDC_TREE_GROUP, OnClickTreeGroup) ON_NOTIFY(TVN_SETDISPINFO
OnBtnAdd OnBtnEdit ON_NOTIFY (NM_RCLICK, IDC_TREE_GROUP, OnRclickTreeGroup) ON_NOTIFY(TVN_ENDLABELEDIT

Variables

CGroupDlgg_pGroupDlg = &g_wndGroup
group_tg_pGroups = NULL
CGroupDlg g_wndGroup
OnBtnAdd OnBtnEdit IDC_TREE_GROUP


Define Documentation

#define GROUP_DELIMETER   '@'
 

Definition at line 46 of file GroupDlg.cpp.

#define GROUPNAME   "QER_Group_%i"
 

Definition at line 47 of file GroupDlg.cpp.

Referenced by Group_GetListFromWorld().

#define IMG_BRUSH   1
 

Definition at line 37 of file GroupDlg.cpp.

#define IMG_ENTITY   3
 

Definition at line 39 of file GroupDlg.cpp.

#define IMG_ENTITYGROUP   4
 

Definition at line 40 of file GroupDlg.cpp.

#define IMG_GROUP   2
 

Definition at line 38 of file GroupDlg.cpp.

#define IMG_MODEL   5
 

Definition at line 41 of file GroupDlg.cpp.

#define IMG_PATCH   0
 

Definition at line 36 of file GroupDlg.cpp.

Referenced by Group_AddToItem().

#define IMG_SCRIPT   6
 

Definition at line 42 of file GroupDlg.cpp.

#define MAX_GROUPS   4096
 

Definition at line 45 of file GroupDlg.cpp.


Function Documentation

BEGIN_MESSAGE_MAP CGroupDlg  ,
CDialog 
 

int CountChar const char *  p,
char  c
 

Definition at line 350 of file GroupDlg.cpp.

References p, and strlen().

00351 {
00352   int nCount = 0;
00353   int nLen = strlen(p)-1;
00354   while (nLen-- >= 0)
00355   {
00356     if (p[nLen] == c)
00357     {
00358       nCount++;
00359     }
00360   }
00361   return nCount;
00362 }

Here is the call graph for this function:

void DecomposeSiblingList const char *  p,
CStringArray *  pArray,
CTreeCtrl *  pTree,
HTREEITEM  itemChild
 

Definition at line 424 of file GroupDlg.cpp.

00425 {
00426   CString str = p;
00427   str += GROUP_DELIMETER;
00428   while (itemChild)
00429   {
00430     CString strAdd = str;
00431     strAdd += pTree->GetItemText(itemChild);
00432     // do not want to add brushes or things, just groups 
00433     if (pTree->GetItemData(itemChild) == 0)
00434     {
00435       pArray->Add(strAdd);
00436     }
00437     if (pTree->ItemHasChildren(itemChild))
00438     {
00439       HTREEITEM itemOffspring = pTree->GetChildItem(itemChild);
00440       DecomposeSiblingList(strAdd, pArray, pTree, itemOffspring); 
00441     }
00442     itemChild = pTree->GetNextSiblingItem(itemChild);
00443   }
00444 }

void Group_Add entity_t e  ) 
 

Definition at line 56 of file GroupDlg.cpp.

References e, group_s::epairs, entity_t::epairs, g(), g_pGroups, g_wndGroup, group_t, group_s::itemOwner, CGroupDlg::m_hWorld, CGroupDlg::m_wndTree, memset(), group_s::next, qmalloc(), and ValueForKey().

Referenced by Map_LoadFile().

00057 {
00058   group_t *g = (group_t*)qmalloc(sizeof(group_t));
00059   g->epairs = e->epairs;
00060   g->next = NULL;
00061   e->epairs = NULL;
00062   // create a new group node
00063   HTREEITEM hItem = g_wndGroup.m_wndTree.GetSelectedItem();
00064   TVINSERTSTRUCT tvInsert;
00065   memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
00066   tvInsert.item.iImage = IMG_GROUP;
00067   tvInsert.item.iSelectedImage = tvInsert.item.iImage;
00068     //++timo wasat?
00069   // tvInsert.hParent = (hItem) ? hItem : m_hWorld;
00070   tvInsert.hParent = g_wndGroup.m_hWorld;
00071   tvInsert.hInsertAfter = NULL;
00072   tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
00073   char *pipo = ValueForKey(e->epairs, "group");
00074   tvInsert.item.pszText = _T(ValueForKey(g->epairs, "group"));
00075     g->itemOwner = g_wndGroup.m_wndTree.InsertItem(&tvInsert);
00076   g->next = g_pGroups;
00077     g_pGroups = g;
00078 }

Here is the call graph for this function:

void Group_AddToItem brush_t b,
HTREEITEM  item
 

Definition at line 99 of file GroupDlg.cpp.

References b, Brush_GetKeyValue(), brush_t, entity_s::eclass, eclass_s::fixedsize, g_pGroupDlg, g_qeglobals, IMG_PATCH, QEGlobals_t::m_bBrushPrimitMode, CGroupDlg::m_wndTree, memset(), eclass_s::name, brush_s::owner, brush_s::patchBrush, and strcpy().

Referenced by Group_AddToProperGroup(), Group_AddToSelected(), and Group_AddToWorld().

00100 {
00101   char cBuff[1024];
00102   int nImage = IMG_BRUSH;
00103     if (!g_qeglobals.m_bBrushPrimitMode)
00104   {
00105     return;
00106   }
00107   const char *pName = NULL;
00108   const char *pNamed = Brush_GetKeyValue(b, "name");
00109  
00110   if (!b->owner || (b->owner == world_entity))
00111   {
00112     if (b->patchBrush) 
00113     {
00114       pName = "Generic Patch";
00115       nImage = IMG_PATCH;
00116     } 
00117     else 
00118     {
00119       pName = "Generic Brush";
00120       nImage = IMG_BRUSH;
00121     }
00122   } 
00123   else 
00124   {
00125     pName = b->owner->eclass->name;
00126     if (b->owner->eclass->fixedsize) 
00127     {
00128       nImage = IMG_ENTITY;
00129     } 
00130     else 
00131     {
00132       nImage = IMG_ENTITYGROUP;
00133     }
00134   }
00135 
00136   strcpy(cBuff, pName);
00137 
00138   TVINSERTSTRUCT tvInsert;
00139   memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
00140   tvInsert.item.iImage = (b->patchBrush) ? IMG_PATCH : IMG_BRUSH;
00141   tvInsert.item.iSelectedImage = tvInsert.item.iImage;
00142   tvInsert.hParent = item;
00143   tvInsert.hInsertAfter = NULL;
00144   tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
00145   tvInsert.item.pszText = cBuff;
00146   HTREEITEM itemNew = g_pGroupDlg->m_wndTree.InsertItem(&tvInsert);
00147   g_pGroupDlg->m_wndTree.SetItemData(itemNew, reinterpret_cast<DWORD>(b));
00148   b->itemOwner = itemNew;
00149   g_pGroupDlg->m_wndTree.RedrawWindow();
00150 
00151 }

Here is the call graph for this function:

void Group_AddToProperGroup brush_t b  ) 
 

Definition at line 178 of file GroupDlg.cpp.

References b, Brush_GetKeyValue(), brush_t, g(), g_pGroupDlg, g_qeglobals, Group_AddToItem(), Group_AddToWorld(), Group_ForName(), group_t, brush_s::itemOwner, group_s::itemOwner, QEGlobals_t::m_bBrushPrimitMode, CGroupDlg::m_wndTree, and Sys_Printf().

Referenced by Brush_Build(), Group_Init(), and Select_AddToGroup().

00179 {
00180     if (!g_qeglobals.m_bBrushPrimitMode)
00181     {
00182         return;
00183     }
00184     // NOTE: we do a local copy of the "group" key because it gets erased by Group_RemoveBrush
00185     const char *pGroup = Brush_GetKeyValue(b, "group");
00186   // remove the entry in the tree if there's one
00187   if (b->itemOwner)
00188   {
00189         g_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);
00190         b->itemOwner = NULL;
00191         g_pGroupDlg->m_wndTree.RedrawWindow();
00192   }
00193 
00194     if (*pGroup != 0)
00195     {
00196         // find the item
00197         group_t *g = Group_ForName(pGroup);
00198         if (g)
00199             Group_AddToItem(b, g->itemOwner);
00200 #ifdef _DEBUG
00201         else
00202             Sys_Printf("WARNING: unexpected Group_ForName not found in Group_AddToProperGroup\n");
00203 #endif
00204     }
00205     else
00206     {
00207         Group_AddToWorld(b);
00208     }
00209 }

Here is the call graph for this function:

void Group_AddToSelected brush_t b  ) 
 

Definition at line 211 of file GroupDlg.cpp.

References b, brush_t, g_pGroupDlg, g_qeglobals, Group_AddToItem(), QEGlobals_t::m_bBrushPrimitMode, and CGroupDlg::m_wndTree.

00212 {
00213     if (!g_qeglobals.m_bBrushPrimitMode)
00214   {
00215     return;
00216   }
00217   HTREEITEM hItem = g_pGroupDlg->m_wndTree.GetSelectedItem();
00218   if (hItem == NULL)
00219   {
00220     hItem = g_pGroupDlg->m_wndTree.GetRootItem();
00221   }
00222   Group_AddToItem(b, hItem);
00223 }

Here is the call graph for this function:

void Group_AddToWorld brush_t b  ) 
 

Definition at line 168 of file GroupDlg.cpp.

References b, brush_t, g_pGroupDlg, g_qeglobals, Group_AddToItem(), QEGlobals_t::m_bBrushPrimitMode, and CGroupDlg::m_wndTree.

Referenced by Group_AddToProperGroup().

00169 {
00170     if (!g_qeglobals.m_bBrushPrimitMode)
00171   {
00172     return;
00173   }
00174   HTREEITEM itemParent = g_pGroupDlg->m_wndTree.GetRootItem();
00175   Group_AddToItem(b, itemParent);
00176 }

Here is the call graph for this function:

group_t* Group_Alloc char *  name  ) 
 

Definition at line 80 of file GroupDlg.cpp.

References group_s::epairs, g(), group_t, name, qmalloc(), and SetKeyValue().

00081 {
00082   group_t *g = (group_t*)qmalloc(sizeof(group_t));
00083     SetKeyValue( g->epairs, "group", name );
00084   return g;
00085 }

Here is the call graph for this function:

group_t* Group_ForName const char *  name  ) 
 

Definition at line 87 of file GroupDlg.cpp.

References group_s::epairs, g(), group_t, name, group_s::next, strcmp(), and ValueForKey().

Referenced by Group_AddToProperGroup().

00088 {
00089     group_t *g = g_pGroups;
00090     while (g != NULL)
00091     {
00092         if (strcmp( ValueForKey(g->epairs,"group"), name ) == 0)
00093             break;
00094         g = g->next;
00095     }
00096     return g;
00097 }

Here is the call graph for this function:

void Group_GetListFromWorld CStringArray *  pArray  ) 
 

Definition at line 288 of file GroupDlg.cpp.

References g_qeglobals, GROUPNAME, i, QEGlobals_t::m_bBrushPrimitMode, sprintf(), strlen(), ValueForKey(), and world_entity.

Referenced by Group_RemoveListFromWorld().

00289 {
00290     if (!g_qeglobals.m_bBrushPrimitMode)
00291   {
00292     return;
00293   }
00294 
00295   if (world_entity == NULL)
00296   {
00297     return;
00298   }
00299 
00300   pArray->RemoveAll();
00301   char cBuff[1024];
00302   for (int i =0; i < MAX_GROUPS; i++)
00303   {
00304     sprintf(cBuff, GROUPNAME, i);
00305     char *pGroup = ValueForKey(world_entity, cBuff);
00306     if (pGroup && strlen(pGroup) > 0)
00307     {
00308       pArray->Add(pGroup);
00309     }
00310     else
00311     {
00312       break;
00313     }
00314   }
00315 }

Here is the call graph for this function:

void Group_Init  ) 
 

Definition at line 235 of file GroupDlg.cpp.

References active_brushes, b, brush_t, epair_t, group_s::epairs, free(), g(), g_pGroups, g_qeglobals, g_wndGroup, Group_AddToProperGroup(), group_t, brush_s::itemOwner, epair_s::key, QEGlobals_t::m_bBrushPrimitMode, CGroupDlg::m_wndTree, memset(), epair_s::next, group_s::next, brush_s::next, selected_brushes, Sys_Printf(), and epair_s::value.

Referenced by CGroupDlg::InitGroups(), Map_LoadFile(), and Map_New().

00236 {
00237     if (!g_qeglobals.m_bBrushPrimitMode)
00238   {
00239     return;
00240   }
00241     // start by cleaning everything
00242   // clean the groups
00243   //++timo FIXME: we leak, delete the groups on the way (I don't have time to do it now)
00244 #ifdef _DEBUG
00245   Sys_Printf("TODO: fix leak in Group_Init\n");
00246 #endif
00247   group_t *g = g_pGroups;
00248   while (g)
00249   {
00250     epair_t *ep,*enext;
00251       for (ep = g->epairs ; ep ; ep=enext )
00252       {
00253           enext = ep->next;
00254           free (ep->key);
00255           free (ep->value);
00256           free (ep);
00257       }
00258     g = g->next;
00259   }
00260   g_pGroups = NULL;
00261     g_wndGroup.m_wndTree.DeleteAllItems();
00262   TVINSERTSTRUCT tvInsert;
00263   memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));
00264   tvInsert.hParent = NULL;
00265   tvInsert.hInsertAfter = NULL;
00266   tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
00267   tvInsert.item.pszText = _T("World");
00268   tvInsert.item.iImage = IMG_GROUP;
00269   tvInsert.item.iSelectedImage = IMG_GROUP;
00270   HTREEITEM hWorld = g_wndGroup.m_wndTree.InsertItem(&tvInsert);
00271     // walk through all the brushes, remove the itemOwner key and add them back where they belong
00272     brush_t *b;
00273     for (b = active_brushes.next; b != &active_brushes; b = b->next)
00274     {
00275         b->itemOwner = NULL;
00276         Group_AddToProperGroup(b);
00277     }
00278     for (b = selected_brushes.next ; b != &selected_brushes ; b = b->next)
00279     {
00280         b->itemOwner = NULL;
00281         Group_AddToProperGroup(b);
00282     }
00283 }

Here is the call graph for this function:

void Group_RemoveBrush brush_t b  ) 
 

Definition at line 153 of file GroupDlg.cpp.

References b, brush_t, DeleteKey(), brush_s::epairs, g_pGroupDlg, g_qeglobals, brush_s::itemOwner, QEGlobals_t::m_bBrushPrimitMode, and CGroupDlg::m_wndTree.

Referenced by Brush_Free().

00154 {
00155     if (!g_qeglobals.m_bBrushPrimitMode)
00156     {
00157         return;
00158     }
00159     if (b->itemOwner)
00160     {
00161         g_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);
00162         b->itemOwner = NULL;
00163         g_pGroupDlg->m_wndTree.RedrawWindow();
00164     }
00165     DeleteKey(b->epairs, "group");
00166 }

Here is the call graph for this function:

void Group_RemoveListFromWorld  ) 
 

Definition at line 317 of file GroupDlg.cpp.

References array(), DeleteKey(), g_qeglobals, Group_GetListFromWorld(), i, QEGlobals_t::m_bBrushPrimitMode, and world_entity.

00318 {
00319     if (!g_qeglobals.m_bBrushPrimitMode)
00320   {
00321     return;
00322   }
00323   CStringArray array;
00324   Group_GetListFromWorld(&array);
00325   int nCount = array.GetSize();
00326   for (int i = 0; i < nCount; i++)
00327   {
00328     DeleteKey(world_entity, array.GetAt(i));
00329   }
00330 }

Here is the call graph for this function:

void Group_Save FILE f  ) 
 

Definition at line 225 of file GroupDlg.cpp.

References group_s::epairs, f, fprintf(), g(), group_t, group_s::next, and ValueForKey().

Referenced by Map_SaveFile().

00226 {
00227     group_t *g = g_pGroups;
00228     while (g)
00229   {
00230     fprintf(f,"{\n\"classname\" \"group_info\"\n\"group\" \"%s\"\n}\n", ValueForKey( g->epairs, "group" ));
00231     g = g->next;
00232   }
00233 }

Here is the call graph for this function:

OnBtnAdd ON_BN_CLICKED IDC_BTN_DEL  ,
OnBtnDel 
 

OnBtnAdd OnBtnEdit OnEndlabeleditTreeGroup OnSetdispinfoTreeGroup ON_NOTIFY TVN_BEGINDRAG  ,
IDC_TREE_GROUP  ,
OnBegindragTreeGroup 
 

Definition at line 499 of file GroupDlg.cpp.

References NULL.

00507 {
00508     CDialog::OnSize(nType, cx, cy);
00509     CRect rct;
00510   GetClientRect(rct);
00511 
00512   if ( m_wndAdd.GetSafeHwnd())
00513   {
00514     //all borders at 4, spacing at 6
00515     CRect rctButton;
00516     m_wndAdd.GetWindowRect(rctButton);
00517     int nWidth = rctButton.Width();
00518     int nHeight = rctButton.Height();
00519 
00520     int nTop = rct.Height() - nHeight - 4;
00521 
00522     m_wndAdd.SetWindowPos(NULL, 4, nTop, 0, 0, SWP_NOSIZE);
00523     m_wndEdit.SetWindowPos(NULL, 8 + nWidth , nTop, 0, 0, SWP_NOSIZE);
00524     m_wndDel.SetWindowPos(NULL, 12 + (nWidth * 2), nTop, 0, 0, SWP_NOSIZE);
00525     rct.bottom = nTop;
00526     m_wndTree.SetWindowPos(NULL, rct.left + 4, rct.top + 4, rct.Width() - 8, rct.Height() - 8, SWP_SHOWWINDOW);
00527   }
00528 }

OnBtnAdd OnBtnEdit OnEndlabeleditTreeGroup ON_NOTIFY NM_CLICK  ,
IDC_TREE_GROUP  ,
OnClickTreeGroup 
 

OnBtnAdd OnBtnEdit ON_NOTIFY NM_RCLICK  ,
IDC_TREE_GROUP  ,
OnRclickTreeGroup 
 


Variable Documentation

CGroupDlg* g_pGroupDlg = &g_wndGroup
 

Definition at line 50 of file GroupDlg.cpp.

Referenced by Group_AddToItem(), Group_AddToProperGroup(), Group_AddToSelected(), Group_AddToWorld(), Group_RemoveBrush(), and CMainFrame::OnCreateClient().

group_t* g_pGroups = NULL
 

Definition at line 54 of file GroupDlg.cpp.

Referenced by Group_Add(), Group_Init(), and CGroupDlg::OnBtnAdd().

CGroupDlg g_wndGroup
 

Definition at line 49 of file GroupDlg.cpp.

Referenced by Group_Add(), and Group_Init().

OnBtnAdd OnBtnEdit OnEndlabeleditTreeGroup IDC_TREE_GROUP
 

Definition at line 498 of file GroupDlg.cpp.


Generated on Thu Aug 25 17:36:34 2005 for Quake III Arena by  doxygen 1.3.9.1