本文整理汇总了C++中KeyValues::GetNextTrueSubKey方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetNextTrueSubKey方法的具体用法?C++ KeyValues::GetNextTrueSubKey怎么用?C++ KeyValues::GetNextTrueSubKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::GetNextTrueSubKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckKeyValues
void CheckKeyValues( KeyValues *pKeyValues, CUtlVector<VTFInfo_t> &vtf )
{
for ( KeyValues *pSubKey = pKeyValues->GetFirstValue(); pSubKey; pSubKey = pSubKey->GetNextValue() )
{
if ( pSubKey->GetDataType() != KeyValues::TYPE_STRING )
continue;
if ( IsTexture( pSubKey->GetString() ) )
{
int nLen = Q_strlen( pSubKey->GetString() ) + 1;
char *pTemp = (char*)_alloca( nLen );
memcpy( pTemp, pSubKey->GetString(), nLen );
Q_FixSlashes( pTemp );
int nCount = vtf.Count();
for ( int i = 0; i < nCount; ++i )
{
if ( Q_stricmp( vtf[i].m_VTFName, pTemp ) )
continue;
vtf[i].m_bFoundInVMT = true;
break;
}
}
}
for ( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
CheckKeyValues( pSubKey, vtf );
}
}
示例2: RunPlayerInit
bool CMapAdd::RunPlayerInit( const char *mapaddMap, const char *szLabel)
{
if(AllocPooledString(mapaddMap) == AllocPooledString("") || !mapaddMap)
return false; //Failed to load!
if(!szLabel)
szLabel = "Init";
//FileHandle_t fh = filesystem->Open(szMapadd,"r","MOD");
// Open the mapadd data file, and abort if we can't
KeyValues *pMapAdd = new KeyValues( "MapAdd" );
if(pMapAdd->LoadFromFile( filesystem, mapaddMap, "MOD" ))
{
KeyValues *pMapAdd2 = pMapAdd->FindKey(szLabel);
if(pMapAdd2)
{
KeyValues *pMapAddEnt = pMapAdd2->GetFirstTrueSubKey();
while (pMapAddEnt)
{
HandlePlayerEntity(pMapAddEnt, false);
pMapAddEnt = pMapAddEnt->GetNextTrueSubKey(); //Got to keep this!
}
}
}
pMapAdd->deleteThis();
return true;
}
示例3: smn_KvGotoNextKey
static cell_t smn_KvGotoNextKey(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
KeyValues *pSubKey = pStk->pCurRoot.front();
if (params[2])
{
pSubKey = pSubKey->GetNextTrueSubKey();
} else {
pSubKey = pSubKey->GetNextKey();
}
if (!pSubKey)
{
return 0;
}
pStk->pCurRoot.pop();
pStk->pCurRoot.push(pSubKey);
return 1;
}
示例4: scan_kvtree
/**
* @brief Scans the KeyValues tree for a key with the name name.
*/
class KeyValues* CRPG_FileVar::scan_kvtree(class KeyValues *kv, char *name) {
KeyValues *subkey;
for(subkey = kv; subkey != NULL; subkey = subkey->GetNextTrueSubKey()) {
if(CRPG::istrcmp((char*)subkey->GetName(), name))
return subkey;
}
return NULL;
}
示例5: DoesMaterialHaveKey
//-----------------------------------------------------------------------------
// Scan material + all subsections for key
//-----------------------------------------------------------------------------
static bool DoesMaterialHaveKey( KeyValues *pKeyValues, const char *pKeyName )
{
if ( pKeyValues->GetString( pKeyName, NULL ) != NULL )
return true;
for( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
if ( DoesMaterialHaveKey( pSubKey, pKeyName ) )
return true;
}
return false;
}
示例6: MaterialFloatKeyValue
//-----------------------------------------------------------------------------
// Scan material + all subsections for key
//-----------------------------------------------------------------------------
static float MaterialFloatKeyValue( KeyValues *pKeyValues, const char *pKeyName, float flDefault )
{
float flValue = pKeyValues->GetFloat( pKeyName, flDefault );
if ( flValue != flDefault )
return flValue;
for( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
float flValue = MaterialFloatKeyValue( pSubKey, pKeyName, flDefault );
if ( flValue != flDefault )
return flValue;
}
return flDefault;
}
示例7: DoesMaterialHaveKeyValuePair
//-----------------------------------------------------------------------------
// Scan material + all subsections for key/value pair
//-----------------------------------------------------------------------------
static bool DoesMaterialHaveKeyValuePair( KeyValues *pKeyValues, const char *pKeyName, const char *pSearchValue )
{
const char *pVal;
pVal = pKeyValues->GetString( pKeyName, NULL );
if ( pVal != NULL && ( Q_stricmp( pSearchValue, pVal ) == 0 ) )
return true;
for( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
if ( DoesMaterialHaveKeyValuePair( pSubKey, pKeyName, pSearchValue ) )
return true;
}
return false;
}
示例8: LoadPlaylistKV
void CASWJukeboxPlaylist::LoadPlaylistKV()
{
KeyValues *pKV = new KeyValues( "playlist" );
if( pKV->LoadFromFile( filesystem, sz_PlaylistFilename ) )
{
// If the load succeeded, create the playlist
for( KeyValues *sub = pKV->GetFirstSubKey(); sub != NULL; sub = sub->GetNextTrueSubKey() )
{
const char *szTrackName = sub->GetString("TrackName");
const char *szHexName = sub->GetString("HexName");
const char *szAlbum = sub->GetString("Album");
const char *szArtist = sub->GetString("Artist");
const char *szGenre = sub->GetString("Genre");
AddMusicToPlaylist( szTrackName, szHexName, szAlbum, szArtist, szGenre );
}
}
}
示例9: CreateMaterialPatchRecursive
void CreateMaterialPatchRecursive( KeyValues *pOriginalKeyValues, KeyValues *pPatchKeyValues, int nKeys, const MaterialPatchInfo_t *pInfo )
{
int i;
for( i = 0; i < nKeys; i++ )
{
const char *pVal = pOriginalKeyValues->GetString( pInfo[i].m_pKey, NULL );
if( !pVal )
continue;
if( pInfo[i].m_pRequiredOriginalValue && Q_stricmp( pVal, pInfo[i].m_pRequiredOriginalValue ) != 0 )
continue;
pPatchKeyValues->SetString( pInfo[i].m_pKey, pInfo[i].m_pValue );
}
KeyValues *pScan;
for( pScan = pOriginalKeyValues->GetFirstTrueSubKey(); pScan; pScan = pScan->GetNextTrueSubKey() )
{
CreateMaterialPatchRecursive( pScan, pPatchKeyValues->FindKey( pScan->GetName(), true ), nKeys, pInfo );
}
}
示例10: ReadCheatCommandsFromFile
void ReadCheatCommandsFromFile( char *pchFileName )
{
KeyValues *pCheatCodeKeys = new KeyValues( "cheat_codes" );
pCheatCodeKeys->LoadFromFile( g_pFullFileSystem, pchFileName, NULL );
KeyValues *pKey = NULL;
for ( pKey = pCheatCodeKeys->GetFirstTrueSubKey(); pKey; pKey = pKey->GetNextTrueSubKey() )
{
int iCheat = s_CheatCodeCommands.AddToTail();
CheatCodeData_t *pNewCheatCode = &(s_CheatCodeCommands[ iCheat ]);
Q_strncpy( pNewCheatCode->szName, pKey->GetName(), CHEAT_NAME_MAX_LEN ); // Get the name
pNewCheatCode->bDevOnly = ( pKey->GetInt( "dev", 0 ) != 0 ); // Get developer only flag
pNewCheatCode->iCodeLength = 0; // Start at zero code elements
Q_strncpy( pNewCheatCode->szCommand, pKey->GetString( "command", "echo \"Cheat code has no command!\"" ), CHEAT_COMMAND_MAX_LEN );
KeyValues *pSubKey = NULL;
for ( pSubKey = pKey->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() )
{
const char *pchType = pSubKey->GetName();
if ( Q_strcmp( pchType, "code" ) == 0 )
{
AssertMsg( ( pNewCheatCode->iCodeLength < CHEAT_NAME_MAX_LEN ), "Cheat code elements exceeded max!" );
pNewCheatCode->pButtonCodes[ pNewCheatCode->iCodeLength ] = g_pInputSystem->StringToButtonCode( pSubKey->GetString() );
++pNewCheatCode->iCodeLength;
}
}
if ( pNewCheatCode->iCodeLength < CHEAT_NAME_MAX_LEN )
{
// If it's activation is a subsequence of another cheat, the longer cheat can't be activated!
DevWarning( "Cheat code \"%s\" has less than %i code elements!", pKey->GetName(), CHEAT_NAME_MAX_LEN );
}
}
}
示例11: PopulateControls
//.........这里部分代码省略.........
// 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 );
scenariolist->SetNumberOfEditLines( 10 );
scenariolist->GetMenu()->ForceCalculateWidth();
scenariolist->ActivateItemByRow( 0 );
}
// Populate the bot difficulty list
ComboBox *botdifflist = dynamic_cast<ComboBox*>( FindChildByName("BotLevel") );
if ( botdifflist && botdifflist->GetItemCount() == 0 )
{
// Hard coded items (sorry!)
botdifflist->AddItem( "#BOT_LEVEL_EASY", new KeyValues("1") );
botdifflist->AddItem( "#BOT_LEVEL_MED", new KeyValues("3") );
botdifflist->AddItem( "#BOT_LEVEL_HARD", new KeyValues("6") );
botdifflist->AddItem( "#BOT_LEVEL_UBER", new KeyValues("9") );
// Admin
botdifflist->SetEditable( false );
botdifflist->SetNumberOfEditLines( 4 );
botdifflist->GetMenu()->ForceCalculateWidth();
botdifflist->ActivateItemByRow( 0 );
}
// Populate the turbo mode list
ComboBox *turbolist = dynamic_cast<ComboBox*>( FindChildByName("TurboMode") );
if ( turbolist && turbolist->GetItemCount() == 0 )
{
// Hard coded items (sorry!)
turbolist->AddItem( "#TURBO_MODE_NORM", new KeyValues("1.000000") );
turbolist->AddItem( "#TURBO_MODE_FAST", new KeyValues("1.500000") );
turbolist->AddItem( "#TURBO_MODE_LIGHT", new KeyValues("1.850000") );
// Admin
turbolist->SetEditable( false );
turbolist->SetNumberOfEditLines( 3 );
turbolist->GetMenu()->ForceCalculateWidth();
turbolist->ActivateItemByRow( 0 );
}
// Load the default/saved values from our command map
for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
{
// Get our value (or default)
const char *value = (m_kvCmdValues->FindKey( kv->GetName() )) ? m_kvCmdValues->GetString( kv->GetName() ) : NULL;
if ( !value )
value = kv->GetString( "default", "" );
if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
{
ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
// Search through all our items to find a matching value
for ( int i=0; i < panel->GetItemCount(); i++ )
{
int id = panel->GetItemIDFromRow( i );
KeyValues* userdata = panel->GetItemUserData( id );
if ( userdata && !Q_stricmp(value, userdata->GetName()) )
{
panel->ActivateItem( id );
break;
}
}
}
else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
{
TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
panel->SetText( value );
}
else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
{
CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
if ( !Q_stricmp(value, "1") )
panel->SetSelected( true );
else
panel->SetSelected( false );
}
}
m_bFirstLoad = false;
}
示例12: OnCommand
void CGECreateServer::OnCommand( const char *command )
{
if ( !Q_stricmp(command, "play") )
{
CUtlVector<char*> commands;
// Pull the values from our controls and apply them to commands and save off the choices
for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
{
KeyValues *kv_value = m_kvCmdValues->FindKey( kv->GetName(), true );
char *cmd = new char[128];
try {
if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
{
ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );
const char *cmd_value = panel->GetActiveItemUserData()->GetName();
kv_value->SetStringValue( cmd_value );
if ( !Q_stricmp(cmd_value, RANDOM_VALUE) )
{
int idx = GERandom<int>( panel->GetItemCount()-1 ) + 1;
idx = panel->GetItemIDFromRow( idx );
cmd_value = panel->GetItemUserData( idx )->GetName();
}
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
commands.AddToTail( cmd );
}
else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
{
char cmd_value[64];
TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
panel->GetText( cmd_value, 64 );
// We don't allow blank values... use default instead
if ( !cmd_value[0] )
Q_strncpy( cmd_value, kv->GetString("default",""), 64 );
kv_value->SetStringValue( cmd_value );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
commands.AddToTail( cmd );
}
else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
{
CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
if ( panel->IsSelected() ) {
kv_value->SetStringValue( "1" );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("on_val","1") );
} else {
kv_value->SetStringValue( "0" );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("off_val","0") );
}
commands.AddToTail( cmd );
}
else
{
delete [] cmd;
}
} catch (...) {
delete [] cmd;
}
}
// Apply the commands
for ( int i=0; i < commands.Count(); i++ )
engine->ClientCmd_Unrestricted( commands[i] );
// Save our last used settings to our custom file
m_kvCmdValues->SaveToFile( filesystem, COMMAND_MAP_VAL, "MOD" );
// Cleanup
commands.PurgeAndDeleteElements();
}
SetVisible( false );
}
示例13: ReadSaveData
//=========================================================
//=========================================================
bool C_GameInstructor::ReadSaveData()
{
// for external playtests, don't ever read in persisted instructor state, always start fresh
if ( CommandLine()->FindParm( "-playtest" ) )
return true;
if ( m_bHasLoadedSaveData )
return true;
// Always reset state first in case storage device
// was declined or ends up in faulty state
ResetDisplaysAndSuccesses();
m_bHasLoadedSaveData = true;
#ifdef _X360
DevMsg( "Read Game Instructor for splitscreen slot %d\n", m_nSplitScreenSlot );
if ( m_nSplitScreenSlot < 0 )
return false;
if ( m_nSplitScreenSlot >= (int) XBX_GetNumGameUsers() )
return false;
int iController = XBX_GetUserId( m_nSplitScreenSlot );
if ( iController < 0 || XBX_GetUserIsGuest( iController ) )
{
// Can't read data for guests
return false;
}
DWORD nStorageDevice = XBX_GetStorageDeviceId( iController );
if ( !XBX_DescribeStorageDevice( nStorageDevice ) )
return false;
#endif
char szFilename[_MAX_PATH];
#ifdef _X360
if ( IsX360() )
{
XBX_MakeStorageContainerRoot( iController, XBX_USER_SETTINGS_CONTAINER_DRIVE, szFilename, sizeof( szFilename ) );
int nLen = strlen( szFilename );
Q_snprintf( szFilename + nLen, sizeof( szFilename ) - nLen, ":\\game_instructor_counts.txt" );
}
else
#endif
{
Q_snprintf( szFilename, sizeof( szFilename ), "save/game_instructor_counts.txt" );
}
KeyValues *data = new KeyValues( "Game Instructor Counts" );
KeyValues::AutoDelete autoDelete(data);
if ( data->LoadFromFile( g_pFullFileSystem, szFilename, NULL ) )
{
int nVersion = 0;
for ( KeyValues *pKey = data->GetFirstSubKey(); pKey; pKey = pKey->GetNextTrueSubKey() )
{
CBaseLesson *pLesson = GetLesson_Internal( pKey->GetName() );
if ( pLesson )
{
pLesson->SetDisplayCount( pKey->GetInt( "display", 0 ) );
pLesson->SetSuccessCount( pKey->GetInt( "success", 0 ) );
if ( Q_strcmp( pKey->GetName(), "version number" ) == 0 )
{
nVersion = pLesson->GetSuccessCount();
}
}
}
CBaseLesson *pLessonVersionNumber = GetLesson_Internal( "version number" );
if ( pLessonVersionNumber && !pLessonVersionNumber->IsLearned() )
{
ResetDisplaysAndSuccesses();
pLessonVersionNumber->SetSuccessCount( pLessonVersionNumber->GetSuccessLimit() );
m_bDirtySaveData = true;
}
return true;
}
// Couldn't read from the file
return false;
}
示例14: MaterialVectorKeyValue
static bool MaterialVectorKeyValue( KeyValues *pKeyValues, const char *pKeyName, int nDefaultDim, float *pDefault, int *pDim, float *pVector )
{
int nDim;
float retVal[4];
KeyValues *pValue = pKeyValues->FindKey( pKeyName );
if ( pValue )
{
switch( pValue->GetDataType() )
{
case KeyValues::TYPE_INT:
{
int nInt = pValue->GetInt();
for ( int i = 0; i < 4; ++i )
{
retVal[i] = nInt;
}
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDefaultDim, retVal ) )
{
*pDim = nDefaultDim;
memcpy( pVector, retVal, nDefaultDim * sizeof(float) );
return true;
}
}
break;
case KeyValues::TYPE_FLOAT:
{
float flFloat = pValue->GetFloat();
for ( int i = 0; i < 4; ++i )
{
retVal[i] = flFloat;
}
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDefaultDim, retVal ) )
{
*pDim = nDefaultDim;
memcpy( pVector, retVal, nDefaultDim * sizeof(float) );
return true;
}
}
break;
case KeyValues::TYPE_STRING:
{
nDim = ParseVectorFromKeyValueString( pValue, "", retVal );
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDim, retVal ) )
{
*pDim = nDim;
memcpy( pVector, retVal, nDim * sizeof(float) );
return true;
}
}
break;
}
}
for( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
if ( MaterialVectorKeyValue( pSubKey, pKeyName, nDefaultDim, pDefault, &nDim, retVal ) )
{
*pDim = nDim;
memcpy( pVector, retVal, nDim * sizeof(float) );
return true;
}
}
*pDim = nDefaultDim;
memcpy( pVector, pDefault, nDefaultDim * sizeof(float) );
return false;
}
示例15: LoadWeapons
void CWeapons::LoadWeapons(const char *szWeaponListName, WeaponsData_t *pDefault)
{
if ((szWeaponListName != NULL) && (szWeaponListName[0] != 0))
{
KeyValues *kv = new KeyValues("Weapons");
char szFilename[1024];
CBotGlobals::BuildFileName(szFilename, "weapons", BOT_CONFIG_FOLDER, "ini", false);
if (kv)
{
if (kv->LoadFromFile(filesystem, szFilename, NULL))
{
kv = kv->FindKey(szWeaponListName);
if (kv)
{
kv = kv->GetFirstSubKey();
if (0)
kv = kv->GetFirstTrueSubKey();
while (kv != NULL)
{
WeaponsData_t newWeapon;
memset(&newWeapon, 0, sizeof(WeaponsData_t));
const char *szKeyName = kv->GetName();
char lowered[64];
strncpy(lowered, szKeyName, 63);
lowered[63] = 0;
__strlow(lowered);
newWeapon.szWeaponName = CStrings::GetString(lowered);
newWeapon.iId = kv->GetInt("id");
newWeapon.iSlot = kv->GetInt("slot");
newWeapon.minPrimDist = kv->GetFloat("minPrimDist");
newWeapon.maxPrimDist = kv->GetFloat("maxPrimDist");
newWeapon.m_fProjSpeed = kv->GetFloat("m_fProjSpeed");
newWeapon.m_iAmmoIndex = kv->GetInt("m_iAmmoIndex");
newWeapon.m_iPreference = kv->GetInt("m_iPreference");
KeyValues *flags = kv->FindKey("flags");
if (flags)
{
int i = 0;
while (szWeaponFlags[i][0] != '\0')
{
if (flags->FindKey(szWeaponFlags[i]) && (flags->GetInt(szWeaponFlags[i]) == 1))
newWeapon.m_iFlags |= (1 << i);
i++;
}
}
AddWeapon(new CWeapon(&newWeapon));
kv = kv->GetNextTrueSubKey();
}
}
}
kv->deleteThis();
}
}
if (pDefault != NULL)
{
// No weapons from INI file then add default
if (m_theWeapons.size() == 0)
{
while (pDefault->szWeaponName[0] != '\0')
{
AddWeapon(new CWeapon(pDefault));
pDefault++;
}
}
}
}