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


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

本文整理汇总了C++中KeyValues::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetString方法的具体用法?C++ KeyValues::GetString怎么用?C++ KeyValues::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValues的用法示例。


在下文中一共展示了KeyValues::GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnCommand

void CDevMapPanel::OnCommand(const char *command)
{
	if (!Q_strcmp(command, "Load") || !Q_strcmp(command, "DoubleClick") || !Q_strcmp(command, "PressedEnter"))
	{
		int itemId = m_pListPanel->GetSelectedItem(0);
		KeyValues *kv = m_pListPanel->GetItem(itemId);
		if (kv)
		{
			const char *map = kv->GetString("Map");
			char map_command[64];
			Q_snprintf(map_command, sizeof(map_command), "map %s", map);
			engine->ClientCmd("scene_flush");
			engine->ClientCmd("disconnect");
			engine->ClientCmd("mat_fullbright 0");
			engine->ClientCmd("progress_enable");
			engine->ClientCmd("clear");
			engine->ClientCmd(map_command);
		}
	}
	else if (!Q_strcmp(command, "Refresh"))
	{
		AddMapsToPanel();
	}

	BaseClass::OnCommand(command);
}
开发者ID:FAKEFACTORY,项目名称:CM2013,代码行数:26,代码来源:IDevMapPanel.cpp

示例2: LoadSurfaceProperties

//-----------------------------------------------------------------------------
// Purpose: Loads the surface properties database into the physics DLL
//-----------------------------------------------------------------------------
void LoadSurfaceProperties( void )
{
	CreateInterfaceFn physicsFactory = GetPhysicsFactory();
	if ( !physicsFactory )
		return;

	physprops = (IPhysicsSurfaceProps *)physicsFactory( VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL );

	const char *SURFACEPROP_MANIFEST_FILE = "scripts/surfaceproperties_manifest.txt";
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( g_pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				LoadSurfacePropFile( sub->GetString() );
				continue;
			}
		}
	}

	manifest->deleteThis();
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:28,代码来源:textures.cpp

示例3: GetInteriorSequence

//-----------------------------------------------------------------------------
// Purpose: get the "idle" animation to play as the compliment to the movement animation
//-----------------------------------------------------------------------------
int CAI_BlendedMotor::GetInteriorSequence( int fromSequence )
{
	// FIXME: add interior activity to path, just like arrival activity.
	int  sequence = GetNavigator()->GetMovementSequence();

	if (m_nInteriorSequence != ACT_INVALID && sequence == m_nPrevMovementSequence)
	{
		return m_nInteriorSequence;
	}

	m_nPrevMovementSequence = sequence;

	KeyValues *seqKeyValues = GetOuter()->GetSequenceKeyValues( sequence );
	// Msg("sequence %d : %s (%d)\n", sequence,  GetOuter()->GetSequenceName( sequence ), seqKeyValues != NULL );
	if (seqKeyValues)
	{
		KeyValues *pkvInterior = seqKeyValues->FindKey("interior");
		if (pkvInterior)
		{
			const char *szActivity = pkvInterior->GetString();
		
			Activity activity = ( Activity )GetOuter()->LookupActivity( szActivity );
			if ( activity != ACT_INVALID )
			{
				m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );
			}
			else
			{
				activity = (Activity)GetOuter()->GetActivityID( szActivity );
				if ( activity != ACT_INVALID )
				{
					m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );
				}
			}

			if (activity == ACT_INVALID || m_nInteriorSequence == ACT_INVALID)
			{
				m_nInteriorSequence = GetOuter()->LookupSequence( szActivity );
			}
		}
	}

	if (m_nInteriorSequence == ACT_INVALID)
	{
		Activity activity = GetNavigator()->GetMovementActivity();
		if (activity == ACT_WALK_AIM || activity == ACT_RUN_AIM)
		{
			activity = ACT_IDLE_ANGRY;
		}
		else
		{
			activity = ACT_IDLE;
		}
		m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );

		Assert( m_nInteriorSequence != ACT_INVALID );
	}

	return m_nInteriorSequence;
}
开发者ID:KissLick,项目名称:sourcemod-npc-in-css,代码行数:63,代码来源:CAI_Blended_Movement.cpp

示例4: KeyValues

