当前位置: 首页>>代码示例>>C++>>正文


C++ CUtlDict::GetElementName方法代码示例

本文整理汇总了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;
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:27,代码来源:classmap.cpp

示例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 );
            }
        }
    }
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:30,代码来源:texturemanager.cpp

示例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();
        }
    }
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:29,代码来源:ai_speech.cpp

示例4:

char const *CMapEntities::GetName( int number )
{
    if ( number < 0 || number >= (int)m_Entities.Count() )
        return NULL;

    return m_Entities.GetElementName( number );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:7,代码来源:eventproperties.cpp

示例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) );
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:17,代码来源:decals.cpp

示例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 );
//.........这里部分代码省略.........
开发者ID:djoslin0,项目名称:ges-legacy-code,代码行数:101,代码来源:ge_createserver.cpp

示例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 );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:unusedcontent.cpp

示例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 );
            }
        }
    }
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:92,代码来源:texturemanager.cpp


注:本文中的CUtlDict::GetElementName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。