MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / AddObjectToTree

Method AddObjectToTree

Editor/VegetationPanel.cpp:344–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342
343
344void CVegetationPanel::AddObjectToTree( CVegetationObject *object,bool bExpandCategory )
345{
346 CString str;
347 char filename[_MAX_PATH];
348
349 std::map<CString,HTREEITEM>::iterator cit;
350 CString category = object->GetCategory();
351
352 HTREEITEM hRoot = TVI_ROOT;
353 cit = m_categoryMap.find(category);
354 if (cit != m_categoryMap.end())
355 {
356 hRoot = cit->second;
357 }
358 if (hRoot == TVI_ROOT)
359 {
360 hRoot = m_objectsTree.InsertItem( category,0,1 );
361 m_objectsTree.SetItemData( hRoot,(DWORD_PTR)0 );
362 m_objectsTree.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD);
363 m_categoryMap[category] = hRoot;
364 }
365
366 // Add new category item.
367 _splitpath( object->GetFileName(),0,0,filename,0 );
368 str.Format( "%s (%d)",filename,object->GetNumInstances() );
369 HTREEITEM hItem = m_objectsTree.InsertItem( str,2,3,hRoot );
370 m_objectsTree.SetItemData( hItem,(DWORD_PTR)object );
371 m_objectsTree.SetCheck( hItem,!object->IsHidden() );
372
373 if (hRoot != TVI_ROOT)
374 {
375 if (bExpandCategory)
376 m_objectsTree.Expand(hRoot,TVE_EXPAND);
377
378 // Determine check state of category.
379 std::vector<CVegetationObject*> objects;
380 GetObjectsInCategory( category,objects );
381 bool anyChecked = false;
382 for (int i = 0; i < objects.size(); i++)
383 {
384 if (!objects[i]->IsHidden())
385 anyChecked = true;
386 }
387 m_objectsTree.SetCheck( hRoot,anyChecked );
388 }
389}
390
391void CVegetationPanel::UpdateObjectInTree( CVegetationObject *object,bool bUpdateInfo )
392{

Callers

nothing calls this directly

Calls 13

SetItemDataMethod · 0.80
FormatMethod · 0.80
SetCheckMethod · 0.80
GetCategoryMethod · 0.45
findMethod · 0.45
endMethod · 0.45
InsertItemMethod · 0.45
SetItemStateMethod · 0.45
GetFileNameMethod · 0.45
GetNumInstancesMethod · 0.45
IsHiddenMethod · 0.45
ExpandMethod · 0.45

Tested by

no test coverage detected