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


C++ Mover::setSelected方法代码示例

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


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

示例1: update

void ForceGroupBar::update( )
{
	bool bSelect = userInput->isLeftClick();
	bool bCommand = useLeftRightMouseProfile ? userInput->isRightClick() : userInput->isLeftClick();
	bool shiftDn = userInput->getKeyDown( KEY_LSHIFT ) ? true : false;
	bool bCamera = useLeftRightMouseProfile ? (userInput->isLeftDoubleClick()) : (userInput->isRightClick() && !userInput->isRightDrag());
	bool bForceGroup = useLeftRightMouseProfile ? (userInput->isLeftDoubleClick()) : userInput->isLeftDoubleClick();
	
	if ( bCamera )
		bSelect = 0;

	Stuff::Vector2DOf<long> screen;
	screen.x = userInput->getMouseX();
	screen.y = userInput->getMouseY();

	 if ( screen.x > FORCEGROUP_LEFT && screen.x < FORCEGROUP_LEFT + FORCEGROUP_WIDTH
		  && screen.y > FORCEGROUP_TOP )
	 {
		 if ( ControlGui::instance->isSelectingInfoObject() )
			userInput->setMouseCursor( mState_INFO );
		 else if ( ControlGui::instance->getRepair() )
			 userInput->setMouseCursor( mState_XREPAIR );
		 else if ( MissionInterfaceManager::instance()->hotKeyIsPressed( EJECT_COMMAND_INDEX ) )
			 userInput->setMouseCursor( mState_EJECT );
		 else
			userInput->setMouseCursor( mState_NORMAL );

		helpTextID = IDS_FORCEGROUP_BAR_DESC;
		helpTextHeaderID = IDS_FORCEGROUP_BAR;
	 }



	// unselect all if appropriate
	if ( bSelect && !shiftDn && inRegion(screen.x, screen.y) 
		&& !ControlGui::instance->isSelectingInfoObject() && (!ControlGui::instance->getRepair()
		&& !MissionInterfaceManager::instance()->hotKeyIsPressed( EJECT_COMMAND_INDEX )
		&& !ControlGui::instance->getGuard()
		|| useLeftRightMouseProfile) )
	{
		Team* pTeam = Team::home;
		for ( int i = 0; i < pTeam->rosterSize; ++i )
		{
			Mover* pMover = (Mover*)pTeam->getMover( i );
			if (pMover->getCommander()->getId() == Commander::home->getId())
			{
				pMover->setSelected( false );
			}
		}
	}

	
	// remove dead mechs
	for ( int t = 0; t < iconCount; ++t )
	{
		if ( (icons[t]->unit->isDestroyed() || icons[t]->unit->isDisabled()) && !icons[t]->unit->recoverBuddyWID )
		{
			if ( !icons[t]->isAnimatingDeath() )
				icons[t]->beginDeathAnimation();
			if ( icons[t]->deathAnimationOver() || icons[t]->unit->causeOfDeath == POWER_USED_UP )
			{
				delete icons[t];
				iconCount --;
				memmove( &icons[t], &icons[t] + 1, (iconCount - t) * sizeof (ForceGroupIcon*) );
				icons[iconCount] = 0;
			}
		}
	}

	qsort( icons, iconCount, sizeof( ForceGroupIcon* ), ForceGroupIcon::sort );

	for ( int i = 0; i < iconCount; i++ )
	{
		icons[i]->setLocationIndex( i );
	}
	

	for ( i = 0; i < iconCount; ++i )
	{
		if ( icons[i]->inRegion( screen.x, screen.y ) )
		{
			icons[i]->unit->setTargeted(true); 
			if ( ControlGui::instance->getRepair() )
			{
				if ( !MissionInterfaceManager::instance()->canRepair(icons[i]->unit ) )
				{
					userInput->setMouseCursor( mState_XREPAIR );
				
					// need to go back and unselect everything
					if ( bSelect  )
					{
						if ( !shiftDn )
						{
							Team* pTeam = Team::home;
							for ( int j = 0; j < pTeam->rosterSize; ++j )
							{
								Mover* pMover = (Mover*)pTeam->getMover( j );
								if (pMover->getCommander()->getId() == Commander::home->getId())
								{
									pMover->setSelected( false );
//.........这里部分代码省略.........
开发者ID:wolfman-x,项目名称:mechcommander2,代码行数:101,代码来源:forcegroupbar.cpp


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