Ejemplo n.º 1
0
void CClientMain::SendMouseMsg( int x,int y ,int MouseStatus)
{
	if (m_bTcpConect && m_bCtrlPermission)
	{
		RECT rcDisplay;
		if (m_dlgDisplay.GetSafeHwnd() != NULL)
		{
			m_dlgDisplay.GetWindowRect(&rcDisplay);
			int sbvPos = m_dlgDisplay.GetScrollPos(SB_VERT);
			int sbhPos = m_dlgDisplay.GetScrollPos(SB_HORZ);
			int SeverMouseX = ((x + sbhPos - rcDisplay.left - m_ScreenDisplayer.GetWinWidth()/2 + m_ScreenDisplayer.GetDisplayWidth()/2) * m_ScreenDisplayer.GetSeverWidth()) / m_ScreenDisplayer.GetDisplayWidth() ;
			int SeverMouseY = ((y + sbvPos - rcDisplay.top - m_ScreenDisplayer.GetWinHeigth()/2 + m_ScreenDisplayer.GetDisplayHeight()/2) * m_ScreenDisplayer.GetServerHeight()) / m_ScreenDisplayer.GetDisplayHeight() ;
			if (SeverMouseX <=  m_ScreenDisplayer.GetSeverWidth()&&
				SeverMouseX >= 0 &&
				SeverMouseY <=  m_ScreenDisplayer.GetServerHeight()&&
				SeverMouseY >= 0 )
			{
				//TODO:将计算好的SverMouseX和SeverMouseY打包消息添加到消息队列中
				MouseMsg* pMousePos = new MouseMsg;
				pMousePos->PacketMsg(SeverMouseX,SeverMouseY,MouseStatus);
				m_tcpClien.send(*pMousePos);
				delete pMousePos;
			}
		}
	}
	
	
}
Ejemplo n.º 2
0
	bool TestStage::onMouse( MouseMsg const& msg )
	{
		if ( !BaseClass::onMouse( msg ) )
			return false;

		GameWindow& window = Global::getDrawEngine()->getWindow();

		if ( msg.onLeftDown() )
		{
			Light light;
			light.pos = Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y  );
			light.color = Color( float( ::Global::Random() ) / RAND_MAX  , 
				                 float( ::Global::Random() ) / RAND_MAX  , 
				                 float( ::Global::Random() ) / RAND_MAX  );
			lights.push_back( light );
		}
		else if ( msg.onRightDown() )
		{
			Block block;
			block.setBox( Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y  ) , Vec2f( 50 , 50 ) );
			blocks.push_back( block );
		}
		else if ( msg.onMoving() )
		{
			if ( !lights.empty() )
			{
				lights.back().pos = Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y  );
			}
		}

		return true;
	}