CVGUIProjectable *CProjectableFactory::AllocateProjectableByScript( const char *pszFileName )
{
	CVGUIProjectable *pPanel = NULL;

	KeyValues *pKV = new KeyValues("");

	bool bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );
	if ( !bSuccess )
		bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s.txt", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );

	if ( bSuccess )
	{
		const char *pszFactoryName = pKV->GetString( "factory" );

		if ( pszFactoryName != NULL && *pszFactoryName != '\0' )
			pPanel = AllocateProjectableByName( pszFactoryName );

		if ( pPanel != NULL )
		{
			KeyValues *pConfig = pKV->FindKey( "config" );

			if ( pConfig != NULL )
			{
				pPanel->LoadProjectableConfig( pConfig );
				pPanel->InvalidateLayout( true, true );
			}
		}
	}

	pKV->deleteThis();

	return pPanel;
}
开发者ID:AniCator,项目名称:Project-Potato,代码行数:33,代码来源:projectable_factory.cpp

示例5: AddBinding

//-----------------------------------------------------------------------------
// Purpose: Bind the specified keyname to the specified item
// Input  : *item - Item to which to add the key
//			*keyname - The key to be added
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::AddBinding( KeyValues *item, const char *keyname )
{
	// See if it's already there as a binding
	if ( !stricmp( item->GetString( "Key", "" ), keyname ) )
		return;

	// Make sure it doesn't live anywhere
	RemoveKeyFromBindItems( item, keyname );

	const char *binding = item->GetString( "Binding", "" );

	// Loop through all the key bindings and set all entries that have
	// the same binding. This allows us to have multiple entries pointing 
	// to the same binding.
	for (int i = 0; i < m_pKeyBindList->GetItemCount(); i++)
	{
		KeyValues *curitem = m_pKeyBindList->GetItemData(m_pKeyBindList->GetItemIDFromRow(i));
		if ( !curitem )
			continue;

		const char *curbinding = curitem->GetString( "Binding", "" );

		if (!stricmp(curbinding, binding))
		{
			curitem->SetString( "Key", keyname );
			m_pKeyBindList->InvalidateItem(i);
		}
	}
}
开发者ID:gamenew09,项目名称:SourceSDK2010,代码行数:34,代码来源:optionssubkeyboard.cpp

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

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

