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


C++ KeyValues::SaveToFile方法代码示例

本文整理汇总了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();
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:28,代码来源:viewangleanim.cpp

示例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;
	}
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:35,代码来源:wars_mount_system.cpp

示例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();
}
开发者ID:Biohazard90,项目名称:source-shader-editor,代码行数:33,代码来源:veditorroot.cpp

示例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);
}
开发者ID:NFMynster,项目名称:DoubleAction,代码行数:28,代码来源:da_menubuttonpanel.cpp

示例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();
}
开发者ID:kirkelifson,项目名称:game,代码行数:33,代码来源:Timer.cpp

示例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;
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:29,代码来源:buildgroup.cpp

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

示例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;
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:49,代码来源:RoomTemplate.cpp

示例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 );
	}
}
开发者ID:BenLubar,项目名称:riflemod,代码行数:48,代码来源:TileGenDialog.cpp

示例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();
}
开发者ID:Randdalf,项目名称:bliink,代码行数:17,代码来源:c_asw_jukebox.cpp

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

示例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();
}
开发者ID:BSVino,项目名称:source-shader-editor,代码行数:49,代码来源:gshaderdumps.cpp

示例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 );
}
开发者ID:ppittle,项目名称:AlienSwarmDirectorMod,代码行数:43,代码来源:tilegen_pages.cpp

示例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;
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:20,代码来源:LevelTheme.cpp

示例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();
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:21,代码来源:tilegen_pages.cpp


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