本文整理汇总了C++中CUtlDict::GetElementName方法的典型用法代码示例。如果您正苦于以下问题:C++ CUtlDict::GetElementName方法的具体用法?C++ CUtlDict::GetElementName怎么用?C++ CUtlDict::GetElementName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtlDict
的用法示例。
在下文中一共展示了CUtlDict::GetElementName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
C_BaseEntity *CClassMap::CreateEntity( const char *mapname )
{
int c = m_ClassDict.Count();
int i;
for ( i = 0; i < c; i++ )
{
classentry_t *lookup = &m_ClassDict[ i ];
if ( !lookup )
continue;
if ( Q_stricmp( lookup->GetMapName(), mapname ) )
continue;
if ( !lookup->factory )
{
#if defined( _DEBUG )
Msg( "No factory for %s/%s\n", lookup->GetMapName(), m_ClassDict.GetElementName( i ) );
#endif
continue;
}
return ( *lookup->factory )();
}
return NULL;
}
示例2: DebugPrintUsedTextures
void CTextureManager::DebugPrintUsedTextures( void )
{
for ( int i = m_TextureList.First(); i != m_TextureList.InvalidIndex(); i = m_TextureList.Next( i ) )
{
ITextureInternal *pTexture = m_TextureList[i];
Msg( "Texture: '%s' RefCount: %d\n", pTexture->GetName(), pTexture->GetReferenceCount() );
}
if ( m_TextureExcludes.Count() )
{
Msg( "\nExcluded Textures: (%d)\n", m_TextureExcludes.Count() );
for ( int i = m_TextureExcludes.First(); i != m_TextureExcludes.InvalidIndex(); i = m_TextureExcludes.Next( i ) )
{
char buff[256];
const char *pName = m_TextureExcludes.GetElementName( i );
V_snprintf( buff, sizeof( buff ), "Excluded: %d '%s' \n", m_TextureExcludes[i], pName );
// an excluded texture is valid, but forced tiny
if ( IsTextureLoaded( pName ) )
{
Msg( buff );
}
else
{
// warn as unknown, could be a spelling error
Warning( buff );
}
}
}
}
示例3: Save
virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave )
{
CUtlDict< ConceptHistory_t, int > *ch = ((CUtlDict< ConceptHistory_t, int > *)fieldInfo.pField);
int count = ch->Count();
pSave->WriteInt( &count );
for ( int i = 0 ; i < count; i++ )
{
ConceptHistory_t *pHistory = &(*ch)[ i ];
pSave->StartBlock();
{
// Write element name
pSave->WriteString( ch->GetElementName( i ) );
// Write data
pSave->WriteAll( pHistory );
// Write response blob
bool hasresponse = pHistory->response != NULL ? true : false;
pSave->WriteBool( &hasresponse );
if ( hasresponse )
{
pSave->WriteAll( pHistory->response );
}
// TODO: Could blat out pHistory->criteria pointer here, if it's needed
}
pSave->EndBlock();
}
}
示例4:
char const *CMapEntities::GetName( int number )
{
if ( number < 0 || number >= (int)m_Entities.Count() )
return NULL;
return m_Entities.GetElementName( number );
}
示例5:
//-----------------------------------------------------------------------------
// Purpose:
// Input : gamematerial -
// Output : char const
//-----------------------------------------------------------------------------
char const *CDecalEmitterSystem::ImpactDecalForGameMaterial( int gamematerial )
{
char gm[ 2 ];
gm[0] = (char)gamematerial;
gm[1] = 0;
int idx = m_GameMaterialTranslation.Find( gm );
if ( idx == m_GameMaterialTranslation.InvalidIndex() )
return NULL;
return m_Decals.GetElementName( m_GameMaterialTranslation.Element(idx) );
}
示例6: PopulateControls
void CGECreateServer::PopulateControls( void )
{
// Only populate on first load
if ( !m_bFirstLoad )
return;
// Populate the map list
ComboBox *maplist = dynamic_cast<ComboBox*>( FindChildByName("MapList") );
if ( maplist )
{
// Clear the list first
maplist->DeleteAllItems();
FileFindHandle_t findHandle; // note: FileFINDHandle
char file[32];
maplist->AddItem( "#SERVER_RANDOM_MAP", new KeyValues(RANDOM_VALUE) );
const char *pFilename = filesystem->FindFirstEx( "maps\\*.bsp", "MOD", &findHandle );
while ( pFilename )
{
if ( stricmp(pFilename, "ge_transition.bsp") ) //They don't need to pick our dinky crash avoidance map.
{
// Add the map to the list
Q_FileBase(pFilename, file, 32);
maplist->AddItem(file, new KeyValues(file));
}
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
maplist->SetNumberOfEditLines( 10 );
maplist->SetEditable( false );
maplist->GetMenu()->ForceCalculateWidth();
maplist->ActivateItemByRow( 0 );
}
// Populate the weapon list
ComboBox *weaponlist = dynamic_cast<ComboBox*>( FindChildByName("WeaponList") );
if ( weaponlist )
{
weaponlist->DeleteAllItems();
// TAKEN DIRECTLY FROM ge_loadoutmanager.cpp
// Parsing individually allows us to overwrite the default sets with custom ones
// Multiple custom sets can be defined as needed (can even make sets per gameplay)
if ( !GELoadoutParser.HasBeenParsed() )
{
GELoadoutParser.InitParser("scripts/loadouts/weapon_sets_default.X");
GELoadoutParser.SetHasBeenParsed( false );
GELoadoutParser.InitParser("scripts/loadouts/weapon_sets_custom*.X");
}
// Random loadout
weaponlist->AddItem( "#SERVER_RANDOM_SET", new KeyValues("random_loadout") );
FOR_EACH_DICT( m_WeaponSets, idx )
{
if (Q_strstr(m_WeaponSets.GetElementName(idx), "_mhide"))
continue;
int id = weaponlist->AddItem( m_WeaponSets.GetElementName(idx), NULL );
weaponlist->GetMenu()->SetItemEnabled( id, false );
for ( int k=m_WeaponSets[idx]->First(); k != m_WeaponSets[idx]->InvalidIndex(); k = m_WeaponSets[idx]->Next(k) )
weaponlist->AddItem( m_WeaponSets[idx]->Element(k), new KeyValues(m_WeaponSets[idx]->GetElementName(k)) );
}
weaponlist->SetEditable( false );
weaponlist->SetNumberOfEditLines( 15 );
weaponlist->GetMenu()->ForceCalculateWidth();
weaponlist->ActivateItemByRow( 0 );
}
// Populate the scenario list
ComboBox *scenariolist = dynamic_cast<ComboBox*>( FindChildByName("ScenarioList") );
if ( scenariolist )
{
// Clear the list first
scenariolist->DeleteAllItems();
FileFindHandle_t findHandle; // note: FileFINDHandle
char file[32];
scenariolist->AddItem( "#SERVER_RANDOM_SCENARIO", new KeyValues(RANDOM_VALUE) );
const char *pFilename = filesystem->FindFirstEx( PYDIR, "MOD", &findHandle );
while ( pFilename )
{
// Add the scenario to the list if not __init__
if ( !Q_stristr( pFilename, "__init__") )
{
Q_FileBase( pFilename, file, 32 );
scenariolist->AddItem( file, new KeyValues(file) );
}
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
scenariolist->SetEditable( false );
//.........这里部分代码省略.........
示例7: Correlate
//.........这里部分代码省略.........
// Don't delete stuff that's in the white list
if ( g_WhiteList.Find( entry.sym ) != g_WhiteList.InvalidIndex() )
{
if ( verbose )
{
vprint( 0, "whitelist blocked deletion of %s\n", g_Analysis.symbols.String( entry.sym ) );
}
continue;
}
++deletionCount;
deletionSize += entry.size;
if ( immediatedelete )
{
if ( _chmod( g_Analysis.symbols.String( entry.sym ), _S_IWRITE ) == -1 )
{
vprint( 0, "Could not find file %s\n", g_Analysis.symbols.String( entry.sym ) );
}
if ( _unlink( g_Analysis.symbols.String( entry.sym ) ) == -1 )
{
vprint( 0, "Could not delete file %s\n", g_Analysis.symbols.String( entry.sym ) );
}
if ( deletionCount % 1000 == 0 )
{
vprint( 0, "...deleted %i files\n", deletionCount );
}
}
else
{
logprint( "deletions.bat", "del \"%s\" /f\n", g_Analysis.symbols.String( entry.sym ) );
}
}
vprint( 0, "\nFile deletion (%d files, %s)\n\n", deletionCount, Q_pretifymem(deletionSize, 2) );
}
double grand_total = 0;
double grand_total_unref = 0;
double grand_total_white = 0;
char totalstring[ 20 ];
char unrefstring[ 20 ];
char refstring[ 20 ];
char whiteliststring[ 20 ];
vprint( 0, "---------------------------------------- Summary ----------------------------------------\n" );
vprint( 0, "% 15s % 15s % 15s % 15s %12s\n",
"Referenced",
"WhiteListed",
"Unreferenced",
"Total",
"Directory" );
// Now walk the dictionary in order
i = directories.First();
while ( i != invalidindex )
{
DirEntry & de = directories[ i ];
double remainder = de.total - de.unreferenced;
float percent_unref = 0.0f;
float percent_white = 0.0f;
if ( de.total > 0 )
{
percent_unref = 100.0f * (float)de.unreferenced / (float)de.total;
percent_white = 100.0f * (float)de.whitelist / (float)de.total;
}
Q_strncpy( totalstring, Q_pretifymem( de.total, 2 ), sizeof( totalstring ) );
Q_strncpy( unrefstring, Q_pretifymem( de.unreferenced, 2 ), sizeof( unrefstring ) );
Q_strncpy( refstring, Q_pretifymem( remainder, 2 ), sizeof( refstring ) );
Q_strncpy( whiteliststring, Q_pretifymem( de.whitelist, 2 ), sizeof( whiteliststring ) );
vprint( 0, "%15s (%8.3f%%) %15s (%8.3f%%) %15s (%8.3f%%) %15s => dir: %s\n",
refstring, 100.0f - percent_unref, whiteliststring, percent_white, unrefstring, percent_unref, totalstring, directories.GetElementName( i ) );
grand_total += de.total;
grand_total_unref += de.unreferenced;
grand_total_white += de.whitelist;
i = directories.Next( i );
}
Q_strncpy( totalstring, Q_pretifymem( grand_total, 2 ), sizeof( totalstring ) );
Q_strncpy( unrefstring, Q_pretifymem( grand_total_unref, 2 ), sizeof( unrefstring ) );
Q_strncpy( refstring, Q_pretifymem( grand_total - grand_total_unref, 2 ), sizeof( refstring ) );
Q_strncpy( whiteliststring, Q_pretifymem( grand_total_white, 2 ), sizeof( whiteliststring ) );
double percent_unref = 100.0 * grand_total_unref / grand_total;
double percent_white = 100.0 * grand_total_white / grand_total;
vprint( 0, "-----------------------------------------------------------------------------------------\n" );
vprint( 0, "%15s (%8.3f%%) %15s (%8.3f%%) %15s (%8.3f%%) %15s\n",
refstring, 100.0f - percent_unref, whiteliststring, percent_white, unrefstring, percent_unref, totalstring );
}
示例8: SetExcludedTextures
void CTextureManager::SetExcludedTextures( const char *pScriptName )
{
// clear all exisiting texture's exclusion
for ( int i = m_TextureExcludes.First(); i != m_TextureExcludes.InvalidIndex(); i = m_TextureExcludes.Next( i ) )
{
ITextureInternal *pTexture = FindTexture( m_TextureExcludes.GetElementName( i ) );
if ( pTexture )
{
pTexture->MarkAsExcluded( false, 0 );
}
}
m_TextureExcludes.RemoveAll();
MEM_ALLOC_CREDIT();
// get optional script
CUtlBuffer excludeBuffer( 0, 0, CUtlBuffer::TEXT_BUFFER );
if ( g_pFullFileSystem->ReadFile( pScriptName, NULL, excludeBuffer ) )
{
char szToken[MAX_PATH];
while ( 1 )
{
// must support spaces in names without quotes
// have to brute force parse up to a valid line
while ( 1 )
{
excludeBuffer.EatWhiteSpace();
if ( !excludeBuffer.EatCPPComment() )
{
// not a comment
break;
}
}
excludeBuffer.GetLine( szToken, sizeof( szToken ) );
int tokenLength = strlen( szToken );
if ( !tokenLength )
{
// end of list
break;
}
// remove all trailing whitespace
while ( tokenLength > 0 )
{
tokenLength--;
if ( isgraph( szToken[tokenLength] ) )
{
break;
}
szToken[tokenLength] = '\0';
}
// first optional token may be a dimension limit hint
int nDimensionsLimit = 0;
char *pTextureName = szToken;
if ( pTextureName[0] != 0 && isdigit( pTextureName[0] ) )
{
nDimensionsLimit = atoi( pTextureName );
// skip forward to name
for ( ;; )
{
char ch = *pTextureName;
if ( !ch || ( !isdigit( ch ) && !isspace( ch ) ) )
{
break;
}
pTextureName++;
}
}
char szCleanName[MAX_PATH];
NormalizeTextureName( pTextureName, szCleanName, sizeof( szCleanName ) );
if ( m_TextureExcludes.Find( szCleanName ) != m_TextureExcludes.InvalidIndex() )
{
// avoid duplicates
continue;
}
m_TextureExcludes.Insert( szCleanName, nDimensionsLimit );
// set any existing texture's exclusion
// textures that don't exist yet will get caught during their creation path
ITextureInternal *pTexture = FindTexture( szCleanName );
if ( pTexture )
{
pTexture->MarkAsExcluded( ( nDimensionsLimit == 0 ), nDimensionsLimit );
}
}
}
}