示例8: CreateVPhysics

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
bool CNPC_Furniture::CreateVPhysics( void )
{
#ifndef HL2_DLL
	return false;
#endif

	if ( !m_BoneFollowerManager.GetNumBoneFollowers() )
	{
		KeyValues *modelKeyValues = new KeyValues("");
		if ( modelKeyValues->LoadFromBuffer( modelinfo->GetModelName( GetModel() ), modelinfo->GetModelKeyValueText( GetModel() ) ) )
		{
			// Do we have a bone follower section?
			KeyValues *pkvBoneFollowers = modelKeyValues->FindKey("bone_followers");
			if ( pkvBoneFollowers )
			{
				// Loop through the list and create the bone followers
				KeyValues *pBone = pkvBoneFollowers->GetFirstSubKey();
				while ( pBone )
				{
					// Add it to the list
					const char *pBoneName = pBone->GetString();
					m_BoneFollowerManager.AddBoneFollower( this, pBoneName );

					pBone = pBone->GetNextKey();
				}
			}
		}
		modelKeyValues->deleteThis();
	}

	return true;
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:35,代码来源:genericmonster.cpp

示例9: SetVarString

//-----------------------------------------------------------------------------
// Purpose: sets the value of a variable in the list
//-----------------------------------------------------------------------------
void CVarListPropertyPage::SetVarString(const char *varName, const char *value)
{
	// find the item by name
	int itemID = m_pRulesList->GetItem(varName);
	KeyValues *rule = m_pRulesList->GetItem(itemID);
	if (!rule)
		return;

	// parse the rule
	const char *type = rule->GetString("type");
	if (!stricmp(type, "enumeration"))
	{
		// look up the value in the enumeration
		int iValue = atoi(value);
		const char *result = rule->FindKey("list", true)->GetString(value, "");
		rule->SetString("value", result);
		rule->SetInt("enum", iValue);
	}
	else 
	{
		// no special type, treat it as a string
		rule->SetString("value", value);
	}
		
	m_pRulesList->ApplyItemChanges(itemID);
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:29,代码来源:VarListPropertyPage.cpp

示例10: GetSelectedAsset

//-----------------------------------------------------------------------------
// Returns the selected sound
//-----------------------------------------------------------------------------
const char *CSoundPicker::GetSelectedSoundName( int nSelectionIndex )
{
	if ( m_pGameSoundPage && ( m_pViewsSheet->GetActivePage() == m_pGameSoundPage ) )
	{
		int nCount = m_pGameSoundList->GetSelectedItemsCount();
		if ( nCount == 0 )
			return NULL;

		if ( nSelectionIndex < 0 )
		{
			nSelectionIndex = nCount - 1;
		}
		int nIndex = m_pGameSoundList->GetSelectedItem( nSelectionIndex );
		if ( nIndex >= 0 )
		{
			KeyValues *pkv = m_pGameSoundList->GetItem( nIndex );
			return pkv->GetString( "gamesound", NULL );
		}
		return NULL;
	}

	if ( m_pWavPage && ( m_pViewsSheet->GetActivePage() == m_pWavPage ) )
		return GetSelectedAsset( nSelectionIndex );

	return NULL;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:29,代码来源:soundpicker.cpp

示例11: GetCachedData

//--------------------------------------------------------------------------------------------------------------
void DownloadCache::GetCachedData( RequestContext *rc )
{
	if ( !m_cache )
		return;

	char cachePath[_MAX_PATH];
	GetCacheFilename( rc, cachePath );

	if ( !(*cachePath) )
		return;

	FileHandle_t fp = g_pFileSystem->Open( cachePath, "rb" );

	if ( fp == FILESYSTEM_INVALID_HANDLE )
		return;

	int size = g_pFileSystem->Size(fp);
	rc->cacheData = new unsigned char[size];
	int status = g_pFileSystem->Read( rc->cacheData, size, fp );
	g_pFileSystem->Close( fp );
	if ( !status )
	{
		delete[] rc->cacheData;
		rc->cacheData = NULL;
	}
	else
	{
		BuildKeyNames( rc->gamePath );
		rc->nBytesCached = size;
		strncpy( rc->cachedTimestamp, m_cache->GetString( m_timestampKey, "" ), BufferSize );
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:33,代码来源:download.cpp

示例12: GenerateFullPathForNode

//-----------------------------------------------------------------------------
// Purpose: creates the full path for a node
//-----------------------------------------------------------------------------
void DirectorySelectDialog::GenerateFullPathForNode(int nodeIndex, char *path, int pathBufferSize)
{
	// get all the nodes
	CUtlLinkedList<int, int> nodes;
	nodes.AddToTail(nodeIndex);
	int parentIndex = nodeIndex;
	while (1)
	{
		parentIndex = m_pDirTree->GetItemParent(parentIndex);
		if (parentIndex == -1)
			break;
		nodes.AddToHead(parentIndex);
	}

	// walk the nodes, adding to the path
	path[0] = 0;
	bool bFirst = true;
	FOR_EACH_LL( nodes, i )
	{
		KeyValues *kv = m_pDirTree->GetItemData( nodes[i] );
		strcat(path, kv->GetString("Text"));

		if (!bFirst)
		{
			strcat(path, "\\");
		}
		bFirst = false;
	}
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:31,代码来源:DirectorySelectDialog.cpp

示例13: OnTextChanged

//-----------------------------------------------------------------------------
// Purpose: Handles changes to combo boxes
//-----------------------------------------------------------------------------
void CMOMSpectatorMenu::OnTextChanged(KeyValues *data)
{
    Panel *panel = reinterpret_cast<Panel *>(data->GetPtr("panel"));

    ComboBox *box = dynamic_cast<ComboBox *>(panel);

    if (box == m_pConfigSettings) // don't change the text in the config setting combo
    {
        m_pConfigSettings->SetText("#Spec_Options");
    }
    else if (box == m_pPlayerList)
    {
        KeyValues *kv = box->GetActiveItemUserData();
        if (kv && GameResources())
        {
            const char *player = kv->GetString("player");

            int currentPlayerNum = GetSpectatorTarget();
            const char *currentPlayerName = GameResources()->GetPlayerName(currentPlayerNum);

            if (!FStrEq(currentPlayerName, player))
            {
                char command[128];
                Q_snprintf(command, sizeof(command), "spec_player \"%s\"", player);
                engine->ClientCmd(command);
            }
        }
    }
}
开发者ID:Asunaya,项目名称:game,代码行数:32,代码来源:momSpectatorGUI.cpp

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

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


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