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


C++ Panel::LookupBinding方法代码示例

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


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

示例1: PopulateList

void CKeyBindingHelpDialog::PopulateList()
{
	m_pList->DeleteAllItems();

	int i, j;

	CUtlVector< ListInfo_t > maps;
	vgui2::Panel *pPanel = m_hPanel;
	while ( pPanel->IsKeyBindingChainToParentAllowed() )
	{
		PanelKeyBindingMap *map = pPanel->GetKBMap();
		while ( map )
		{
			int k;
			int c = maps.Count();
			for ( k = 0; k < c; ++k )
			{
				if ( maps[k].m_pMap == map )
					break;
			}
			if ( k == c )
			{
				int mapIndex = maps.AddToTail( );
				maps[mapIndex].m_pMap = map;
				maps[mapIndex].m_pPanel = pPanel;
			}
			map = map->baseMap;
		}

		pPanel = pPanel->GetParent();
		if ( !pPanel )
			break;
	}

	CUtlRBTree< KeyValues *, int >	sorted( 0, 0, BindingLessFunc );

	// add header item
	int c = maps.Count();
	for ( i = 0; i < c; ++i )
	{
		PanelKeyBindingMap *m = maps[ i ].m_pMap;
		Panel *pMapPanel = maps[i].m_pPanel;
		Assert( m );

		int bindings = m->boundkeys.Count();
		for ( j = 0; j < bindings; ++j )
		{
			BoundKey_t *kbMap = &m->boundkeys[ j ];
			Assert( kbMap );

			// Create a new: blank item
			KeyValues *item = new KeyValues( "Item" );
			
			// Fill in data
			char loc[ 128 ];
			Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );

			char ansi[ 256 ];
			AnsiText( loc, ansi, sizeof( ansi ) );

			item->SetString( "Action", ansi );
			item->SetWString( "Binding", Panel::KeyCodeModifiersToDisplayString( (KeyCode)kbMap->keycode, kbMap->modifiers ) );

			// Find the binding
			KeyBindingMap_t *bindingMap = pMapPanel->LookupBinding( kbMap->bindingname );
			if ( bindingMap && 
				 bindingMap->helpstring )
			{
				AnsiText( bindingMap->helpstring, ansi, sizeof( ansi ) );
				item->SetString( "Description", ansi );
			}
			
			item->SetPtr( "Item", kbMap );			

			sorted.Insert( item );
		}

		// Now try and find any "unbound" keys...
		int mappings = m->entries.Count();
		for ( j = 0; j < mappings; ++j )
		{
			KeyBindingMap_t *kbMap = &m->entries[ j ];

			// See if it's bound
			CUtlVector< BoundKey_t * > list;
			pMapPanel->LookupBoundKeys( kbMap->bindingname, list );
			if ( list.Count() > 0 )
				continue;

			// Not bound, add a placeholder entry
			// Create a new: blank item
			KeyValues *item = new KeyValues( "Item" );
			
			// fill in data
			char loc[ 128 ];
			Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );

			char ansi[ 256 ];
			AnsiText( loc, ansi, sizeof( ansi ) );

//.........这里部分代码省略.........
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:101,代码来源:KeyBindingHelpDialog.cpp


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