Пример #1
0
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
0
void CBaseMapsPage::SetListCellColors(MapData *pData, KeyValues *pKvInto)
{
    KeyValues *pCellColor = new KeyValues("cellcolor");
    // KeyValues *pCellBGColor = new KeyValues("cellbgcolor");
    KeyValues *pSub = pCellColor->CreateNewKey();
    pSub->SetName(CFmtStr("%i", HEADER_MAP_NAME));
    pSub->SetColor("color", pData->m_bInLibrary ? COLOR_BLUE : COLOR_WHITE);
    // pCellBGColor->AddSubKey(pSub->MakeCopy());
    pKvInto->AddSubKey(pCellColor);
    // pKvInto->AddSubKey(pCellBGColor);
}
//---------------------------------------------------------------------
// Purpose: Send all properties and contexts to the matchmaking session
//---------------------------------------------------------------------
void CSessionOptionsDialog::SetupSession( void )
{
	KeyValues *pKeys = new KeyValues( "SessionKeys" );

	// Send user-selected properties and contexts
	for ( int i = 0; i < m_Menu.GetItemCount(); ++i )
	{
		COptionsItem *pItem = dynamic_cast< COptionsItem* >( m_Menu.GetItem( i ) );
		if ( !pItem )
		{                    
			continue;
		}		

		const sessionProperty_t &prop = pItem->GetActiveOption();

		KeyValues *pProperty = pKeys->CreateNewKey();
		pProperty->SetName( prop.szID );
		pProperty->SetInt( "type", prop.nType );
		pProperty->SetString( "valuestring", prop.szValue );
		pProperty->SetString( "valuetype", prop.szValueType );
		pProperty->SetInt( "optionindex", pItem->GetActiveOptionIndex() );
	}

	// Send contexts and properties parsed from the resource file
	for ( int i = 0; i < m_SessionProperties.Count(); ++i )
	{
		const sessionProperty_t &prop = m_SessionProperties[i];

		KeyValues *pProperty = pKeys->CreateNewKey();
		pProperty->SetName( prop.szID );
		pProperty->SetInt( "type", prop.nType );
		pProperty->SetString( "valuestring", prop.szValue );
		pProperty->SetString( "valuetype", prop.szValueType );
	}

	// Matchmaking will make a copy of these keys
	matchmaking->SetSessionProperties( pKeys );
	pKeys->deleteThis();
}
Пример #4
0
static void WriteToProgramCache( CGLMShaderPair *pair )
{
	KeyValues *pProgramCache = new KeyValues( "programcache" );
	pProgramCache->LoadFromFile( g_pFullFileSystem, PROGRAM_CACHE_FILE, "MOD" );

	if ( !pProgramCache )
	{
		Warning( "Could not write to program cache file!\n" );
		return;
	}

	// extract values of interest which represent a pair of shaders
	
	char	vprogramName[128];
	int		vprogramStaticIndex = -1;
	int		vprogramDynamicIndex = -1;
	pair->m_vertexProg->GetLabelIndexCombo( vprogramName, sizeof(vprogramName), &vprogramStaticIndex, &vprogramDynamicIndex );

	
	char	pprogramName[128];
	int		pprogramStaticIndex = -1;
	int		pprogramDynamicIndex = -1;
	pair->m_fragmentProg->GetLabelIndexCombo( pprogramName, sizeof(pprogramName), &pprogramStaticIndex, &pprogramDynamicIndex );

	// make up a key - this thing is really a list of tuples, so need not be keyed by anything particular
	KeyValues *pProgramKey = pProgramCache->CreateNewKey();
	Assert( pProgramKey );

	pProgramKey->SetString	( "vs", vprogramName );
	pProgramKey->SetString	( "ps", pprogramName );

	pProgramKey->SetInt		( "vs_static", vprogramStaticIndex );
	pProgramKey->SetInt		( "ps_static", pprogramStaticIndex );

	pProgramKey->SetInt		( "vs_dynamic", vprogramDynamicIndex );
	pProgramKey->SetInt		( "ps_dynamic", pprogramDynamicIndex );

	pProgramCache->SaveToFile( g_pFullFileSystem, PROGRAM_CACHE_FILE, "MOD" );
	pProgramCache->deleteThis();
}