Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setAttribute(Qt::WA_AcceptTouchEvents);
    installEventFilter(ui->btn_left);
    installEventFilter(ui->btn_right);
    installEventFilter(ui->btn_up);

    connect(ui->btn_left, SIGNAL(Pressed()), this, SLOT(ClickLeft()));
    connect(ui->btn_left, SIGNAL(Released()), this, SLOT(ReleaseLeftRight()));
    connect(ui->btn_right, SIGNAL(Pressed()), this, SLOT(ClickRight()));
    connect(ui->btn_right, SIGNAL(Released()), this, SLOT(ReleaseLeftRight()));
    connect(ui->btn_up, SIGNAL(Pressed()), this, SLOT(ClickUp()));
    connect(ui->btn_up, SIGNAL(Released()), this, SLOT(ReleaseUp()));

    ui->btn_left->RotateImage(90);
    ui->btn_right->RotateImage(-90);
    ui->btn_up->RotateImage(180);

    engine = new GameEngine(this);
    engine->setCamera(ui->graphicsView);
    engine->InitScene(":/map/map_tank.tmx");

    ui->summary->setVisible(false);
    ui->summary->setText("Tanque\tDisparo\tAcerto\tMorte");

    connect(ui->toolButton, SIGNAL(pressed()), this, SLOT(SwapSummary()));
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// Name : HandleMouse() 
//-----------------------------------------------------------------------------
bool CSliderUI::HandleMouse( HWND hWnd, UINT uMsg, POINT mousePoint, INPUT_STATE inputstate, CTimer* timer )
{
	if( !m_bEnabled || !m_bVisible )
		return false;

	switch( uMsg )
	{
	case WM_LBUTTONDOWN:
	case WM_LBUTTONDBLCLK:
		{
			if ( Pressed(hWnd, mousePoint, inputstate, timer))
				return true;
		}break;

	case WM_LBUTTONUP:
		{
			if ( Released(hWnd, mousePoint))
				return true;
		}break;

	case WM_MOUSEMOVE:
		{
			if ( Dragged(mousePoint))
				return true;
		}break;

	case WM_MOUSEWHEEL:
		{
			if ( Scrolled( inputstate.nScrollAmount ) )
				return true;
		}break;
	};

	return false;
}
Exemplo n.º 3
0
bool DrawingTouch::update(QBrush *color)
{
    bool wasVisible = false;
    if (ellipse) {
        wasVisible = ellipse->isVisible();
        ellipse->setVisible(TrackingId() >= 0);
    }
    else {
        ellipse = scene->addEllipse(QRectF(Cx() - radius, Cy() - radius,
                                           2 * radius, 2 * radius));
    }
    if (TrackingId() >= 0) {
        QRectF rect = ellipse->rect();
        rect.moveCenter(QPointF(Cx(), Cy()));
        ellipse->setRect(rect);
        ellipse->setPen(Pressed() ? pressedPen : releasedPen);
        if (!wasVisible) {
            ellipse->setBrush(*color);
            ellipse->show();
            return true;
        }
   }

    return false;
}
Exemplo n.º 4
0
//When an event (e.g Click) occurs this method calls functions, via function pointers, that are assigned
//as event handlers
void Control::Update() 
{
	bool oldMouseIn = this->mouseIn;
	bool oldMouseUp = this->mouseUp;
	bool oldPressed = this->pressed;
	SetMouseIn();
	SetMouseUp();
	SetPressed(oldMouseUp);
	SetClicked(oldPressed);
	
	//check for mouse enetering/leaving
	if(oldMouseIn !=this->mouseIn && !this->clicked)
	{
		if(this->mouseIn && MouseEnter)
		{
			MouseEnter();
		}
		else
		{
			if(MouseLeave)
			{
				MouseLeave();
			}
		}
	}
	//check for pressed
	if(this->pressed && Pressed)
	{
		inPress = true;
		Pressed();
	}
	//check for click
	if(this->clicked && Clicked)
	{
		Clicked();
	}
	if(this->mouseUp)
	{
		if(oldMouseUp != this->mouseUp)
		{
			if(MouseUp)
			{
				MouseUp();
			}
			if(inPress && OutOfPress)
			{
				OutOfPress();
				inPress=false;
			}
		}
	}
	
	//loop through all child controls and update
	list<Control*>::iterator i;
	for(i = this->controls.begin(); i != this->controls.end(); i++) 
	{
		(*i)->Update();
	}
}
Exemplo n.º 5
0
bool FramelessMove::eventFilter(QObject *obj, QEvent *ev)
{
    if (obj == _monitor)
    {
        switch(ev->type())
        {
        case QEvent::MouseButtonPress:
        {
            QMouseEvent* event = (QMouseEvent*)ev;
            if(event->button() == Qt::LeftButton)
            {
                _offsetPos = event->globalPos();
                emit Pressed(_offsetPos);
                lButtonPress = true;
            }

            break;
        }
        case QEvent::MouseButtonRelease:
        {
            QMouseEvent* event = (QMouseEvent*)ev;
            if(event->button() == Qt::LeftButton && lButtonPress)
            {
                lButtonPress  = false;
                emit Release(event->globalPos());
            }

            break;
        }
        case QEvent::MouseMove:
        {

            if(lButtonPress)
            {
                QMouseEvent* event = (QMouseEvent*)ev;

                QPoint newPos = event->globalPos() - _offsetPos;
                emit Offset(newPos);

                if(_target)
                    _target->move(_target->pos() + newPos);

                _offsetPos = event->globalPos();


            }
            break;
        }
        default:
            break;

        }
    }

    return false;
}
Exemplo n.º 6
0
	bool Button::ProcessInput( bool active, int x, int y ) {
		if ( bounds.IsInside( Vec2f( (float)x, (float)y ) ) ) {
			inputOver = active;
			if ( active == false ) {
				Pressed();
			}
			return true;
		} else {
			inputOver = false;
			return false;
		}
		
	}
