本文整理汇总了C++中KeyValues::AddSubKey方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::AddSubKey方法的具体用法?C++ KeyValues::AddSubKey怎么用?C++ KeyValues::AddSubKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::AddSubKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKeyValuesForEditor
KeyValues* CASW_Location_Group::GetKeyValuesForEditor()
{
char buffer[64];
KeyValues *pKeys = new KeyValues( "Group" );
pKeys->SetInt( "RequiredUnlocks", m_iRequiredUnlocks );
Q_snprintf( buffer, sizeof( buffer ), "%d %d %d %d", m_Color.r(), m_Color.g(), m_Color.b(), m_Color.a() );
pKeys->SetString( "Color", buffer );
pKeys->SetString( "Name", m_szGroupName );
pKeys->SetString( "TitleText", m_szTitleText );
pKeys->SetString( "DescriptionText", m_szDescriptionText );
pKeys->SetString( "ImageName", m_szImageName );
for ( int i = 0; i < m_UnlockedBy.Count(); i++ )
{
KeyValues *pKey = new KeyValues( "UnlockMissionID" );
Q_snprintf( buffer, sizeof( buffer ), "%d", m_UnlockedBy[i] );
pKey->SetStringValue( buffer );
pKeys->AddSubKey( pKey );
}
for ( int i = 0; i < m_Locations.Count(); i++ )
{
KeyValues *pKey = m_Locations[i]->GetKeyValuesForEditor();
pKeys->AddSubKey( pKey );
}
return pKeys;
}
示例2: OnCommand
//-----------------------------------------------------------------------------
// Purpose: handles button commands
//-----------------------------------------------------------------------------
void InputDialog::OnCommand(const char *command)
{
if (!stricmp(command, "OK"))
{
int nTextLength = m_pInput->GetTextLength() + 1;
char* txt = (char*)_alloca( nTextLength * sizeof(char) );
m_pInput->GetText( txt, nTextLength );
KeyValues *kv = new KeyValues( "InputCompleted", "text", txt );
if ( m_pContextKeyValues )
{
kv->AddSubKey( m_pContextKeyValues );
m_pContextKeyValues = NULL;
}
PostActionSignal( kv );
CloseModal();
}
else if (!stricmp(command, "Cancel"))
{
KeyValues *kv = new KeyValues( "InputCanceled" );
if ( m_pContextKeyValues )
{
kv->AddSubKey( m_pContextKeyValues );
m_pContextKeyValues = NULL;
}
PostActionSignal( kv );
CloseModal();
}
else
{
BaseClass::OnCommand(command);
}
}
示例3: KeyValues
KeyValues *InstantiateRule( const CTilegenMissionPreprocessor *pPreprocessor, const char *pRuleName )
{
const CTilegenRule *pRule = pPreprocessor->FindRule( pRuleName );
if ( pRule != NULL )
{
KeyValues *pNewKV = new KeyValues( "rule_instance", "name", pRuleName );
for ( int i = 0; i < pRule->GetParameterCount(); ++ i )
{
if ( !pRule->IsParameterOptional( i ) )
{
const KeyValues *pDefaultValue = pRule->GetDefaultValue( i );
KeyValues *pRuleInstanceParameter = new KeyValues( pRule->GetParameterName( i ) );
if ( pDefaultValue != NULL )
{
pRuleInstanceParameter->AddSubKey( pDefaultValue->MakeCopy() );
}
else
{
pRuleInstanceParameter->SetString( NULL, "<Enter Value>" );
}
pNewKV->AddSubKey( pRuleInstanceParameter );
}
}
return pNewKV;
}
return NULL;
}
示例4: SaveRoomTemplate
bool CRoomTemplate::SaveRoomTemplate()
{
if (!m_pLevelTheme)
return false;
char szThemeDirName[MAX_PATH];
Q_snprintf(szThemeDirName, sizeof(szThemeDirName), "tilegen/roomtemplates/%s", m_pLevelTheme->m_szName);
g_pFullFileSystem->CreateDirHierarchy( szThemeDirName, "GAME" );
char szFullFileName[MAX_PATH];
Q_snprintf( szFullFileName, sizeof(szFullFileName), "tilegen/roomtemplates/%s/%s.roomtemplate", m_pLevelTheme->m_szName, m_FullName );
KeyValues *pRoomTemplateKeyValues = new KeyValues( m_FullName );
pRoomTemplateKeyValues->SetInt( "TilesX", m_nTilesX );
pRoomTemplateKeyValues->SetInt( "TilesY", m_nTilesY );
pRoomTemplateKeyValues->SetInt( "SpawnWeight", m_nSpawnWeight );
pRoomTemplateKeyValues->SetString( "RoomTemplateDescription", m_Description );
pRoomTemplateKeyValues->SetString( "Soundscape", m_Soundscape );
pRoomTemplateKeyValues->SetInt( "TileType", m_nTileType );
// exits
int iExits = m_Exits.Count();
for (int i=0; i<iExits; i++)
{
KeyValues *pkvSubSection = new KeyValues("EXIT");
pkvSubSection->SetInt("XPos", m_Exits[i]->m_iXPos);
pkvSubSection->SetInt("YPos", m_Exits[i]->m_iYPos);
pkvSubSection->SetInt("ExitDirection", (int) m_Exits[i]->m_ExitDirection);
pkvSubSection->SetInt("ZChange", m_Exits[i]->m_iZChange);
pkvSubSection->SetString("ExitTag", m_Exits[i]->m_szExitTag);
pkvSubSection->SetBool("ChokeGrow", m_Exits[i]->m_bChokepointGrowSource);
pRoomTemplateKeyValues->AddSubKey(pkvSubSection);
}
// tags
KeyValues *pkvSubSection = new KeyValues("Tags");
for ( int i=0; i<GetNumTags(); i++ )
{
pkvSubSection->AddSubKey( new KeyValues( "tag", NULL, GetTag( i ) ) );
}
pRoomTemplateKeyValues->AddSubKey(pkvSubSection);
if (!pRoomTemplateKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName, "GAME"))
{
Msg("Error: Failed to save room template %s\n", szFullFileName);
return false;
}
return true;
}
示例5: KeyValues
/*
char *name;
bool bStatic;
int min;
int max;
*/
KeyValues *__AllocKV_Identifiers( IdentifierLists_t *pList )
{
KeyValues *pIdents = new KeyValues("");
for ( int i = 0; i < pList->hList_Combos.Count(); i++ )
pIdents->AddSubKey( __AllocKV_Combo( i, pList->hList_Combos[i] ) );
for ( int i = 0; i < pList->hList_EConstants.Count(); i++ )
pIdents->AddSubKey( __AllocKV_EConst( i, pList->hList_EConstants[i] ) );
for ( int i = 0; i < pList->hList_Textures.Count(); i++ )
pIdents->AddSubKey( __AllocKV_Texture( i, pList->hList_Textures[i] ) );
pIdents->SetInt( "i_numdcombos", pList->inum_DynamicCombos );
return pIdents;
}
示例6: SaveTime
//Called every time a new time is achieved
void CTimer::SaveTime()
{
const char *szMapName = gpGlobals->mapname.ToCStr();
KeyValues *timesKV = new KeyValues(szMapName);
int count = localTimes.Count();
for (int i = 0; i < count; i++)
{
Time t = localTimes[i];
char timeName[512];
Q_snprintf(timeName, 512, "%i", t.ticks);
KeyValues *pSubkey = new KeyValues(timeName);
pSubkey->SetFloat("rate", t.tickrate);
pSubkey->SetInt("date", t.date);
timesKV->AddSubKey(pSubkey);
}
char file[MAX_PATH];
Q_strcpy(file, c_mapDir);
Q_strcat(file, szMapName, MAX_PATH);
Q_strncat(file, c_timesExt, MAX_PATH);
if (timesKV->SaveToFile(filesystem, file, "MOD", true))
{
Log("Successfully saved new time!\n");
IGameEvent *savedEvent = gameeventmanager->CreateEvent("runtime_saved");
if (savedEvent)
gameeventmanager->FireEvent(savedEvent);
}
timesKV->deleteThis();
}
示例7: DeleteSelection
//-----------------------------------------------------------------------------
// Purpose: Delete selected entities/props.
//-----------------------------------------------------------------------------
void CEditorSystem::DeleteSelection()
{
if( !IsAnythingSelected() )
return;
KeyValues *pOperation = new KeyValues( "data" );
pOperation->SetString("operation", "deleteflora");
for( int i = 0; i < m_hSelectedEntities.Count(); i++ )
{
if( !m_hSelectedEntities[i] )
continue;
CWarsFlora *pFlora = dynamic_cast<CWarsFlora *>( m_hSelectedEntities[i].Get() );
if( pFlora )
{
pOperation->AddSubKey( new KeyValues( "flora", "uuid", pFlora->GetFloraUUID() ) );
pFlora->Remove();
}
else
{
m_hSelectedEntities[i]->Remove();
}
}
m_hSelectedEntities.Purge();
warseditorstorage->QueueClientCommand( pOperation );
}
示例8: OnCommand
//-----------------------------------------------------------------------------
// Process commands
//-----------------------------------------------------------------------------
void CSaveDocumentQuery::OnCommand( char const *cmd )
{
if ( !Q_stricmp( cmd, "yes" ) )
{
KeyValues *kv = new KeyValues( "OnSaveFile" );
kv->SetString( "filename", m_szFileName );
kv->SetString( "filetype", m_szFileType );
kv->SetInt( "context", m_nContext );
kv->SetPtr( "actionTarget", m_pActionSignalTarget );
if ( m_pPostSaveKeyValues )
{
kv->AddSubKey( m_pPostSaveKeyValues->MakeCopy() );
}
vgui::ivgui()->PostMessage( m_pActionSignalTarget->GetVPanel(), kv, 0 );
MarkForDeletion();
}
else if ( !Q_stricmp( cmd, "no" ) )
{
PostCommand( "OnMarkNotDirty" );
if ( m_pPostSaveKeyValues )
{
vgui::ivgui()->PostMessage( m_pActionSignalTarget->GetVPanel(), m_pPostSaveKeyValues->MakeCopy(), 0 );
}
MarkForDeletion();
}
else if ( !Q_stricmp( cmd, "cancel" ) )
{
PostCommand( "OnCancelSaveDocument" );
MarkForDeletion();
}
else
{
BaseClass::OnCommand( cmd );
}
}
示例9: OnCommand
//-----------------------------------------------------------------------------
// On command
//-----------------------------------------------------------------------------
void CDmeLogEditFrame::OnCommand( const char *pCommand )
{
if ( !Q_stricmp( pCommand, "Ok" ) )
{
KeyValues *pActionKeys = new KeyValues( "LogEdited" );
if ( m_pContextKeyValues )
{
pActionKeys->AddSubKey( m_pContextKeyValues );
// This prevents them from being deleted later
m_pContextKeyValues = NULL;
}
PostActionSignal( pActionKeys );
CloseModal();
return;
}
if ( !Q_stricmp( pCommand, "Cancel" ) )
{
CloseModal();
return;
}
BaseClass::OnCommand( pCommand );
}
示例10: AddFolder
void CRoomTemplateListPanel::AddFolder( const char *pFolderName )
{
int nNumFolders = m_RoomTemplateFolders.Count();
for ( int i = 0; i < nNumFolders; ++ i )
{
if ( Q_stricmp( pFolderName, m_RoomTemplateFolders[i].m_FolderName ) == 0 )
{
// Mark this folder as being used
m_RoomTemplateFolders[i].m_pFolderButton->SetVisible( true );
return;
}
}
// New folder, create a new entry
m_RoomTemplateFolders.AddToTail();
Q_strncpy( m_RoomTemplateFolders[nNumFolders].m_FolderName, pFolderName, MAX_PATH );
m_RoomTemplateFolders[nNumFolders].m_bExpanded = true;
m_RoomTemplateFolders[nNumFolders].m_pFolderButton = new Button( this, "FolderButton", "", this, "ToggleFolder" );
KeyValues *pMessageKV = new KeyValues( "ToggleFolder" );
KeyValues *pIndexKV = new KeyValues( "folder" );
pIndexKV->SetString( NULL, m_RoomTemplateFolders[nNumFolders].m_FolderName );
pMessageKV->AddSubKey( pIndexKV );
m_RoomTemplateFolders[nNumFolders].m_pFolderButton->SetCommand( pMessageKV );
}
示例11: LoadControlSettings
// Load the control settings
void CBaseModFrame::LoadControlSettings( const char *dialogResourceName, const char *pathID, KeyValues *pPreloadedKeyValues, KeyValues *pConditions )
{
// Use the keyvalues they passed in or load them using special hook for flyouts generation
KeyValues *rDat = pPreloadedKeyValues;
if ( !rDat )
{
// load the resource data from the file
rDat = new KeyValues(dialogResourceName);
// check the skins directory first, if an explicit pathID hasn't been set
bool bSuccess = false;
if ( !IsX360() && !pathID )
{
bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, "SKIN" );
}
if ( !bSuccess )
{
bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, pathID );
}
if ( bSuccess )
{
if ( IsX360() )
{
rDat->ProcessResolutionKeys( surface()->GetResolutionKey() );
}
if ( pConditions && pConditions->GetFirstSubKey() )
{
GetBuildGroup()->ProcessConditionalKeys( rDat, pConditions );
}
}
}
// Find the auto-generated-chapter hook
if ( KeyValues *pHook = rDat->FindKey( "FlmChapterXXautogenerated" ) )
{
const int numMaxAutogeneratedFlyouts = 20;
for ( int k = 1; k <= numMaxAutogeneratedFlyouts; ++ k )
{
KeyValues *pFlyoutInfo = pHook->MakeCopy();
CFmtStr strName( "FlmChapter%d", k );
pFlyoutInfo->SetName( strName );
pFlyoutInfo->SetString( "fieldName", strName );
pFlyoutInfo->SetString( "ResourceFile", CFmtStr( "FlmChapterXXautogenerated_%d/%s", k, pHook->GetString( "ResourceFile" ) ) );
rDat->AddSubKey( pFlyoutInfo );
}
rDat->RemoveSubKey( pHook );
pHook->deleteThis();
}
BaseClass::LoadControlSettings( dialogResourceName, pathID, rDat, pConditions );
if ( rDat != pPreloadedKeyValues )
{
rDat->deleteThis();
}
}
示例12: df_SaveDump_File
/*
CUtlVector< SimpleTexture* > hList_Textures;
CUtlVector< SimpleCombo* > hList_Combos;
CUtlVector< SimpleEnvConstant* > hList_EConstants;
*/
void df_SaveDump_File( const char *canvasname, const BasicShaderCfg_t &shader )
{
KeyValues *pKV = new KeyValues( canvasname );
char _path[MAX_PATH];
Q_snprintf( _path, MAX_PATH, "%s/%s.dump", ::GetDumpDirectory(), canvasname );
Q_FixSlashes( _path );
pKV->SetString( "vs_name", shader.ProcVSName );
pKV->SetString( "ps_name", shader.ProcPSName );
pKV->SetString( "shader_filename", shader.Filename );
pKV->SetString( GetDumpVersion_KeyName(), GetDumpVersion_Current() );
pKV->SetInt( "i_sm", shader.iShaderModel );
pKV->SetInt( "i_cull", shader.iCullmode );
pKV->SetInt( "i_ablend", shader.iAlphablendmode );
pKV->SetFloat( "fl_atestref", shader.flAlphaTestRef );
pKV->SetInt( "i_dtest", shader.iDepthtestmode );
pKV->SetInt( "i_dwrite", shader.iDepthwritemode );
pKV->SetInt( "i_srgbw", shader.bsRGBWrite ? 1 : 0 );
pKV->SetInt( "i_vfmt_flags", shader.iVFMT_flags );
pKV->SetInt( "i_vfmt_texcoords", shader.iVFMT_numTexcoords );
pKV->SetInt( "i_vfmt_udata", shader.iVFMT_numUserData );
for ( int i = 0; i < 3; i++ )
{
char tmp[48];
Q_snprintf( tmp, sizeof(tmp), "i_vfmt_texcoordDim_%i", i );
pKV->SetInt( tmp, shader.iVFMT_texDim[i] );
}
pKV->SetInt( "i_vlit", shader.bVertexLighting );
pKV->SetInt( "i_vrefract", shader.bRefractionSupport );
KeyValues *pKVIdentVS = __AllocKV_Identifiers( shader.pVS_Identifiers );
pKVIdentVS->SetName( "identifiers_VS" );
pKV->AddSubKey( pKVIdentVS );
KeyValues *pKVIdentPS = __AllocKV_Identifiers( shader.pPS_Identifiers );
pKVIdentPS->SetName( "identifiers_PS" );
pKV->AddSubKey( pKVIdentPS );
pKV->SaveToFile( g_pFullFileSystem, _path, "MOD" );
pKV->deleteThis();
}
示例13: UTIL_IncrementMapKey
void UTIL_IncrementMapKey( const char *pszCustomKey )
{
if ( !pszCustomKey )
return;
char szFilename[ _MAX_PATH ];
if ( !UTIL_GetMapLoadCountFileName( MAP_KEY_FILE, szFilename, _MAX_PATH ) )
return;
int iCount = 1;
KeyValues *kvMapLoadFile = new KeyValues( MAP_KEY_FILE );
if ( kvMapLoadFile )
{
kvMapLoadFile->LoadFromFile( g_pFullFileSystem, szFilename, "MOD" );
char mapname[MAX_MAP_NAME];
Q_FileBase( engine->GetLevelName(), mapname, sizeof( mapname) );
Q_strlower( mapname );
// Increment existing, or add a new one
KeyValues *pMapKey = kvMapLoadFile->FindKey( mapname );
if ( pMapKey )
{
iCount = pMapKey->GetInt( pszCustomKey, 0 ) + 1;
pMapKey->SetInt( pszCustomKey, iCount );
}
else
{
KeyValues *pNewKey = new KeyValues( mapname );
if ( pNewKey )
{
pNewKey->SetString( pszCustomKey, "1" );
kvMapLoadFile->AddSubKey( pNewKey );
}
}
// Write it out
// force create this directory incase it doesn't exist
filesystem->CreateDirHierarchy( MAP_KEY_FILE_DIR, "MOD");
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
kvMapLoadFile->RecursiveSaveToFile( buf, 0 );
g_pFullFileSystem->WriteFile( szFilename, "MOD", buf );
kvMapLoadFile->deleteThis();
}
if ( IsX360() )
{
#ifdef _X360
xboxsystem->FinishContainerWrites();
#endif
}
}
示例14: GetDefaultCamera
KeyValues* VMFExporter::GetDefaultCamera()
{
KeyValues *pKeys = new KeyValues( "cameras" );
pKeys->SetInt( "activecamera", 0 );
KeyValues *pSubKeys = new KeyValues( "camera" );
pSubKeys->SetString( "position", "[135.491 -60.314 364.02]" );
pSubKeys->SetString( "look", "[141.195 98.7571 151.25]" );
pKeys->AddSubKey( pSubKeys );
return pKeys;
}
示例15: OnRuleDetailsClicked
void CRulePickerDialog::OnRuleDetailsClicked( vgui::Panel *pPanel )
{
CRuleDetailsPanel *pRuleDetails = dynamic_cast< CRuleDetailsPanel * >( pPanel );
Assert( pPanel != NULL );
KeyValues *pNewRuleInstance = InstantiateRule( m_pRulePreprocessor, pRuleDetails->GetRule()->GetName() );
if ( pNewRuleInstance != NULL )
{
KeyValues *pMessage = new KeyValues( "RuleChanged" );
pMessage->AddSubKey( pNewRuleInstance );
PostActionSignal( pMessage );
}
OnClose();
}