Esempio n. 1
0
TesseractWidget::TesseractWidget(Socket *_TheSocket,int PlayerNum,QString PlayerName,QGLWidget *parent) : QGLWidget(parent), ui(new Ui::TesseractWidget) {
    ui->setupUi(this);
    TheSocket=_TheSocket;
    QThread *tt=new QThread(TheSocket);
    TheSocket->moveToThread(tt);
    tt->start();
    connect(TheSocket,SIGNAL(readVariantMap(int,QString,quint16,const QVariantMap&)),this,SLOT(recvVariantMap(int,QString,quint16,const QVariantMap&)));
    connect(TheSocket,SIGNAL(sockDisconnect(int,QString,quint16)),this,SLOT(sockDisconnect(int,QString,quint16)));
    memset(KeyStatus,0,sizeof(KeyStatus));
    creatingblock=0;
    mousetracked=1;
    TheWorld=new World;
    connect(TheWorld,SIGNAL(log(const QString&)),this,SLOT(Log(const QString&)));
    connect(TheWorld,SIGNAL(releaseMouse()),this,SLOT(releaseMouse()));
    connect(TheWorld,SIGNAL(trackMouse()),this,SLOT(trackMouse()));
    connect(TheWorld,SIGNAL(renderText2D(Coordinate,const QString&)),this,SLOT(renderText2D(Coordinate,const QString&)));
    connect(TheWorld,SIGNAL(renderText3D(Coordinate,const QString&,int)),this,SLOT(renderText3D(Coordinate,const QString&,int)));
    Player tp;
    tp.Name=PlayerName;
    TheWorld->Players.insert(PlayerNum,tp);
    TheWorld->Myself=TheWorld->Players.find(PlayerNum);
    PM=new PluginManager;
    PM->ClientLoadFolder("plugins",TheWorld,TheSocket);
    QApplication::setOverrideCursor(Qt::BlankCursor);
    gt=new GameThread(TheWorld,KeyStatus,TheSocket);
    gt->start();
    GLTimer=new QTimer;
    GLTimer->start(16);
    connect(GLTimer,SIGNAL(timeout()),this,SLOT(DrawScene()));
    TheWorld->RegisterBlock(Block("Stone",Coordinate(.2,.2,.2),""));
    currentblocktype="Stone";
    QVariantMap qvm;
    qvm.insert("type","getbasic");
    emit TheSocket->sendVariantMap(qvm,-1);
}
Esempio n. 2
0
TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
    : WebView(webTab)
    , p_QupZilla(mainClass)
    , m_tabWidget(p_QupZilla->tabWidget())
    , m_page(0)
    , m_webTab(webTab)
    , m_menu(new Menu(this))
    , m_mouseTrack(false)
    , m_navigationVisible(false)
    , m_hasRss(false)
    , m_rssChecked(false)
{
    connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
    connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadingProgress(int)));
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));

    connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
    connect(this, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
    connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));

    connect(this, SIGNAL(statusBarMessage(QString)), p_QupZilla->statusBar(), SLOT(showMessage(QString)));

    connect(mApp->networkManager(), SIGNAL(wantsFocus(QUrl)), this, SLOT(getFocus(QUrl)));

    connect(p_QupZilla, SIGNAL(setWebViewMouseTracking(bool)), this, SLOT(trackMouse(bool)));

    // Tracking mouse also on tabs created in fullscreen
    trackMouse(p_QupZilla->isFullScreen());
}
Esempio n. 3
0
//--------------------------------------------------------------
// handle mouse release
void mgWinServices::mouseUp(
  UINT  uMsg,   
  WPARAM  wParam,
  LPARAM  lParam)
{
  int dx, dy;
  trackMouse(LOWORD(lParam), HIWORD(lParam), dx, dy);

  int released = 0;
  if (uMsg == WM_LBUTTONUP)
    released = MG_EVENT_MOUSE1_DOWN;
  else if (uMsg == WM_RBUTTONUP)
    released = MG_EVENT_MOUSE2_DOWN;
  else if (uMsg == WM_MBUTTONUP)
    released = MG_EVENT_MOUSE3_DOWN;

  m_eventFlags &= ~released;

  if (m_theApp != NULL)
  {
    // if button released away from last coords, it was dragged
    if (dx != 0 || dy != 0)
      m_theApp->appMouseDrag(dx, dy, m_eventFlags);

    m_theApp->appMouseUp(released, m_eventFlags);
  }
}
Esempio n. 4
0
//--------------------------------------------------------------
// handle mouse press
void mgWinServices::mouseDown(
  UINT  uMsg,   
  WPARAM  wParam,
  LPARAM  lParam)
{
  int dx, dy;
  trackMouse(LOWORD(lParam), HIWORD(lParam), dx, dy);

  int pressed = 0;
  if (uMsg == WM_LBUTTONDOWN)
    pressed = MG_EVENT_MOUSE1_DOWN;
  else if (uMsg == WM_RBUTTONDOWN)
    pressed = MG_EVENT_MOUSE2_DOWN;
  else if (uMsg == WM_MBUTTONDOWN)
    pressed = MG_EVENT_MOUSE3_DOWN;

  m_eventFlags |= pressed;

  // =-= if another button already down, should this be a dragged, not moved?
  if (dx != 0 || dy != 0 && m_theApp != NULL)
    m_theApp->appMouseMove(dx, dy, m_eventFlags);

  if (m_theApp != NULL)
    m_theApp->appMouseDown(pressed, m_eventFlags);

}
void createWindow(SystemEventHandler* handler)
{
    g_platform_data.m_handler = handler;

    HINSTANCE hInst = GetModuleHandle(NULL);
    WNDCLASSEX wnd;
    memset(&wnd, 0, sizeof(wnd));
    wnd.cbSize = sizeof(wnd);
    wnd.style = CS_HREDRAW | CS_VREDRAW;
    wnd.lpfnWndProc = msgProc;
    wnd.hInstance = hInst;
    wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
    wnd.lpszClassName = "lmxa";
    wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    RegisterClassExA(&wnd);
    g_platform_data.m_hwnd = CreateWindowA(
                                 "lmxa", "lmxa", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, hInst, 0);
    SetWindowTextA(g_platform_data.m_hwnd, "Lumix Studio");

    RAWINPUTDEVICE Rid;
    Rid.usUsagePage = 0x01;
    Rid.usUsage = 0x02;
    Rid.dwFlags = 0;
    Rid.hwndTarget = 0;
    RegisterRawInputDevices(&Rid, 1, sizeof(Rid));

    timeBeginPeriod(1);
    trackMouse();

    Lumix::Renderer::setInitData(g_platform_data.m_hwnd);
    ImGui::GetIO().ImeWindowHandle = g_platform_data.m_hwnd;
}
Esempio n. 6
0
//--------------------------------------------------------------
// handle mouse movement
void mgWinServices::mouseMove(
  WPARAM  wParam,
  LPARAM  lParam)
{
  int dx, dy;
  trackMouse(LOWORD(lParam), HIWORD(lParam), dx, dy);

  if (m_theApp != NULL)
  {
    if ((m_eventFlags & MG_EVENT_MOUSE_BUTTONS) != 0)
      m_theApp->appMouseDrag(dx, dy, m_eventFlags);
    else m_theApp->appMouseMove(dx, dy, m_eventFlags);
  }
}
Esempio n. 7
0
void
ValControlSegment::MouseDown(BPoint point)
{
	if (!parent()->IsEnabled())
		return;

	parent()->MakeFocus();

	// not left button?
	uint32 nButton;
	GetMouse(&point, &nButton);
	if (!(nButton & B_PRIMARY_MOUSE_BUTTON))
		return;

	// double click?
	bigtime_t doubleClickInterval;
	if (get_click_speed(&doubleClickInterval) < B_OK) {
		PRINT(("* ValControlSegment::MouseDown():\n"
			"  get_click_speed() failed."));
		return;
	}

	bigtime_t now = system_time();
	if (now - fLastClickTime < doubleClickInterval) {
		if(isTracking()) {
			setTracking(false);
			mouseReleased();
		}

		// hand off to parent control
		parent()->showEditField();
		fLastClickTime = 0LL;
		return;
	}
	else
		fLastClickTime = now;

		
	// engage tracking
	trackMouse(point, TRACK_VERTICAL);
}
Esempio n. 8
0
bool Input::translateGameInput() {

	if (_engineFlags & kEnginePauseJobs) {
		return false;
	}

	if (_hasDelayedAction) {
		// if walking is over, then take programmed action
		takeAction(_delayedActionZone);
		_hasDelayedAction = false;
		_delayedActionZone.reset();
		return true;
	}

	if (_mouseButtons == kMouseRightDown) {
		// right button down shows inventory
		enterInventoryMode();
		return true;
	}

	Common::Point mousePos;
	getAbsoluteCursorPos(mousePos);
	// test if mouse is hovering on an interactive zone for the currently selected inventory item
	ZonePtr z = _vm->hitZone(_activeItem._id, mousePos.x, mousePos.y);

	if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || (ACTIONTYPE(z) != kZoneCommand))) {
		walkTo(mousePos);
		return true;
	}

	trackMouse(z);
	if (!z) {
		return true;
	}

	if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || (ACTIONTYPE(z) == kZoneCommand))) {

		bool noWalk = z->_flags & kFlagsNoWalk;	// check the explicit no-walk flag
		if (_gameType == GType_BRA) {
			// action performed on object marked for self-use do not need walk in BRA
			noWalk |= ((z->_flags & kFlagsYourself) != 0);
		}

		if (noWalk) {
			takeAction(z);
		} else {
			// action delayed: if Zone defined a moveto position the character is programmed to move there,
			// else it will move to the mouse position
			_delayedActionZone = z;
			_hasDelayedAction = true;
			if (z->_moveTo.y != 0) {
				mousePos = z->_moveTo;
			}

			walkTo(mousePos);
		}

		_vm->beep();
		setArrowCursor();
		return true;
	}

	return true;
}
ushort TMenuView::execute()
{
    Boolean    autoSelect = False;
    menuAction action;
    char   ch;
    ushort result = 0;
    TMenuItem *itemShown = 0;
    TMenuItem *p;
    TMenuView *target;
    TRect  r;
    TEvent e;

    current = menu->deflt;
    do  {
        action = doNothing;
        getEvent(e);
        switch (e.what)
            {
            case  evMouseDown:
                if( mouseInView(e.mouse.where) || mouseInOwner(e) )
                    {
                    trackMouse(e);
                    if( size.y == 1 )
                        autoSelect = True;
                    }
                else
                    action =  doReturn;
                break;
            case  evMouseUp:
                trackMouse(e);
                if( mouseInOwner(e) )
                    current = menu->deflt;
                else if( current != 0 && current->name != 0 )
                    action = doSelect;
                else
                    action = doReturn;
                break;
            case  evMouseMove:
                if( e.mouse.buttons != 0 )
                    {
                    trackMouse(e);
                    if( !(mouseInView(e.mouse.where) || mouseInOwner(e)) &&
                        mouseInMenus(e) )
                        action = doReturn;
                    }
                break;
            case  evKeyDown:
                switch( ctrlToArrow(e.keyDown.keyCode) )
                    {
                    case  kbUp:
                    case  kbDown:
                        if( size.y != 1 )
                            trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbDown));
                        else if( e.keyDown.keyCode == kbDown )
                            autoSelect =  True;
                        break;
                    case  kbLeft:
                    case  kbRight:
                        if( parentMenu == 0 )
                            trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbRight));
                        else
                            action =  doReturn;
                        break;
                    case  kbHome:
                    case  kbEnd:
                        if( size.y != 1 )
                            {
                            current = menu->items;
                            if( e.keyDown.keyCode == kbEnd )
                                trackKey(False);
                            }
                        break;
                    case  kbEnter:
                        if( size.y == 1 )
                            autoSelect =  True;
                        action = doSelect;
                        break;
                    case  kbEsc:
                        action = doReturn;
                        if( parentMenu == 0 || parentMenu->size.y != 1 )
                            clearEvent(e);
                        break;
                    default:
                        target = this;
                        ch = getAltChar(e.keyDown.keyCode);
                        if( ch == 0 )
                            ch = e.keyDown.charScan.charCode;
                        else
                            target = topMenu();
                        p = target->findItem(ch);
                        if( p == 0 )
                            {
                            p = topMenu()->hotKey(e.keyDown.keyCode);
                            if( p != 0 && commandEnabled(p->command) )
                                {
                                result = p->command;
                                action = doReturn;
                                }
                            }
                        else if( target == this )
                            {
                            if( size.y == 1 )
                                autoSelect = True;
                            action = doSelect;
                            current = p;
                            }
                        else if( parentMenu != target ||
                                 parentMenu->current != p )
                                action = doReturn;
                    }
                break;
            case  evCommand:
                if( e.message.command == cmMenu )
                    {
                    autoSelect = False;
                    if (parentMenu != 0 )
                        action = doReturn;
                    }
                else
                    action = doReturn;
                break;
            }

        if( itemShown != current )
            {
            itemShown =  current;
            drawView();
            }

        if( (action == doSelect || (action == doNothing && autoSelect)) &&
            current != 0 &&
            current->name != 0 )
                if( current->command == 0 )
                    {
                    if( (e.what & (evMouseDown | evMouseMove)) != 0 )
                        putEvent(e);
                    r = getItemRect( current );
                    r.a.x = r.a.x + origin.x;
                    r.a.y = r.b.y + origin.y;
                    r.b = owner->size;
                    if( size.y == 1 )
                        r.a.x--;
                    target = topMenu()->newSubView(r, current->subMenu,this);
                    result = owner->execView(target);
                    destroy( target );
                    }
                else if( action == doSelect )
                    result = current->command;

        if( result != 0 && commandEnabled(result) )
            {
            action =  doReturn;
            clearEvent(e);
            }
        } while( action != doReturn );

    if( e.what != evNothing &&
        (parentMenu != 0 || e.what == evCommand))
            putEvent(e);
    if( current != 0 )
        {
        menu->deflt = current;
        current = 0;
        drawView();
        }
    return result;
}
Esempio n. 10
0
void reViewport::render()
{
	reRadial::shared()->camera = camera;
	if (size.x*size.y<100) return;
	glEnable(GL_SCISSOR_TEST);	
	glScissor(position.x, position.y, size.x, size.y);
	glViewport(position.x, position.y, size.x, size.y);
	camera->viewport(reVec4(position.x, position.y, size.x, size.y));

	if (!tracking && trackMouse())
	{
		QPoint p = widget->mapFromGlobal(QCursor::pos());
		reNode* node = querySelected(surface);				
		assert(!node || node == surface);
		if (!node)
		{
			node = querySelected(widget->helperNode);
		}
		if (!node)
		{
			reNode* anode = dynamic_cast<reNode*>(widget->model()->root());
			node = querySelected(anode);
		}
	
		overNode(node);
		//qDebug() << (node ? node->name().c_str() : "none");
		//qDebug() << node;
	}

	glClearColor(0.30f, 0.42f, 0.64f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
	emit prerendering(this);
	camera->apply();
	glPushMatrix();
	//glTranslatef(0,-0.1f, 0);
	glDisable(GL_TEXTURE_2D);
	glColor4f(0.15f, 0.15f, 0.15f, 1.0f);
	//drawGrid(100, .5f);
	glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
	glDisable(GL_DEPTH_TEST);
	glLineWidth(1);
	drawGrid(50, 1.0f);
	glLineWidth(1);	
	glEnable(GL_DEPTH_TEST);

	glPushAttrib(GL_ENABLE_BIT);
	renderer->render(camera, (reNode*)widget->model()->root());
	glPopAttrib();

	emit rendering(this);

	glClear(GL_DEPTH_BUFFER_BIT);
	widget->helperNode->render();

	rePhysics* phy = ((reCollection*)widget->model()->root())->findInSupers<rePhysics>();
	
	if (phy)
	{
		phy->dynamicsWorld->debugDrawWorld();
	}

	surface->size(size);
	reMat4 t = glm::translate(reMat4(), reVec3(10, size.y - label->font()->lineHeight - 10, 0));
	reMat4 s = glm::scale(reMat4(), reVec3(0.8, 0.8, 0.8));
	surface->transform(reTransform(t*s));
	surface->render();	
	
	bottomSurface->size(size);
	t = glm::translate(reMat4(), reVec3(10, label->font()->lineHeight - 10, 0));
	s = glm::scale(reMat4(), reVec3(0.8, 0.8, 0.8));
	bottomLabel->text(QString("fps:%1").arg(ceil(widget->fps)).toStdString());
	bottomSurface->transform(reTransform(t*s));
	bottomSurface->render();
	
	glPopMatrix();
}
Esempio n. 11
0
static LRESULT WINAPI msgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (!g_platform_data.m_handler) return DefWindowProc(hWnd, msg, wParam, lParam);

    switch (msg)
    {
    case WM_LBUTTONUP:
        g_platform_data.m_handler->onMouseButtonUp(SystemEventHandler::MouseButton::LEFT);
        break;
    case WM_LBUTTONDOWN:
        g_platform_data.m_handler->onMouseButtonDown(SystemEventHandler::MouseButton::LEFT);
        break;
    case WM_RBUTTONDOWN:
        g_platform_data.m_handler->onMouseButtonDown(SystemEventHandler::MouseButton::RIGHT);
        break;
    case WM_RBUTTONUP:
        g_platform_data.m_handler->onMouseButtonUp(SystemEventHandler::MouseButton::RIGHT);
        break;
    case WM_MBUTTONUP:
        g_platform_data.m_handler->onMouseButtonUp(SystemEventHandler::MouseButton::MIDDLE);
        break;
    case WM_MBUTTONDOWN:
        g_platform_data.m_handler->onMouseButtonDown(SystemEventHandler::MouseButton::MIDDLE);
        break;
    case WM_MOUSEWHEEL:
        g_platform_data.m_handler->onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
        break;
    case WM_INPUT:
        handleRawInput(lParam);
        break;
    case WM_MOUSEMOVE:
    {
        if (!g_platform_data.m_is_mouse_tracked) trackMouse();
    }
    break;
    case WM_ERASEBKGND:
        return 1;
    case WM_MOVE:
    case WM_SIZE:
    {
        RECT rect;
        GetClientRect(g_platform_data.m_hwnd, &rect);
        g_platform_data.m_handler->onWindowTransformed(
            rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
    }
    break;
    case WM_CLOSE:
        PostQuitMessage(0);
        break;
    case WM_MOUSELEAVE:
    {
        g_platform_data.m_is_mouse_tracked = false;
        g_platform_data.m_handler->onMouseLeftWindow();
    }
    break;
    case WM_KEYUP:
    case WM_SYSKEYUP:
        g_platform_data.m_handler->onKeyUp(getKeyFromSystem((int)wParam));
        break;
    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
        g_platform_data.m_handler->onKeyDown(getKeyFromSystem((int)wParam));
        break;
    case WM_CHAR:
        g_platform_data.m_handler->onChar((int)wParam);
        break;
    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}