Exemplo n.º 7
0
	void KeyboardInputDevice::OnPressed(InputDeviceKey key)
	{
		Pressed(key);
	}
Exemplo n.º 8
0
void GamepadInputDevice::OnPressed(InputDeviceButton button)
{
    Pressed(button);
}
Exemplo n.º 9
0
/*
 FUNCTION:mousePressEvent
 grabs the mouse press event and sends it to its parent in a form that is readable
 */
void LabelButton::mousePressEvent(QMouseEvent *event){
    emit Pressed(this);
    event->accept();
}
Exemplo n.º 10
0
void Overlay::RenderConsole()
{
    const UINT ConsoleStartOffset = 3;
    const UINT ConsoleXSeparation = 210;
	const UINT ConsoleYSeparation = 13;

    if(Pressed(GetAsyncKeyState(KEY_F2)))
    {
        g_Globals.UsingNullPixelShader = !g_Globals.UsingNullPixelShader;
    }

    if(g_Globals.UsingOverlay)
	{
        if(Pressed(GetAsyncKeyState(KEY_DELETE)))
        {
            for(UINT PanelIndex = 0; PanelIndex < ConsolePanelCount; PanelIndex++)
            {
                ClearPanel(PanelIndex);
            }
            ClearMeshes();
        }

        D3D9Base::LPDIRECT3DDEVICE9 Device = NULL;
        _Font->GetDevice(&Device);

        D3D9Base::LPDIRECT3DSURFACE9 BackBufferSurface = NULL;
        Device->GetBackBuffer(0, 0, D3D9Base::D3DBACKBUFFER_TYPE_MONO, &BackBufferSurface);
        
        D3DSURFACE_DESC BackBufferDesc;
        BackBufferSurface->GetDesc(&BackBufferDesc);

        D3DVIEWPORT9 Viewport;
        Viewport.X = 0;
        Viewport.Y = 0;
        Viewport.Width = BackBufferDesc.Width;
        Viewport.Height = BackBufferDesc.Height;
        Viewport.MinZ = 0.0f;
        Viewport.MaxZ = 1.0f;
        Device->SetViewport(&Viewport);

        BackBufferSurface->Release();
        Device->Release();

		_Sprite->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE );

        for(UINT PanelIndex = 0; PanelIndex < ConsolePanelCount; PanelIndex++)
        {
            ConsolePanel &CurPanel = _Panels[PanelIndex];
		    UINT LineIndex = CurPanel.CurHeadPtr, YPos = ConsoleStartOffset;
		    UINT XPos = ConsoleStartOffset + ConsoleXSeparation * PanelIndex;
			bool FlipLineOrder = false;
			if(PanelIndex == ConsolePanelCount - 1)
			{
				FlipLineOrder = true;
				//YPos = ConsoleStartOffset + ConsoleYSeparation * CurPanel.Lines.Length();
				YPos = ConsoleStartOffset + ConsoleYSeparation;
				XPos = ConsoleStartOffset;
			}
			if(PanelIndex == ConsolePanelCount - 2)
			{
				XPos += 75;
			}

			bool Done = false;
		    while(!Done)
		    {
			    // TODO: add sprite support
				UINT ModifiedLineIndex = LineIndex;
				if(FlipLineOrder)
				{
					//ModifiedLineIndex = CurPanel.Lines.Length() - 1 - LineIndex;
				}
                const ConsoleLine &CurLine = CurPanel.Lines[ModifiedLineIndex];
                const String &CurText = CurLine.Text;
			    if(CurText.Length() > 0)
			    {
				    RECT Rect;
				    SetRect( &Rect, int(XPos), int(YPos), 0, 0 );
    				
                    //RGBColor Color = RGBColor::Black;
			        //_Font->DrawText(_Sprite, CurText.CString(), CurText.Length(), &Rect, DT_NOCLIP, D3D9Base::D3DXCOLOR(Color.r / 255.0f, Color.g / 255.0f, Color.b / 255.0f, 1.0f ));
			        //Rect.left -= 1;
			        //Rect.top -= 1;

                    RGBColor Color = CurLine.Color;
                    _Font->DrawText(_Sprite, CurText.CString(), CurText.Length(), &Rect, DT_NOCLIP, D3D9Base::D3DXCOLOR(Color.r / 255.0f, Color.g / 255.0f, Color.b / 255.0f, Color.a / 255.0f ));
			    }
			    LineIndex = Math::Mod(LineIndex + 1, CurPanel.Lines.Length());
			    YPos += ConsoleYSeparation;
			    if(LineIndex == Math::Mod(int(CurPanel.CurHeadPtr), CurPanel.Lines.Length()))
			    {
				    Done = true;
			    }
		    }
        }
		_Sprite->End();
	}
}