/* ************************************
* BOOL InitTreeViewItems(HWND hwndTV)
* 功能	为Tree View窗口增加若干个节点
* 参数	hwndTV,Tree View控件窗口句柄
**************************************/
BOOL InitTreeViewItems(HWND hwndTV)
{
	// 根节点1
	HTREEITEM hRoot = AddItemToTree(hwndTV, "type1", NULL,TRUE);
	// 根节点1的子节点1
	HTREEITEM hP = AddItemToTree(hwndTV, "name1", hRoot,FALSE);
	// 根节点1的子节点2
	hP = AddItemToTree(hwndTV, "name2", hRoot, TRUE);
	// 子节点2的子节点
	AddItemToTree(hwndTV, "sub1", hP,FALSE);
	// 子节点2的了节点
	AddItemToTree(hwndTV, "sub2", hP,FALSE);
	// 根节点2
	hRoot = AddItemToTree(hwndTV, "type2", NULL,TRUE);
	// 根节点2的子节点
	hP = AddItemToTree(hwndTV, "name3", hRoot, TRUE);
	// 根节点2的子子节点
	hP = AddItemToTree(hwndTV, "sub3", hP,FALSE);
	// 根节点3
	hRoot = AddItemToTree(hwndTV, "type3", NULL,TRUE);

	return TRUE;
}
Beispiel #2
0
void zoneList::occupy(entry *zone)
{
  unsigned char *zoneHeader = zone->itemData[0];
  modelCount = getWord(zoneHeader, 0, true);  
  headerColCount = getWord(zoneHeader, 0x204, true);
  sectionCount = getWord(zoneHeader, 0x208, true);
  entityCount = getWord(zoneHeader, 0x20C, true);
  neighborCount = getWord(zoneHeader, 0x210, true);
  
  char zoneModelString[8][30];
  for (unsigned long lp=0; lp<modelCount; lp++)
  {
    unsigned long modelEID = getWord(zoneHeader, 4+(lp*0x40), true);
    getEIDstring(zoneModelString[lp], modelEID);
    
    unsigned long parentCID = nsd->lookupCID(modelEID);
    if (parentCID != -1)
    {
      chunk *parentChunk      = nsf->lookupChunk(parentCID);
      zoneModel[lp]           = lookupEntry(modelEID, parentChunk);
    }
    else
    {
      char temp[6];
      getEIDstring(temp, modelEID);
      sprintf(zoneModelString[lp], "BAD REF: %s", temp);
      
      zoneModel[lp] = 0;
    }
  }
  
  char zoneEntityString[20][10];
  for (unsigned long lp=0; lp<entityCount; lp++)
  {
    unsigned char *entity = zone->itemData[headerColCount+sectionCount+lp];
    
    unsigned short entityID = getHword(entity, 0x8, true);
    
    unsigned char codeIndex = entity[0x12];
    unsigned long entityCodeEID = nsd->levelEIDs[codeIndex];
    char entityCodeEIDString[6];
    getEIDstring(entityCodeEIDString, entityCodeEID);
    
    sprintf(zoneEntityString[lp], "%i: %s", entityID, entityCodeEIDString);
  }
  
  char zoneNeighborString[20][10];
  for (unsigned long lp=0; lp<neighborCount; lp++)
  {
    unsigned long neighborEID = getWord(zoneHeader, 0x214+(lp*4), true);
    getEIDstring(zoneNeighborString[lp], neighborEID);
    
    unsigned long parentCID = nsd->lookupCID(neighborEID);
    if (parentCID != -1)
    {
      chunk *parentChunk      = nsf->lookupChunk(parentCID);
      zoneNeighbor[lp]        = lookupEntry(neighborEID, parentChunk);
    }
    else
    {
      char temp[6];
      getEIDstring(temp, neighborEID);
      sprintf(zoneNeighborString[lp], "BAD REF: %s", temp);
      
      zoneNeighbor[lp] = 0;
    }
  }
  
  char zoneEIDString[6];
  getEIDstring(zoneEIDString, zone->EID);
  
  char zoneString[20];
  sprintf(zoneString, "Zone: %s", zoneEIDString);
  
  AddItemToTree(hwnd, zoneString, 1, 1);
  
  AddItemToTree(hwnd, "Models", 2, 0);
  for (unsigned long lp=0; lp<modelCount; lp++)    
    AddItemToTree(hwnd, zoneModelString[lp], 3, (lp << 8) | 3);
  
  AddItemToTree(hwnd, "Entities", 2, 0);
  for (unsigned long lp=0; lp<entityCount; lp++)
    AddItemToTree(hwnd, zoneEntityString[lp], 3, (lp << 8) | 5);
  
  AddItemToTree(hwnd, "Sections", 2, 0);
  for (unsigned long lp=0; lp<sectionCount; lp++)
  {
    char sectionString[20];
    sprintf(sectionString, "Section %i", lp);
    AddItemToTree(hwnd, sectionString, 3, 0);
    
    AddItemToTree(hwnd,            "Camera", 4, (lp << 8) | (0 << 3) | 4);
    AddItemToTree(hwnd, "Neighbor Sections", 4, (lp << 8) | (1 << 3) | 4);
  }
  
  AddItemToTree(hwnd, "Neighbor Zones", 2, 0);
  for (unsigned long lp=0; lp<neighborCount; lp++)
  {
    AddItemToTree(hwnd, zoneNeighborString[lp], 3, (lp << 8) | 2);
  }
  
  AddItemToTree(hwnd,          "Lighting properties", 2, (1 << 3) | 1);
  AddItemToTree(hwnd, "Shading/rendering properties", 2, (2 << 3) | 1); 
  AddItemToTree(hwnd,             "Collision octree", 2, (3 << 3) | 1);
}
//-----------------------------------------------------------------------------
//	ExcludePathsDlg_Populate
//
//	Generate a path table.
//-----------------------------------------------------------------------------
void ExcludePathsDlg_Populate( HWND hWnd, bool bRefresh )
{
	struct GamePath_t 
	{
		CUtlString	pathName;
		bool		bIsModPath;
	};

	CUtlVector< GamePath_t > gamePaths;		

	// can skip the time consuming directory scan, unless forced
	if ( bRefresh || !g_PathTable.Count() )
	{
		g_PathTable.Purge();

		for ( int i = 0; i < ARRAYSIZE( g_GameNames ); i++ )
		{
			char szTargetPath[MAX_PATH];
			V_strncpy( szTargetPath, g_localPath, sizeof( szTargetPath ) );
			V_AppendSlash( szTargetPath, sizeof( szTargetPath ) );
			V_strncat( szTargetPath, g_GameNames[i].pName, sizeof( szTargetPath ) );

			GamePath_t gamePath;
			gamePath.pathName = szTargetPath;
			gamePath.bIsModPath = g_GameNames[i].bIsModPath;
			gamePaths.AddToTail( gamePath );
		}

		// iterate all game paths
		for ( int i = 0; i < gamePaths.Count(); i++ )
		{
			CUtlVector< CUtlString > dirList;
			RecurseFileTree_r( g_localPath, gamePaths[i].pathName.String(), 0, dirList, gamePaths[i].bIsModPath );
		}
	}

	// reset the tree
	HWND hWndTree = GetDlgItem( hWnd, IDC_PATHS_TREE );
	TreeView_DeleteAllItems( hWndTree );

	// reset and add root
	// only the root is at depth 0
	AddItemToTree( hWndTree, ROOT_NAME, 0, false );

	// build the tree view
	for ( int iIndex = g_PathTable.FirstInorder(); iIndex != g_PathTable.InvalidIndex(); iIndex = g_PathTable.NextInorder( iIndex ) )
	{
		// due to sorting, number of slashes is depth
		const char *pString = g_PathTable[iIndex].pathName.String();
		int depth = 0;
		for ( int j = 0; j < (int)strlen( pString ); j++ )
		{
			if ( pString[j] == '\\' )
			{
				depth++;
			}
		}
		if ( !depth )
		{
			depth = 1;
		}

		char szPath[MAX_PATH];
		V_FileBase( pString, szPath, sizeof( szPath ) );
		AddItemToTree( hWndTree, szPath, depth, g_PathTable[iIndex].bIsModPath );
	}

	HTREEITEM hTreeRoot = TreeView_GetRoot( hWndTree );
	for ( int i = 0; i < g_ExcludePaths.Count(); i++ )
	{
		HTREEITEM hTree = ExcludePathsDlg_Find_r( hWndTree, hTreeRoot, 0, "", g_ExcludePaths[i].String() );
		if ( hTree )
		{
			ExcludePathsDlg_SetCheckState_r( hWndTree, hTree, 0, true );
		}
	}

	// expand the root node to show state
	ExcludePathsDlg_ExpandToShowState_r( hWndTree, hTreeRoot, 0 );
}
void MorphByBone::BuildTreeList()
{
//get our handle

	suspendUI = TRUE;
	HWND treeHWND = GetDlgItem(rollupHWND,IDC_TREE1);
	int tempBone, tempMorph;
	tempBone = currentBone;
	tempMorph = currentMorph;

	
	COLORREF clrBk = ColorMan()->GetColor(kWindow);
	TreeView_SetBkColor( treeHWND, clrBk); 



//	TVITEM tvi;

	BitArray expanded;
	expanded.SetSize(boneData.Count());
	expanded.ClearAll();
	for (int i = 0; i < boneData.Count(); i++)
		{
	//if !null
		INode *node = GetNode(i);
		if (node != NULL)
			{
	//add to parent
			TSTR name = node->GetName();
	//add the node as a root entry
			BOOL expand = TreeView_GetItemState(treeHWND,boneData[i]->treeHWND,TVIS_EXPANDED);
			if (expand)
				{
				expanded.Set(i);
				}
			}
		}

	TreeView_DeleteAllItems(treeHWND);	
	currentBone = tempBone;
	currentMorph = tempMorph;

	//DebugPrint(_T("Morph name creatiuon\n"));
//loop through our nodes
	for (int i = 0; i < boneData.Count(); i++)
		{
	//if !null
		INode *node = GetNode(i);
		if (node != NULL)
			{
	//add to parent
			TSTR name = node->GetName();
	//add the node as a root entry
			boneData[i]->tvi.state = 0;

			HTREEITEM parent = AddItemToTree(treeHWND, boneData[i]->tvi, name,i,TVI_ROOT);
			
			boneData[i]->treeHWND = parent;
			if (expanded[i])
			{
				boneData[i]->tvi.state = TVIS_EXPANDED;
				TreeView_SetItemState(treeHWND,boneData[i]->treeHWND,TVIS_EXPANDED,TVIS_EXPANDED);
			}
			if ((currentMorph == -1) && (i==currentBone))
			{
				if (i==currentBone)
				{
 				TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,TVIS_SELECTED,TVIS_SELECTED);
				TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,TVIS_BOLD,TVIS_BOLD);
				}
				else
				{
				TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,0,TVIS_SELECTED);
				TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,0,TVIS_BOLD);

				}
			}
	//loop through targets and add those as children
			for (int j = 0 ; j < boneData[i]->morphTargets.Count(); j++)
				{
				if (!boneData[i]->morphTargets[j]->IsDead())
					{
//add morph target to list
					TSTR morphName;
					if (boneData[i]->morphTargets[j]->IsDisabled())
						morphName.printf(_T("%s(%s)"),boneData[i]->morphTargets[j]->name,GetString(IDS_DISABLED));
					else morphName.printf(_T("%s(%0.1f)"),boneData[i]->morphTargets[j]->name,boneData[i]->morphTargets[j]->weight*100.f);

//					boneData[i]->morphTargets[j]->tvi.state = TVIS_BOLD ;
//					boneData[i]->morphTargets[j]->tvi.stateMask |= TVIS_BOLD ;
//DebugPrint(_T("Morph name %s\n"),morphName);
					boneData[i]->morphTargets[j]->tvi.state = 0;
					boneData[i]->morphTargets[j]->treeHWND = AddItemToTree(treeHWND ,boneData[i]->morphTargets[j]->tvi, morphName, (i+1)*1000+j,parent);

					if ((i== currentBone) && (j == currentMorph))
					{
						TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,TVIS_SELECTED ,TVIS_SELECTED );
						TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,TVIS_BOLD ,TVIS_BOLD );
					}
					else
					{
						TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,0 ,TVIS_SELECTED );
						TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,0 ,TVIS_BOLD );
					}





					
					}
				}
			}
		}
	suspendUI = FALSE;

}