本文整理汇总了C++中KeyValues::SaveToFile方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::SaveToFile方法的具体用法?C++ KeyValues::SaveToFile怎么用?C++ KeyValues::SaveToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::SaveToFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveAsAnimFile
void CViewAngleAnimation::SaveAsAnimFile( const char *pKeyFrameFileName )
{
// save all of our keyframes into the file
KeyValues *pData = new KeyValues( pKeyFrameFileName );
pData->SetInt( "flags", m_iFlags );
KeyValues *pKey = new KeyValues( "keyframe" );
int i;
int c = m_KeyFrames.Count();
char buf[64];
for ( i=0;i<c;i++ )
{
pKey = pData->CreateNewKey();
Q_snprintf( buf, sizeof(buf), "%f %f %f",
m_KeyFrames[i]->m_vecAngles[0],
m_KeyFrames[i]->m_vecAngles[1],
m_KeyFrames[i]->m_vecAngles[2] );
pKey->SetString( "angles", buf );
pKey->SetFloat( "time", m_KeyFrames[i]->m_flTime );
pKey->SetInt( "flags", m_KeyFrames[i]->m_iFlags );
}
pData->SaveToFile( filesystem, pKeyFrameFileName, NULL );
pData->deleteThis();
}
示例2: MountExtraContent
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void MountExtraContent()
{
memset(g_AppStatus, 0, sizeof(g_AppStatus));
KeyValues *pMountList = new KeyValues( "MountList" );
if( !pMountList->LoadFromFile( filesystem, "mountlist.txt" ) )
{
// Create default
pMountList->SetString( "dota", "0" );
pMountList->SetString( "left4dead", "0" );
pMountList->SetString( "left4dead2", "0" );
pMountList->SetString( "portal2", "0" );
pMountList->SetString( "csgo", "0" );
pMountList->SetString( "dearesther", "0" );
pMountList->SaveToFile( filesystem, "mountlist.txt", "MOD" );
}
if( TryMountVPKGame( "DOTA", "../../common/dota 2 beta/dota", APP_DOTA, "dota", pMountList ) )
PostProcessDota2( "models" );
TryMountVPKGame( "Portal 2", "../../common/portal 2/portal2", APP_PORTAL2, "portal2", pMountList );
TryMountVPKGame( "Left 4 Dead 2", "../../common/left 4 dead 2/left4dead2", APP_L4D2, "left4dead2", pMountList );
TryMountVPKGame( "Left 4 Dead", "../../common/left 4 dead/left4dead", APP_L4D1, "left4dead", pMountList );
TryMountVPKGame( "Counter-Strike Global Offensive", "../../common/Counter-Strike Global Offensive/csgo", APP_CSGO, "csgo", pMountList );
TryMountVPKGame( "Dear Esther", "../../common/dear esther/dearesther", APP_DEARESTHER, "dearesther", pMountList );
if( pMountList )
{
pMountList->deleteThis();
pMountList = NULL;
}
}
示例3: SaveLayout
void CEditorRoot::SaveLayout()
{
KeyValues *pKV = new KeyValues( "config" );
pKV->SetInt( "preview_visible", (pPreview && pPreview->IsVisible()) );
if ( pPreview )
pPreview->GetBounds( px, py, psx, psy );
pKV->SetInt( "p_x", px );
pKV->SetInt( "p_y", py );
pKV->SetInt( "p_sx", psx );
pKV->SetInt( "p_sy", psy );
pKV->SetInt( "draw_datatypes", m_bDraw_Datatypes ? 1 : 0 );
pKV->SetInt( "draw_shadows", m_bDraw_Shadows ? 1 : 0 );
pKV->SetInt( "draw_all_limits", m_bDraw_AllLimits ? 1 : 0 );
pKV->SetInt( "compile_preview", m_bAutoCompile ? 1 : 0 );
pKV->SetInt( "enable_nodeview_tooltips", m_bDoTooltips ? 1 : 0 );
pKV->SetInt( "compile_always_full", m_bAutoFullcompile ? 1 : 0 );
pKV->SetInt( "compile_auto_publish_to_materials", m_bAutoShaderPublish ? 1 : 0 );
pKV->SetInt( "precache_auto_reload", m_bAutoPrecacheUpdate ? 1 : 0 );
pKV->SetInt( "warn_unsaved_changes", m_bWarnOnClose ? 1 : 0 );
pKV->SetInt( "cedit_x", cedit_x );
pKV->SetInt( "cedit_y", cedit_y );
pKV->SetInt( "cedit_sx", cedit_sx );
pKV->SetInt( "cedit_sy", cedit_sy );
pKV->SaveToFile( filesystem, VarArgs( "%s/shadereditorui/editor_config.txt", engine->GetGameDirectory()), "MOD" );
pKV->deleteThis();
//DeallocPingPongRTs();
}
示例4: OnCommand
void CButtonPanel::OnCommand( const char *command)
{
if (!Q_strcmp(command, "opennews"))
{
CloseAll();
m_pNews->SetNormalImage("news");
m_iLatestNews = time(NULL);
KeyValues *manifest = new KeyValues( "latest_news" );
manifest->SetInt("time", (long)m_iLatestNews);
manifest->SaveToFile( filesystem, "latest_news.txt", "MOD" );
NewsFrame()->ShowPanel(true);
return;
}
if (!Q_strcmp(command, "openleaderboard"))
{
CloseAll();
Leaderboard()->ShowPanel(true);
return;
}
BaseClass::OnCommand(command);
}
示例5: 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();
}
示例6: SaveControlSettings
//-----------------------------------------------------------------------------
// Purpose: saves control settings to file
//-----------------------------------------------------------------------------
bool BuildGroup::SaveControlSettings( void )
{
bool bSuccess = false;
if ( m_pResourceName )
{
KeyValues *rDat = new KeyValues( m_pResourceName );
// get the data from our controls
GetSettings( rDat );
char fullpath[ 512 ];
g_pFullFileSystem->RelativePathToFullPath( m_pResourceName, m_pResourcePathID, fullpath, sizeof( fullpath ) );
// save the data out to a file
bSuccess = rDat->SaveToFile( g_pFullFileSystem, fullpath, NULL );
if (!bSuccess)
{
MessageBox *dlg = new MessageBox("BuildMode - Error saving file", "Error: Could not save changes. File is most likely read only.");
dlg->DoModal();
}
rDat->deleteThis();
}
return bSuccess;
}
示例7: SaveUserConfigFile
//-----------------------------------------------------------------------------
// Purpose: saves all the current settings to the user config file
//-----------------------------------------------------------------------------
void CSystem::SaveUserConfigFile()
{
if (m_pUserConfigData)
{
m_pUserConfigData->SaveToFile(g_pFullFileSystem, m_szFileName, m_szPathID);
}
}
示例8: 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;
}
示例9: GenerateRoomThumbnails
void CTileGenDialog::GenerateRoomThumbnails( bool bAddToPerforce )
{
// save out a keyvalues file with position/size of each room
KeyValues *pKV = new KeyValues( "RoomThumbnails" );
char filename[MAX_PATH];
for ( int i=0;i<m_pMapLayout->m_PlacedRooms.Count();i++ )
{
CRoom *pRoom = m_pMapLayout->m_PlacedRooms[i];
if ( !pRoom )
continue;
KeyValues *pkvEntry = new KeyValues( "Thumbnail" );
Q_snprintf( filename, sizeof( filename ), "tilegen/roomtemplates/%s/%s.tga", pRoom->m_pRoomTemplate->m_pLevelTheme->m_szName,
pRoom->m_pRoomTemplate->GetFullName() );
pkvEntry->SetString( "Filename", filename );
int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f; // shift back so the middle of our grid is the origin
float xPos = (pRoom->m_iPosX - half_map_size) * ASW_TILE_SIZE;
float yPos = (pRoom->m_iPosY - half_map_size) * ASW_TILE_SIZE;
pkvEntry->SetFloat( "RoomX", xPos );
pkvEntry->SetFloat( "RoomY", yPos + pRoom->m_pRoomTemplate->GetTilesY() * ASW_TILE_SIZE );
pkvEntry->SetFloat( "RoomWide", pRoom->m_pRoomTemplate->GetTilesX() * ASW_TILE_SIZE );
pkvEntry->SetFloat( "RoomTall", pRoom->m_pRoomTemplate->GetTilesY() * ASW_TILE_SIZE );
pkvEntry->SetFloat( "OutputWide", pRoom->m_pRoomTemplate->GetTilesX() * RoomTemplatePanelTileSize() );
pkvEntry->SetFloat( "OutputTall", pRoom->m_pRoomTemplate->GetTilesY() * RoomTemplatePanelTileSize() );
pKV->AddSubKey( pkvEntry );
}
if ( !pKV->SaveToFile( g_pFullFileSystem, THUMBNAILS_FILE, "GAME" ) )
{
Msg( "Error: Couldn't save %s\n", THUMBNAILS_FILE );
pKV->deleteThis();
return;
}
pKV->deleteThis();
m_pMapLayout->SaveMapLayout( "maps/output.layout" );
if ( engine )
{
char buffer[256];
Q_snprintf(buffer, sizeof(buffer), "asw_random_weapons 0; asw_building_room_thumbnails 1; asw_add_room_thumbnails_to_perforce %d; asw_build_map %s", bAddToPerforce ? 1 : 0, "output.layout" );
engine->ClientCmd_Unrestricted( buffer );
}
}
示例10: ExportPlayistKV
void CASWJukeboxPlaylist::ExportPlayistKV( void )
{
KeyValues *pPlaylistKV = new KeyValues("playlist");
for( int i=0; i<m_CombatMusicPlaylist.Count(); ++i )
{
KeyValues *pTrackKV = new KeyValues("Track");
pTrackKV->SetString( "TrackName", m_CombatMusicPlaylist[i].m_szFilename );
pTrackKV->SetString( "HexName", m_CombatMusicPlaylist[i].m_szHexname );
pTrackKV->SetString( "Album", m_CombatMusicPlaylist[i].m_szAlbum );
pTrackKV->SetString( "Artist", m_CombatMusicPlaylist[i].m_szArtist);
pTrackKV->SetString( "Genre", m_CombatMusicPlaylist[i].m_szGenre );
pPlaylistKV->AddSubKey( pTrackKV );
}
pPlaylistKV->SaveToFile( filesystem, sz_PlaylistFilename );
pPlaylistKV->deleteThis();
}
示例11: PersistToCache
//--------------------------------------------------------------------------------------------------------------
void DownloadCache::PersistToCache( const RequestContext *rc )
{
if ( !m_cache || !rc || !rc->data || !rc->nBytesTotal || !rc->nBytesCurrent )
return;
char cachePath[_MAX_PATH];
GenerateCacheFilename( rc, cachePath );
FileHandle_t fp = g_pFileSystem->Open( cachePath, "wb" );
if ( fp )
{
g_pFileSystem->Write( rc->data, rc->nBytesCurrent, fp );
g_pFileSystem->Close( fp );
m_cache->SaveToFile( g_pFileSystem, CacheFilename, NULL );
}
}
示例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: OnCommand
void CTilegenKVEditorPage::OnCommand( const char *command )
{
if ( !Q_stricmp( command, "Save" ) )
{
KeyValues *pKV = GetKeyValues();
char fullFilePathBuffer [512];
Q_snprintf(fullFilePathBuffer, sizeof(fullFilePathBuffer),"C:\\Program Files\\Steam\\steamapps\\sourcemods\\alienswarmdirectormod\\%s", m_szFilename);
Msg("Saving to [%s]", fullFilePathBuffer);
//if ( pKV != NULL && !pKV->SaveToFile( g_pFullFileSystem, m_szFilename, "GAME" ) )
if ( pKV != NULL && !pKV->SaveToFile( g_pFullFileSystem, fullFilePathBuffer ) )
{
if ( p4 )
{
char fullPath[MAX_PATH];
g_pFullFileSystem->RelativePathToFullPath( m_szFilename, "GAME", fullPath, MAX_PATH );
if ( p4->IsFileInPerforce( fullPath ) )
{
MessageBox *pMessage = new MessageBox( "Check Out?", "File is not writeable. Would you like to check it out from Perforce?", this );
pMessage->SetCancelButtonVisible( true );
pMessage->SetOKButtonText( "#MessageBox_Yes" );
pMessage->SetCancelButtonText( "#MessageBox_No" );
pMessage->SetCommand( new KeyValues( "CheckOutFromP4", "file", fullPath ) );
pMessage->DoModal();
return;
}
}
else
{
VGUIMessageBox( this, "Save Error", "Failed to save %s. Make sure file is checked out from Perforce.", m_szFilename );
}
}
UpdateList();
return;
}
else if ( !Q_stricmp( command, "New" ) )
{
SaveNew();
return;
}
BaseClass::OnCommand( command );
}
示例14: SaveTheme
bool CLevelTheme::SaveTheme(const char *pszThemeName)
{
char szFullFileName[MAX_PATH];
Q_snprintf(szFullFileName, sizeof(szFullFileName), "tilegen/themes/%s.theme", pszThemeName);
KeyValues *pThemeKeyValues = new KeyValues( pszThemeName );
pThemeKeyValues->SetString("ThemeName", m_szName);
pThemeKeyValues->SetString("ThemeDescription", m_szDescription);
pThemeKeyValues->SetBool( "VMFTweak", m_bRequiresVMFTweak );
pThemeKeyValues->SetBool( "SkipErrorCheck", m_bSkipErrorCheck );
char buffer[128];
Q_snprintf( buffer, sizeof( buffer ), "%f %f %f", m_vecAmbientLight.x, m_vecAmbientLight.y, m_vecAmbientLight.z );
pThemeKeyValues->SetString( "AmbientLight", buffer );
if (!pThemeKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName, "GAME"))
{
Msg("Error: Failed to save theme %s\n", szFullFileName);
return false;
}
// TODO: check the room templates folder for this theme exists
return true;
}
示例15: GetKeyValues
void CTilegenKVEditorPage::OnCheckOutFromP4( KeyValues *pKV )
{
const char *pPath = pKV->GetString( "file", NULL );
if ( pPath != NULL )
{
if ( p4->OpenFileForEdit( pPath ) )
{
KeyValues *pKV = GetKeyValues();
if ( !pKV->SaveToFile( g_pFullFileSystem, m_szFilename, "GAME" ) )
{
VGUIMessageBox( this, "Save Error!", "Checked out '%s' from Perforce, but failed to save file.", pPath );
}
}
else
{
VGUIMessageBox( this, "P4 Error!", "Failed to check out '%s' from Perforce.", pPath );
}
}
UpdateList();
}