Ejemplo n.º 3
0
bool Game::onMouse( MouseMsg const& msg )
{
	mMousePos = msg.getPos();

	if ( !GUISystem::getInstance().mManager.procMouseMsg( msg ) )
	{
		if ( !msg.onMoving() )
			return true;
	}
	mStageStack.back()->onMouse( msg );
	return true;
}
Ejemplo n.º 4
0
bool CPlayButton::onMouseMsg( MouseMsg const& msg )
{
	if ( msg.onLeftDown() )
	{
		if ( m_playInfo.type == PT_NULL )
			return false;

		sDragIcon->removeRectArea( 0 );
		setupPlayIcon( sDragIcon );
		sDragIcon->show( true );
		
		Vec3D pos = mSprite->getWorldPosition();
		pos[2] = -8000;
		sDragIcon->setWorldPosition( pos );

		CUISystem::getInstance().captureMouse( this );
	}
	else if ( msg.onLeftUp() )
	{
		CUISystem::getInstance().releaseMouse();
		sDragIcon->show( false );

		CWidget* ui = CUISystem::getInstance().hitTest( msg.getPos() );

		if ( ui != this )
		{
			if ( ui )
			{
				CPlayButton* playbutton = dynamic_cast< CPlayButton* >( ui ) ;
				if ( playbutton )
					playbutton->onInputItem( this );
			}
			else
			{
				if ( m_cbType ==  CBT_FAST_PLAY_BAR )
					setFunction( NULL , NULL );
			}
			// skip OnClick
			return false;
		}
	}

	if ( msg.isLeftDown() && msg.isDraging() )
	{
		if ( sDragIcon->isShow() )
		{
			Vec2i const& size = getSize();
			MouseMsg const& msg = CUISystem::getInstance().getLastMouseMsg();
			sDragIcon->setWorldPosition( Vec3D( msg.x() - size.x/2 , msg.y() - size.y/2 , -8000 ) );
		}
	}

	CButtonUI::onMouseMsg( msg );

	return false;
}
Ejemplo n.º 5
0
bool SampleBase::onMouse( MouseMsg& msg )
{
	if ( msg.onLeftDown() )
	{
		mLastDownPos = msg.getPos();
	}
	else if ( msg.isDraging() && msg.isLeftDown() )
	{
		Quaternion q;
		q.setMatrix( mMainCamera->getLocalTransform() );
		Vector3 rot = q.getEulerZYX();

		rot.z += 0.01 *( mLastDownPos.x - msg.getPos().x );
		rot.x += 0.01 *( mLastDownPos.y - msg.getPos().y );

		Quaternion q2;
		q2.setEulerZYX( rot.z , rot.y , rot.x );

		Matrix4 mat;
		mat.setTransform( mMainCamera->getLocalPosition() , q2 );

		mMainCamera->setLocalTransform( mat );
		//mMainCamera->rotate( CF_AXIS_Y , 0.01 *( mLastDownPos.x - msg.getPos().x ) , CFTO_LOCAL );
		//mMainCamera->rotate( CF_AXIS_X , -0.01 *( mLastDownPos.y - msg.getPos().y ) , CFTO_LOCAL );
		mLastDownPos = msg.getPos();
	}
	return true;
}
Ejemplo n.º 6
0
bool GFrame::onMouseMsg( MouseMsg const& msg )
{
	BaseClass::onMouseMsg( msg );

	static int x , y;
	static bool needMove = false;
	if ( msg.onLeftDown() )
	{
		setTop();

		if ( msg.getPos().y > getWorldPos().y &&
			 msg.getPos().y < getWorldPos().y + TopSideHeight )
		{
			x = msg.x();
			y = msg.y();

			getManager()->captureMouse( this );

			needMove = true;
		}
	}
	else if ( msg.onRightDown() )
	{
		if ( msg.getPos().y > getWorldPos().y &&
			 msg.getPos().y < getWorldPos().y + TopSideHeight )
		{ 
			mbMiniSize = !mbMiniSize;
			if ( mbMiniSize )
			{
				mPrevSize = getSize();
				setSize( Vec2i( mPrevSize.x , TopSideHeight ) );
				mClipEnable = true;
			}
			else
			{
				setSize( mPrevSize );
				mClipEnable = false;
			}
		}

	}
	else if ( msg.onLeftUp() )
	{
		needMove = false;
		getManager()->releaseMouse();
	}
	if ( needMove )
	{
		if ( msg.isLeftDown() && msg.isDraging() )
		{
			Vec2i pos = getPos() +Vec2i( msg.x() - x , msg.y() - y );
			setPos( pos );
			x = msg.x();
			y = msg.y();
		}
	}
	return false;
}
Ejemplo n.º 7
0
bool TUIManager<T>::procMouseMsg( MouseMsg const& msg )
{
    PROFILE_ENTRY("UI System");

    bool result = true;

    mProcessingMsg = true;

    mMouseMsg = msg;

    TUICore<T>* ui;
    if ( mUICapture )
    {
        ui = mUICapture;
    }
    else if ( mUIModal )
    {
        if (  mUIModal->hitTest( mMouseMsg.getPos() ) )
            ui = mUIModal->hitTestChildren( mMouseMsg.getPos() - mUIModal->getPos() );
        else
            ui = NULL;
    }
    else
    {
        ui = hitTest( mMouseMsg.getPos() );
    }

    mUILastMouseMsg = ui;

    {
        PROFILE_ENTRY("Msg Process");

        if (  msg.onLeftDown() )
        {
            if ( mUIFocus != ui )
            {
                if ( mUIFocus )
                    mUIFocus->focus( false );

                mUIFocus = ui;

                if ( ui )
                    ui->focus( true );
            }
        }
        else if ( msg.onMoving() )
        {
            if ( mUIMouse != ui )
            {
                if ( mUIMouse )
                    mUIMouse->mouseOverlap( false );

                mUIMouse = ui;

                if ( ui )
                    ui->mouseOverlap( true );
            }
        }


        if ( ui )
        {
            if ( msg.isDraging() && ui != mUIFocus )
            {
                result = ( mUIFocus == NULL ) ;
            }
            else
            {
                result = ui->onMouseMsg( mMouseMsg );
                while ( result && ui->checkFlag( UF_PARENT_MOUSE_EVENT ) )
                {
                    if ( ui->getParent() == &mRoot )
                        break;
                    ui->_removeFlag( UF_PARENT_MOUSE_EVENT );

                    ui = static_cast< T* >( ui->getParent() );
                    result = ui->onMouseMsg( mMouseMsg );
                    mUILastMouseMsg = ui;
                }
            }

            //while ( bool still = ui->onMouseMsg( mMouseMsg ) )
            //{
            //	ui = ui->getParent();
            //	if ( !still || ui == getRoot() )
            //		return still;
            //}
        }
    }

    mProcessingMsg = false;

    cleanupDestroyUI();
    return result;
}