本文整理汇总了C++中KeyValues::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetInt方法的具体用法?C++ KeyValues::GetInt怎么用?C++ KeyValues::GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseReleased
void CMapListPanel::OnMouseReleased(MouseCode code)
{
if (code == MOUSE_LEFT)
{
int x, y;
input()->GetCursorPosition(x, y);
int row, col;
if (GetCellAtPos(x, y, row, col))
{
int itemID = GetItemIDFromRow(row);
uint32 mapID = GetItemUserData(itemID);
KeyValues *pMap = GetItem(itemID);
if (pMap)
{
if (col == HEADER_MAP_IN_LIBRARY)
{
if (pMap->GetInt(KEYNAME_MAP_IN_LIBRARY) == INDX_MAP_IN_LIBRARY)
MapSelectorDialog().OnRemoveMapFromLibrary(mapID);
else
MapSelectorDialog().OnAddMapToLibrary(mapID);
}
else if (col == HEADER_MAP_IN_FAVORITES)
{
if (pMap->GetInt(KEYNAME_MAP_IN_FAVORITES) == INDX_MAP_IN_FAVORITES)
MapSelectorDialog().OnRemoveMapFromFavorites(mapID);
else
MapSelectorDialog().OnAddMapToFavorites(mapID);
}
}
}
}
}
示例2: LoadFilterSettings
//-----------------------------------------------------------------------------
// Purpose: loads filter settings (from disk) from the keyvalues
//-----------------------------------------------------------------------------
void CBaseMapsPage::LoadFilterSettings()
{
KeyValues *filter = MapSelectorDialog().GetFilterSaveData(GetName());
//Game-mode selection
m_iGameModeFilter = filter->GetInt("gamemode", 0);
m_pGameModeFilter->ActivateItemByRow(m_iGameModeFilter);
//"Map"
Q_strncpy(m_szMapFilter, filter->GetString("map"), sizeof(m_szMapFilter));
m_pMapFilter->SetText(m_szMapFilter);
//Map layout
m_iMapLayoutFilter = filter->GetInt("maplayout", 0);
m_pMapLayoutFilter->ActivateItemByRow(m_iMapLayoutFilter);
//HideCompleted maps
m_bFilterHideCompleted = filter->GetBool("HideCompleted", false);
m_pHideCompletedFilterCheck->SetSelected(m_bFilterHideCompleted);
//Difficulty
m_iDifficultyFilter = filter->GetInt("difficulty");
if (m_iDifficultyFilter)
{
char buf[32];
Q_snprintf(buf, sizeof(buf), "< %d", m_iDifficultyFilter);
m_pDifficultyFilter->SetText(buf);
}
// apply to the controls
OnLoadFilter(filter);
UpdateFilterSettings();
ApplyGameFilters();
}
示例3: SetupList
// fills in the target list panel with buttons for each of the entries in the desired list
bool SwarmopediaTopics::SetupList(SwarmopediaPanel *pPanel, const char *szDesiredList)
{
// look through our KeyValues for the desired list
KeyValues *pkvList = GetSubkeyForList(szDesiredList);
if (!pkvList)
{
Msg("Swarmopedia error: Couldn't find list %s\n", szDesiredList);
return false;
}
// now go through every LISTENTRY in the subkey we found, adding it to the list panel
int iPlayerUnlockLevel = 999; // todo: have this check a convar that measures how far through the jacob campaign the player has got
while ( pkvList )
{
if (Q_stricmp(pkvList->GetName(), "LISTENTRY")==0)
{
const char *szEntryName = pkvList->GetString("Name");
const char *szArticleTarget = pkvList->GetString("ArticleTarget");
const char *szListTarget = pkvList->GetString("ListTarget");
int iEntryUnlockLevel = pkvList->GetInt("UnlockLevel");
int iSectionHeader = pkvList->GetInt("SectionHeader");
if (iEntryUnlockLevel == 0 || iEntryUnlockLevel < iPlayerUnlockLevel)
{
pPanel->AddListEntry(szEntryName, szArticleTarget, szListTarget, iSectionHeader);
}
}
pkvList = pkvList->GetNextKey();
}
return true;
}
示例4: ReadKVIdents_Combos
void ReadKVIdents_Combos( CUtlVector< SimpleCombo* > &hList, KeyValues *pKV )
{
int itr = 0;
char tmp[MAX_PATH];
Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
KeyValues *c = pKV->FindKey( tmp );
while( c )
{
SimpleCombo *combo = new SimpleCombo();
const char *name = c->GetString( "sz_name" );
int len = Q_strlen( name ) + 1;
combo->name = new char[ len ];
Q_snprintf( combo->name, MAX_PATH, "%s", name );
combo->bStatic = !!c->GetInt( "i_static" );
combo->min = c->GetInt( "i_min" );
combo->max = c->GetInt( "i_max" );
combo->iComboType = c->GetInt( "i_type" );
hList.AddToTail( combo );
itr++;
Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
c = pKV->FindKey( tmp );
}
}
示例5: ReadKVIdents_Texture
void ReadKVIdents_Texture( CUtlVector< SimpleTexture* > &hList, KeyValues *pKV )
{
int itr = 0;
char tmp[MAX_PATH];
Q_snprintf( tmp, MAX_PATH, "texsamp_%i", itr );
KeyValues *c = pKV->FindKey( tmp );
while( c )
{
SimpleTexture *tex = new SimpleTexture();
const char *paramname = c->GetString( "sz_param" );
int len = Q_strlen( paramname ) + 1;
tex->szParamName = new char[ len ];
Q_snprintf( tex->szParamName, MAX_PATH, "%s", paramname );
const char *fallbackname = c->GetString( "sz_fallback" );
len = Q_strlen( fallbackname ) + 1;
tex->szFallbackName = new char[ len ];
Q_snprintf( tex->szFallbackName, MAX_PATH, "%s", fallbackname );
tex->iSamplerIndex = c->GetInt( "i_sampidx" );
tex->iTextureMode = c->GetInt( "i_texmode" );
tex->bCubeTexture = !!c->GetInt( "i_cubemap" );
tex->bSRGB = !!c->GetInt( "i_srgb" );
hList.AddToTail( tex );
itr++;
Q_snprintf( tmp, MAX_PATH, "texsamp_%i", itr );
c = pKV->FindKey( tmp );
}
}
示例6: LoadFromKeyValues
void CRoomTemplate::LoadFromKeyValues( const char *pRoomName, KeyValues *pKeyValues )
{
m_nTilesX = pKeyValues->GetInt( "TilesX", 1 );
m_nTilesY = pKeyValues->GetInt( "TilesY", 1 );
SetSpawnWeight( pKeyValues->GetInt( "SpawnWeight", MIN_SPAWN_WEIGHT ) );
SetFullName( pRoomName );
Q_strncpy( m_Description, pKeyValues->GetString( "RoomTemplateDescription", "" ), m_nMaxDescriptionLength );
Q_strncpy( m_Soundscape, pKeyValues->GetString( "Soundscape", "" ), m_nMaxSoundscapeLength );
SetTileType( pKeyValues->GetInt( "TileType", ASW_TILETYPE_UNKNOWN ) );
m_Tags.RemoveAll();
// search through all the exit subsections
KeyValues *pkvSubSection = pKeyValues->GetFirstSubKey();
bool bClearedExits = false;
while ( pkvSubSection )
{
// mission details
if ( Q_stricmp(pkvSubSection->GetName(), "EXIT")==0 )
{
if ( !bClearedExits )
{
// if we haven't cleared previous exits yet then do so now
m_Exits.PurgeAndDeleteElements();
bClearedExits = true;
}
CRoomTemplateExit *pExit = new CRoomTemplateExit();
pExit->m_iXPos = pkvSubSection->GetInt("XPos");
pExit->m_iYPos = pkvSubSection->GetInt("YPos");
pExit->m_ExitDirection = (ExitDirection_t) pkvSubSection->GetInt("ExitDirection");
pExit->m_iZChange = pkvSubSection->GetInt("ZChange");
Q_strncpy( pExit->m_szExitTag, pkvSubSection->GetString( "ExitTag" ), sizeof( pExit->m_szExitTag ) );
pExit->m_bChokepointGrowSource = !!pkvSubSection->GetInt("ChokeGrow", 0);
// discard exits outside the room bounds
if ( pExit->m_iXPos < 0 || pExit->m_iYPos < 0 || pExit->m_iXPos >= m_nTilesX || pExit->m_iYPos >= m_nTilesY )
{
delete pExit;
}
else
{
m_Exits.AddToTail(pExit);
}
}
else if ( Q_stricmp(pkvSubSection->GetName(), "Tags")==0 && TagList() )
{
for ( KeyValues *sub = pkvSubSection->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
{
if ( !Q_stricmp( sub->GetName(), "tag" ) )
{
AddTag( sub->GetString() );
}
}
}
pkvSubSection = pkvSubSection->GetNextKey();
}
}
示例7: ReadKVIdents_EConst
void ReadKVIdents_EConst( CUtlVector< SimpleEnvConstant* > &hList, KeyValues *pKV )
{
int itr = 0;
char tmp[MAX_PATH];
Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
KeyValues *c = pKV->FindKey( tmp );
while( c )
{
SimpleEnvConstant *econst = new SimpleEnvConstant();
econst->iEnvC_ID = c->GetInt( "i_envconstidx" );
econst->iHLSLRegister = c->GetInt( "i_normregister" );
econst->iConstSize = c->GetInt( "i_econstsize" );
econst->iSmartNumComps = c->GetInt( "i_smartcomps" );
const char *name = c->GetString( "sz_smartname" );
int len = Q_strlen( name ) + 1;
econst->szSmartHelper = new char[ len ];
Q_snprintf( econst->szSmartHelper, MAX_PATH, "%s", name );
for ( int i = 0; i < 4; i++ )
{
char tmpdef[MAX_PATH];
Q_snprintf( tmpdef, MAX_PATH, "fl_smartdefault_%02i", i );
econst->flSmartDefaultValues[ i ] = c->GetFloat( tmpdef );
}
hList.AddToTail( econst );
itr++;
Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
c = pKV->FindKey( tmp );
}
}
示例8: GetDoc
//-----------------------------------------------------------------------------
// Purpose: Creates a message to send to a friend - returns NULL if user unknown
//-----------------------------------------------------------------------------
ISendMessage *CServerSession::CreateUserMessage(unsigned int userID, int msgID)
{
CBuddy *bud = GetDoc()->GetBuddy(userID);
if (!bud)
return NULL;
KeyValues *buddy = bud->Data();
if (!buddy)
return NULL;
ISendMessage *msg = m_pNet->CreateMessage(msgID);
// get address
CNetAddress addr;
addr.SetIP(buddy->GetInt("IP"));
addr.SetPort(buddy->GetInt("Port"));
msg->SetNetAddress(addr);
msg->SetEncrypted(true);
// set the session ID to be the session ID of the target
msg->SetSessionID(buddy->GetInt("SessionID"));
return msg;
}
示例9: ApplySettings
//---------------------------------------------------------------------
// Purpose: Parse session properties and contexts from the resource file
//---------------------------------------------------------------------
void CSessionBrowserDialog::ApplySettings( KeyValues *pResourceData )
{
BaseClass::ApplySettings( pResourceData );
KeyValues *pScenarios = pResourceData->FindKey( "ScenarioInfoPanels" );
if ( pScenarios )
{
for ( KeyValues *pScenario = pScenarios->GetFirstSubKey(); pScenario != NULL; pScenario = pScenario->GetNextKey() )
{
CScenarioInfoPanel *pScenarioInfo = new CScenarioInfoPanel( this, "ScenarioInfoPanel" );
SETUP_PANEL( pScenarioInfo );
pScenarioInfo->m_pTitle->SetText( pScenario->GetString( "title" ) );
pScenarioInfo->m_pSubtitle->SetText( pScenario->GetString( "subtitle" ) );
pScenarioInfo->m_pMapImage->SetImage( pScenario->GetString( "image" ) );
int nTall = pScenario->GetInt( "tall", -1 );
if ( nTall > 0 )
{
pScenarioInfo->SetTall( nTall );
}
int nXPos = pScenario->GetInt( "xpos", -1 );
if ( nXPos >= 0 )
{
int x, y;
pScenarioInfo->GetPos( x, y );
pScenarioInfo->SetPos( nXPos, y );
}
int nDescOneYpos = pScenario->GetInt( "descOneY", -1 );
if ( nDescOneYpos > 0 )
{
int x, y;
pScenarioInfo->m_pDescOne->GetPos( x, y );
pScenarioInfo->m_pDescOne->SetPos( x, nDescOneYpos );
}
int nDescTwoYpos = pScenario->GetInt( "descTwoY", -1 );
if ( nDescTwoYpos > 0 )
{
int x, y;
pScenarioInfo->m_pDescTwo->GetPos( x, y );
pScenarioInfo->m_pDescTwo->SetPos( x, nDescTwoYpos );
}
m_pScenarioInfos.AddToTail( pScenarioInfo );
}
}
}
示例10: OverrideDefaultsForModel
void OverrideDefaultsForModel( const char *keyname, simplifyparams_t ¶ms )
{
KeyValues *pKeys = g_pModelConfig;
while ( pKeys )
{
if ( !Q_stricmp( pKeys->GetName(), keyname ) )
{
for ( KeyValues *pData = pKeys->GetFirstSubKey(); pData; pData = pData->GetNextKey() )
{
if ( !Q_stricmp( pData->GetName(), "tolerance" ) )
{
params.tolerance = pData->GetFloat();
if (!g_bQuiet)
{
Msg("%s: tolerance set to %.2f\n", keyname, params.tolerance );
}
}
else if ( !Q_stricmp( pData->GetName(), "addAABB" ) )
{
params.addAABBToSimplifiedHull = pData->GetInt() ? true : false;
if (!g_bQuiet)
{
Msg("%s: AABB %s\n", keyname, params.addAABBToSimplifiedHull ? "on" : "off" );
}
}
else if ( !Q_stricmp( pData->GetName(), "singleconvex" ) )
{
params.forceSingleConvex = pData->GetInt() ? true : false;
if (!g_bQuiet)
{
Msg("%s: Forced to single convex\n", keyname );
}
}
else if ( !Q_stricmp( pData->GetName(), "mergeconvex" ) )
{
params.mergeConvexTolerance = pData->GetFloat();
params.mergeConvexElements = params.mergeConvexTolerance > 0 ? true : false;
if (!g_bQuiet)
{
Msg("%s: Merge convex %.2f\n", keyname, params.mergeConvexTolerance );
}
}
}
return;
}
pKeys = pKeys->GetNextKey();
}
}
示例11: ItemSelected
//-----------------------------------------------------------------------------
// Purpose: User clicked on item: remember where last active row/column was
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::ItemSelected(int itemID)
{
m_pKeyBindList->SetItemOfInterest(itemID);
if (m_pKeyBindList->IsItemIDValid(itemID))
{
// find the details, see if we should be enabled/clear/whatever
m_pSetBindingButton->SetEnabled(true);
KeyValues *kv = m_pKeyBindList->GetItemData(itemID);
if (kv)
{
const char *key = kv->GetString("Key", NULL);
if (key && *key)
{
m_pClearBindingButton->SetEnabled(true);
}
else
{
m_pClearBindingButton->SetEnabled(false);
}
if (kv->GetInt("Header"))
{
m_pSetBindingButton->SetEnabled(false);
}
}
}
else
{
m_pSetBindingButton->SetEnabled(false);
m_pClearBindingButton->SetEnabled(false);
}
}
示例12: CreateWorldVertexTransitionPatchedMaterial
void CreateWorldVertexTransitionPatchedMaterial( const char *pOriginalMaterialName, const char *pPatchedMaterialName )
{
KeyValues *kv = LoadMaterialKeyValues( pOriginalMaterialName, 0 );
if( kv )
{
// change shader to Lightmappedgeneric (from worldvertextransition*)
kv->SetName( "LightmappedGeneric" );
// don't need no stinking $basetexture2 or any other second texture vars
RemoveKey( kv, "$basetexture2" );
RemoveKey( kv, "$bumpmap2" );
RemoveKey( kv, "$bumpframe2" );
RemoveKey( kv, "$basetexture2noenvmap" );
RemoveKey( kv, "$blendmodulatetexture" );
RemoveKey( kv, "$maskedblending" );
RemoveKey( kv, "$surfaceprop2" );
// If we didn't want a basetexture on the first texture in the blend, we don't want an envmap at all.
KeyValues *basetexturenoenvmap = kv->FindKey( "$BASETEXTURENOENVMAP" );
if( basetexturenoenvmap->GetInt() )
{
RemoveKey( kv, "$envmap" );
}
Warning( "Patching WVT material: %s\n", pPatchedMaterialName );
WriteMaterialKeyValuesToPak( pPatchedMaterialName, kv );
}
}
示例13: RefreshGameSoundList
//-----------------------------------------------------------------------------
// Purpose: refreshes the gamesound list
//-----------------------------------------------------------------------------
void CSoundPicker::RefreshGameSoundList()
{
if ( !m_pGameSoundList )
return;
// Check the filter matches
int nMatchingGameSounds = 0;
int nTotalCount = 0;
for ( int nItemID = m_pGameSoundList->FirstItem(); nItemID != m_pGameSoundList->InvalidItemID(); nItemID = m_pGameSoundList->NextItem( nItemID ) )
{
KeyValues *kv = m_pGameSoundList->GetItem( nItemID );
int hGameSound = kv->GetInt( "gameSoundHandle", SoundEmitterSystem()->InvalidIndex() );
if ( hGameSound == SoundEmitterSystem()->InvalidIndex() )
continue;
bool bIsVisible = IsGameSoundVisible( hGameSound );
m_pGameSoundList->SetItemVisible( nItemID, bIsVisible );
if ( bIsVisible )
{
++nMatchingGameSounds;
}
++nTotalCount;
}
UpdateGameSoundColumnHeader( nMatchingGameSounds, nTotalCount );
if ( ( m_pGameSoundList->GetSelectedItemsCount() == 0 ) && ( m_pGameSoundList->GetItemCount() > 0 ) )
{
int nItemID = m_pGameSoundList->GetItemIDFromRow( 0 );
// This prevents the refreshing of the sound list from playing the sound
++m_nSoundSuppressionCount;
m_pGameSoundList->SetSelectedCell( nItemID, 0 );
}
}
示例14: FindPoseCycle
static float FindPoseCycle( StudioModel *model, int sequence )
{
float cycle = 0.0f;
if ( !model->GetStudioHdr() )
return cycle;
KeyValues *seqKeyValues = new KeyValues("");
if ( seqKeyValues->LoadFromBuffer( model->GetFileName( ), model->GetKeyValueText( sequence ) ) )
{
// Do we have a build point section?
KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
if ( pkvAllFaceposer )
{
int thumbnail_frame = pkvAllFaceposer->GetInt( "thumbnail_frame", 0 );
if ( thumbnail_frame )
{
// Convert frame to cycle if we have valid data
int maxFrame = model->GetNumFrames( sequence ) - 1;
if ( maxFrame > 0 )
{
cycle = thumbnail_frame / (float)maxFrame;
}
}
}
}
seqKeyValues->deleteThis();
return cycle;
}
示例15: OverrideMenuItem
//-----------------------------------------------------------------
// Purpose: Change properties of a menu item
//-----------------------------------------------------------------
void CSessionOptionsDialog::OverrideMenuItem( KeyValues *pItemKeys )
{
if ( m_bModifySession && m_pDialogKeys )
{
if ( !Q_stricmp( pItemKeys->GetName(), "OptionsItem" ) )
{
const char *pID = pItemKeys->GetString( "id", "NULL" );
KeyValues *pKey = m_pDialogKeys->FindKey( pID );
if ( pKey )
{
pItemKeys->SetInt( "activeoption", pKey->GetInt( "optionindex" ) );
}
}
}
//
// When hosting a new session on LIVE:
// - restrict max number of players to bandwidth allowed
//
if ( !m_bModifySession &&
( !Q_stricmp( m_szGametype, "hoststandard" ) || !Q_stricmp( m_szGametype, "hostranked" ) )
)
{
if ( !Q_stricmp( pItemKeys->GetName(), "OptionsItem" ) )
{
const char *pID = pItemKeys->GetString( "id", "NULL" );
if ( !Q_stricmp( pID, "PROPERTY_GAME_SIZE" ) )
{
pItemKeys->SetInt( "activeoption", GetMaxPlayersRecommendedOption() );
}
}
}
}