本文整理汇总了C++中KeyValues::SetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::SetFloat方法的具体用法?C++ KeyValues::SetFloat怎么用?C++ KeyValues::SetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::SetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecordSprite
//-----------------------------------------------------------------------------
// Recording
//-----------------------------------------------------------------------------
static inline void RecordSprite( const Vector& start, int nModelIndex,
float flScale, int nBrightness )
{
if ( !ToolsEnabled() )
return;
if ( clienttools->IsInRecordingMode() )
{
const model_t* pModel = (nModelIndex != 0) ? modelinfo->GetModel( nModelIndex ) : NULL;
const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : "";
KeyValues *msg = new KeyValues( "TempEntity" );
msg->SetInt( "te", TE_SPRITE_SINGLE );
msg->SetString( "name", "TE_Sprite" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", start.x );
msg->SetFloat( "originy", start.y );
msg->SetFloat( "originz", start.z );
msg->SetString( "model", pModelName );
msg->SetFloat( "scale", flScale );
msg->SetInt( "brightness", nBrightness );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
示例2: RecordDecal
//-----------------------------------------------------------------------------
// Recording
//-----------------------------------------------------------------------------
static inline void RecordDecal( const Vector &pos, const Vector &start,
int entity, int hitbox, int index )
{
if ( !ToolsEnabled() )
return;
if ( clienttools->IsInRecordingMode() )
{
// FIXME: Can't record on entities yet
if ( entity != 0 )
return;
KeyValues *msg = new KeyValues( "TempEntity" );
msg->SetInt( "te", TE_DECAL );
msg->SetString( "name", "TE_Decal" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", pos.x );
msg->SetFloat( "originy", pos.y );
msg->SetFloat( "originz", pos.z );
msg->SetFloat( "startx", start.x );
msg->SetFloat( "starty", start.y );
msg->SetFloat( "startz", start.z );
msg->SetInt( "hitbox", hitbox );
msg->SetString( "decalname", effects->Draw_DecalNameFromIndex( index ) );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
示例3: OnMouseWheeled
void InventoryItem::OnMouseWheeled(int delta)
{
bool bScrollingUp = (delta > 0);
if (!m_bWantsToRotate)
{
m_flOriginX += (bScrollingUp ? -1 : 1);
KeyValues *pkvChar = GameBaseClient->GetInventoryItemDetails(GameBaseClient->pszInventoryList[GetControlID()].inventoryItem);
if (pkvChar)
{
KeyValues *pkvModelField = pkvChar->FindKey("ModelData");
if (pkvModelField)
{
KeyValues *pkvModel = pkvModelField->FindKey("Model");
if (pkvModel)
{
pkvModel->SetFloat("origin_x", m_flOriginX);
pkvModel->SetFloat("angles_y", m_flAngleY);
m_pModelPreview->ParseModelInfo(pkvModel);
}
}
pkvChar->deleteThis();
}
}
BaseClass::OnMouseWheeled(delta);
}
示例4: RecordSparks
//-----------------------------------------------------------------------------
// Recording
//-----------------------------------------------------------------------------
static inline void RecordSparks( const Vector &start, int nMagnitude, int nTrailLength, const Vector &direction )
{
if ( !ToolsEnabled() )
return;
if ( clienttools->IsInRecordingMode() )
{
KeyValues *msg = new KeyValues( "TempEntity" );
msg->SetInt( "te", TE_SPARKS );
msg->SetString( "name", "TE_Sparks" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", start.x );
msg->SetFloat( "originy", start.y );
msg->SetFloat( "originz", start.z );
msg->SetFloat( "directionx", direction.x );
msg->SetFloat( "directiony", direction.y );
msg->SetFloat( "directionz", direction.z );
msg->SetInt( "magnitude", nMagnitude );
msg->SetInt( "traillength", nTrailLength );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
示例5: clr
//-----------------------------------------------------------------------------
// Recording
//-----------------------------------------------------------------------------
static inline void RecordBloodSprite( const Vector &start, const Vector &direction,
int r, int g, int b, int a, int nSprayModelIndex, int nDropModelIndex, int size )
{
if ( !ToolsEnabled() )
return;
if ( clienttools->IsInRecordingMode() )
{
Color clr( r, g, b, a );
const model_t* pSprayModel = (nSprayModelIndex != 0) ? modelinfo->GetModel( nSprayModelIndex ) : NULL;
const model_t* pDropModel = (nDropModelIndex != 0) ? modelinfo->GetModel( nDropModelIndex ) : NULL;
const char *pSprayModelName = pSprayModel ? modelinfo->GetModelName( pSprayModel ) : "";
const char *pDropModelName = pDropModel ? modelinfo->GetModelName( pDropModel ) : "";
KeyValues *msg = new KeyValues( "TempEntity" );
msg->SetInt( "te", TE_BLOOD_SPRITE );
msg->SetString( "name", "TE_BloodSprite" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", start.x );
msg->SetFloat( "originy", start.y );
msg->SetFloat( "originz", start.z );
msg->SetFloat( "directionx", direction.x );
msg->SetFloat( "directiony", direction.y );
msg->SetFloat( "directionz", direction.z );
msg->SetColor( "color", clr );
msg->SetString( "spraymodel", pSprayModelName );
msg->SetString( "dropmodel", pDropModelName );
msg->SetInt( "size", size );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
示例6:
KeyValues *CBaseContainerNode::AllocateKeyValues( int NodeIndex )
{
KeyValues *pKV = BaseClass::AllocateKeyValues( NodeIndex );
pKV->SetFloat( "container_extents_x", m_vecContainerExtents.x );
pKV->SetFloat( "container_extents_y", m_vecContainerExtents.y );
pKV->SetFloat( "container_extents_z", m_vecContainerExtents.z );
return pKV;
}
示例7: OnThink
void InventoryItem::OnThink()
{
BaseClass::OnThink();
// If we want to rotate then we'll keep track of the users movement with the mouse (coords) in order to update the position.
if (m_bWantsToRotate)
{
// When the cursor goes out of our control bounds then OnMouseReleased will no longer record the mouse input, which means we need to use this function:
if (!g_pInputSystem->IsButtonDown(MOUSE_RIGHT))
{
m_bWantsToRotate = false;
return;
}
int x, y;
vgui::input()->GetCursorPos(x, y);
if (x != m_iOriginalCursorXPos)
{
int iDiff = x - m_iOriginalCursorXPos;
m_flAngleY += iDiff;
// Clamp the angle between 0 - 360 degrees.
if (m_flAngleY > 360)
m_flAngleY = 0;
else if (m_flAngleY < 0)
m_flAngleY = 360;
KeyValues *pkvChar = GameBaseClient->GetInventoryItemDetails(GameBaseClient->pszInventoryList[GetControlID()].inventoryItem);
if (pkvChar)
{
KeyValues *pkvModelField = pkvChar->FindKey("ModelData");
if (pkvModelField)
{
KeyValues *pkvModel = pkvModelField->FindKey("Model");
if (pkvModel)
{
pkvModel->SetFloat("origin_x", m_flOriginX);
pkvModel->SetFloat("angles_y", m_flAngleY);
m_pModelPreview->ParseModelInfo(pkvModel);
}
}
pkvChar->deleteThis();
}
m_iOriginalCursorXPos = x;
}
}
}
示例8: 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 );
}
}
示例9: Update
//================================================================================
// Pensamiento
//================================================================================
void CInternalLight::Update( const Vector &vecPos, const Vector &vecForward, const Vector &vecRight, const Vector &vecUp )
{
VPROF_BUDGET( __FUNCTION__, VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
// No esta encendida
if ( !IsOn() )
return;
FlashlightState_t state;
// Actualizamos el estado
if ( !UpdateState( state, vecPos, vecForward, vecRight, vecUp ) )
return;
// Actualizamos la proyección de la luz
UpdateLightProjection( state );
#ifndef NO_TOOLFRAMEWORK
if ( clienttools->IsInRecordingMode() ) {
KeyValues *msg = new KeyValues( "FlashlightState" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetInt( "entindex", m_iEntIndex );
msg->SetInt( "flashlightHandle", m_nLightHandle );
msg->SetPtr( "flashlightState", &state );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
#endif
}
示例10: 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();
}
示例11: ReorderObjectives
// sets priority of objective entities based on the order the rooms were listed in the mission/objective txt
void VMFExporter::ReorderObjectives( const CRoomTemplate *pTemplate, KeyValues *pTemplateKeys )
{
KeyValues *pKeys = m_pTemplateKeys;
while ( pKeys )
{
if ( !Q_stricmp( pKeys->GetName(), "entity" ) && !Q_strnicmp( pKeys->GetString( "classname" ), "asw_objective", 13 ) )
{
if ( pKeys->GetFloat( "Priority" ) != 0 ) // if level designer has already set priority, then don't override it
{
pKeys = pKeys->GetNextKey();
continue;
}
int iPriority = 100;
// We no longer have a requested rooms array, so this code is not valid. Need to replace it with something else to ensure priorities are set correctly.
// for ( int i = 0; i < m_pMapLayout->m_pRequestedRooms.Count(); i++ )
// {
// if ( m_pMapLayout->m_pRequestedRooms[i]->m_pRoomTemplate == pTemplate )
// {
// iPriority = m_pMapLayout->m_pRequestedRooms[i]->m_iMissionTextOrder;
// }
// }
pKeys->SetFloat( "Priority", iPriority );
}
pKeys = pKeys->GetNextKey();
}
}
示例12: KeyValues
FOR_EACH_VEC(m_vLocalTimes, i)
{
Time t = m_vLocalTimes[i];
//MOM_TODO: consider adding a "100 tick" column?
KeyValues *kvLocalTimeFormatted = new KeyValues("localtime");
kvLocalTimeFormatted->SetFloat("time_f", t.time_sec);//Used for static compare
kvLocalTimeFormatted->SetInt("date_t", t.date);//Used for finding
char timeString[BUFSIZETIME];
mom_UTIL->FormatTime(t.time_sec, timeString);
kvLocalTimeFormatted->SetString("time", timeString);
char dateString[64];
tm *local;
local = localtime(&t.date);
if (local)
{
strftime(dateString, sizeof(dateString), "%d/%m/%Y %H:%M:%S", local);
kvLocalTimeFormatted->SetString("date", dateString);
}
else
kvLocalTimeFormatted->SetInt("date", t.date);
kvInto->AddSubKey(kvLocalTimeFormatted);
}
示例13: 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();
}
示例14: TurnOff
//================================================================================
// Apaga y destruye la luz
//================================================================================
void CInternalLight::TurnOff()
{
// No esta encendida
if ( !IsOn() )
return;
m_bIsOn = false;
// Destruimos la luz
if ( m_nLightHandle != CLIENTSHADOW_INVALID_HANDLE ) {
g_pClientShadowMgr->DestroyFlashlight( m_nLightHandle );
m_nLightHandle = CLIENTSHADOW_INVALID_HANDLE;
}
#ifndef NO_TOOLFRAMEWORK
if ( clienttools->IsInRecordingMode() ) {
KeyValues *msg = new KeyValues( "FlashlightState" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetInt( "entindex", m_iEntIndex );
msg->SetInt( "flashlightHandle", m_nLightHandle );
msg->SetPtr( "flashlightState", NULL );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
#endif
}
示例15: InsertKeyValues
//-----------------------------------------------------------------------------
// VMT parser
//-----------------------------------------------------------------------------
static void InsertKeyValues( KeyValues &dst, KeyValues& src, bool bCheckForExistence )
{
KeyValues *pSrcVar = src.GetFirstSubKey();
while( pSrcVar )
{
if ( !bCheckForExistence || dst.FindKey( pSrcVar->GetName() ) )
{
switch( pSrcVar->GetDataType() )
{
case KeyValues::TYPE_STRING:
dst.SetString( pSrcVar->GetName(), pSrcVar->GetString() );
break;
case KeyValues::TYPE_INT:
dst.SetInt( pSrcVar->GetName(), pSrcVar->GetInt() );
break;
case KeyValues::TYPE_FLOAT:
dst.SetFloat( pSrcVar->GetName(), pSrcVar->GetFloat() );
break;
case KeyValues::TYPE_PTR:
dst.SetPtr( pSrcVar->GetName(), pSrcVar->GetPtr() );
break;
}
}
pSrcVar = pSrcVar->GetNextKey();
}
}