void update_left_button_released(void) { left_button_released = 0; left_button_double_clicked = 0; if ( lbDisplay.LeftButton ) { left_button_held = 1; left_button_held_x = GetMouseX(); left_button_held_y = GetMouseY(); } if (left_button_held) { if (!lbDisplay.MLeftButton) { left_button_released = 1; left_button_held = 0; left_button_released_x = GetMouseX(); left_button_released_y = GetMouseY(); if ( left_button_click_space_count < 5 ) { left_button_double_clicked = 1; left_button_double_clicked_x = left_button_released_x; left_button_double_clicked_y = left_button_released_y; } left_button_click_space_count = 0; } } else { if (left_button_click_space_count < LONG_MAX) left_button_click_space_count++; } }
void update_right_button_released(void) { right_button_released = 0; right_button_double_clicked = 0; if (lbDisplay.RightButton) { right_button_held = 1; right_button_held_x = GetMouseX(); right_button_held_y = GetMouseY(); } if ( right_button_held ) { if ( !lbDisplay.MRightButton ) { right_button_released = 1; right_button_held = 0; right_button_released_x = GetMouseX(); right_button_released_y = GetMouseY(); if (right_button_click_space_count < 5) { right_button_double_clicked = 1; right_button_double_clicked_x = right_button_released_x; right_button_double_clicked_y = right_button_released_y; } right_button_click_space_count = 0; } } else { if (right_button_click_space_count < LONG_MAX) right_button_click_space_count++; } }
void PathFindApp::OnLeftButtonUp() { if (IsKeyDown(HK_LCONTROL)) m_from.Set(GetMouseX(),GetMouseY()); else if (IsKeyDown(HK_RCONTROL)) m_to.Set(GetMouseX(),GetMouseY()); else m_map.Set(GetMouseX(),GetMouseY(),this->IsShiftKeyDown() ? 1:0); }
void Sample2DScene::update(void) { if (Keyboard::getInstance().getKey(27)==KEY_STATUS::KEY_PUSH) { exit(0); } if (Keyboard::getInstance().getKey(GLUT_KEY_DOWN)==KEY_STATUS::KEY_PUSH) { indexY++; } if (Keyboard::getInstance().getKey(GLUT_KEY_UP)==KEY_STATUS::KEY_PUSH) { indexY--; } if (Keyboard::getInstance().getKey(GLUT_KEY_RIGHT)==KEY_STATUS::KEY_PUSH) { indexX++; } if (Keyboard::getInstance().getKey(GLUT_KEY_LEFT)==KEY_STATUS::KEY_PUSH) { indexX--; } indexX += 4; indexX %= 4; indexY += 4; indexY %= 4; if (GetRightButton()==MOUSE_BUTTON_STATUS::MOUSE_BUTTON_PUSH) { new Effect(GetMouseX(), GetMouseY()); } if (GetLeftButton()==MOUSE_BUTTON_STATUS::MOUSE_BUTTON_PUSH) { new Flare(GetMouseX(), GetMouseY()); } if (rand()%5==0) { new Smoke(GetMouseX(), GetMouseY()); } if (Keyboard::getInstance().getKey('z')==KEY_STATUS::KEY_PUSH) { isEndFlg = true; new Fadeout(120); } if (Keyboard::getInstance().getKey('x')==KEY_STATUS::KEY_PUSH) { new Talk(2); } //printf("x = %d, y = %d\n", GetMouseX(), GetMouseY()); if (GetLeftButton() == MOUSE_BUTTON_PUSH) { printf("左クリックされた\n"); } if (GetRightButton() == MOUSE_BUTTON_PUSH) { printf("右クリックされた\n"); } GameObjectManager::getInstance().updateAll(); char *text = textbox->update(); if (text != NULL) { chatLog->add("", text); textbox->clearLog(); } chatLog->update(); }
void OnUpdate(float dt) { if (IsKeyDown('W')) walk(30 * dt); else if (IsKeyDown('S')) walk(-30 * dt); if (IsKeyDown('A')) strafe(30 * dt); else if (IsKeyDown('D')) strafe(-30 * dt); float calcedX = GetMouseX() - lastMouseX, calcedY = GetMouseY() - lastMouseY; lastMouseX = GetMouseX(); lastMouseY = GetMouseY(); if (calcedY < 0) pitch(0.5f * dt * abs(calcedY)); else if (calcedY > 0) pitch(-0.5f * dt * abs(calcedY)); if (calcedX > 0) yaw(0.5f * dt * abs(calcedX)); else if (calcedX < 0) yaw(-0.5f * dt * abs(calcedX)); }
Vector3<float> getMousePosition() { double modelview[16]; glGetDoublev(GL_MODELVIEW_MATRIX, modelview); double projection[16]; glGetDoublev(GL_PROJECTION_MATRIX, projection); int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); float z; double objX; double objY; double objZ; glReadPixels(GetMouseX(),getWindowHeight() - GetMouseY(),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&z); gluUnProject(GetMouseX(),getWindowHeight() - GetMouseY(),z,modelview,projection,viewport,&objX,&objY,&objZ); return Vector3<float>(objX, objY, objZ); }
/* * Function: GetTrianglePoints * Usage: GetTrianglePoints(tri) * ----------------------------------- * This function watches the user click three points on the Graphics Console. * The function notes the location of those points by loading the 'tri' array * with three pointT structs. * The function connects the dots to create a triangle on the screen. * Graphics should already be initialized. We assume working with triangles, * but the constant nPOINTS will let us see if this works for four points. */ void GetTrianglePoints(pointT tri[]) { int pt_ct = 0; while ( pt_ct < nPOINTS ) { //cout << "got to this point" << endl; WaitForMouseDown(); WaitForMouseUp(); tri[pt_ct].xp = GetMouseX(); tri[pt_ct].yp = GetMouseY(); if ( pt_ct == 0 ) { MovePen(tri[0].xp, tri[0].yp); } else { DrawLine( (tri[pt_ct].xp - tri[pt_ct - 1].xp ), (tri[pt_ct].yp - tri[pt_ct - 1].yp ) ); } UpdateDisplay(); pt_ct ++; } // Connect the third and first points of the triangle with lines DrawLine( (tri[0].xp - tri[nPOINTS - 1].xp ), (tri[0].yp - tri[nPOINTS - 1].yp ) ); UpdateDisplay(); }
coord GetLocationChosenByUser(void) { coord position; int i=0; double x,y; do { WaitForMouseDown(); x=GetMouseX(); y=GetMouseY(); if (LG<x && x<16*LG && GetWindowHeight()-11.3*LG<y && y<GetWindowHeight()-1.3*LG) { i=1; for (i=16;i>=1;i--) { if (x>i*LG) { position.col=i-1; break; } } for (i=2;i<=12;i++) { if ((y-0.7*LG)>(GetWindowHeight()-i*LG)) { position.row=i-3; break; } } return position; } } while (i==0); }
void confirmComplete(double x1, double y1, double x2, double y2)//确认完成按钮函数 { MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); double distance1; double distance2; double X,Y; SetPenColor(RED); distance1=(x2-x1-GetStringWidth("输入完成"))/2; distance2=(y1-y2-GetStringWidth("输"))/2; MovePen(x1+distance1,y1-distance2); DrawString("输入完成"); SetPenColor(BLACK); while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { EatEgg();//吃掉完成键和信息输入框的蛋 break; } } } }
void ReserveCurrentCell(void) { unsigned char MouseX = GetMouseX(); unsigned char MouseY = GetMouseY(); ReserveCell(MouseX,MouseY); }
void createTriangle(Point &v1, Point &v2, Point &v3) { int count = 0; while(count < 3) { WaitForMouseDown(); WaitForMouseUp(); double X = GetMouseX(); double Y = GetMouseY(); /* log points */ if (count == 0) { MovePen(X, Y); v1.X = X; v1.Y = Y; } else if (count == 1) { v2.X = X; v2.Y = Y; DrawLine(v2.X - v1.X, v2.Y - v1.Y); } else { v3.X = X; v3.Y = Y; DrawLine(v3.X - v2.X, v3.Y - v2.Y); // close triangle DrawLine(v1.X - v3.X, v1.Y - v3.Y); } count++; } }
pointT GetMouseClick() { WaitForMouseDown(); WaitForMouseUp(); pointT pt; pt.x = int(GetMouseX()); pt.y = int(GetMouseY()); return pt; }
void update_busy_doing_gui_on_menu(void) { int gidx; gidx = point_is_over_gui_menu(GetMouseX(), GetMouseY()); if (gidx == -1) busy_doing_gui = 0; else busy_doing_gui = 1; }
/* Function: GetMouseClick * Usage: loc = GetMouseClick(); * ------------------------------ * Waits for the user to click somewhere on the graphics window * and returns the coordinate of where the click took place. */ coordT GetMouseClick() { coordT where; WaitForMouseDown(); WaitForMouseUp(); where.x = GetMouseX(); where.y = GetMouseY(); return where; }
/** * Returns if the mouse is over "pannel map" - the circular minimap area on top left. * @param x Pannel map circle start X coordinate. * @param y Pannel map circle start Y coordinate. * @return */ TbBool mouse_is_over_pannel_map(ScreenCoord x, ScreenCoord y) { long cmx,cmy; long px,py; cmx = GetMouseX(); cmy = GetMouseY(); px = (cmx-(x+PANNEL_MAP_RADIUS)); py = (cmy-(y+PANNEL_MAP_RADIUS)); return (LbSqrL(px*px + py*py) < PANNEL_MAP_RADIUS); }
void PathfinderEventLoop() { while (true) { WaitForMouseDown(); int downButtonIndex = FindButtonIndex(GetMouseX(), GetMouseY()); if (downButtonIndex != -1) { buttons[downButtonIndex].highlighted = true; DrawButton(buttons[downButtonIndex]); UpdateDisplay(); } bool isDown = true; while (isDown) { isDown = MouseButtonIsDown(); int index = FindButtonIndex(GetMouseX(), GetMouseY()); if (index != downButtonIndex) { if (downButtonIndex != -1) { buttons[downButtonIndex].highlighted = false; DrawButton(buttons[downButtonIndex]); } if (index != -1 && isDown) { buttons[index].highlighted = true; DrawButton(buttons[index]); } downButtonIndex = index; UpdateDisplay(); } } if (downButtonIndex != -1) { buttons[downButtonIndex].highlighted = false; DrawButton(buttons[downButtonIndex]); UpdateDisplay(); buttons[downButtonIndex].callback->apply(); } else { pointT pt; pt.x = int(GetMouseX()); pt.y = int(GetMouseY()); if (pt.y < WINDOW_HEIGHT && clickHook != NULL) { clickHook->apply(pt); } } } }
/** * Returns if the mouse is over "pannel map" - the circular minimap area on top left. * @param x Pannel map circle start X coordinate. * @param y Pannel map circle start Y coordinate. * @return */ TbBool mouse_is_over_pannel_map(ScreenCoord x, ScreenCoord y) { long cmx,cmy; long px,py; cmx = GetMouseX(); cmy = GetMouseY(); int units_per_px; units_per_px = (16*status_panel_width + 140/2) / 140; px = (cmx-(x+PANNEL_MAP_RADIUS*units_per_px/16)); py = (cmy-(y+PANNEL_MAP_RADIUS*units_per_px/16)); return (LbSqrL(px*px + py*py) < PANNEL_MAP_RADIUS*units_per_px/16); }
FReply FSceneViewport::OnMouseMove( const FGeometry& InGeometry, const FPointerEvent& InMouseEvent ) { // Start a new reply state CurrentReplyState = FReply::Handled(); if( !InMouseEvent.GetCursorDelta().IsZero() ) { UpdateCachedMousePos( InGeometry, InMouseEvent ); UpdateCachedGeometry(InGeometry); const bool bViewportHasCapture = ViewportWidget.IsValid() && ViewportWidget.Pin()->HasMouseCapture(); if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue ) { // Switch to the viewport clients world before processing input FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient ); if( bViewportHasCapture ) { ViewportClient->CapturedMouseMove( this, GetMouseX(), GetMouseY() ); } else { ViewportClient->MouseMove( this, GetMouseX(), GetMouseY() ); } if( bViewportHasCapture ) { // Accumulate delta changes to mouse movment. Depending on the sample frequency of a mouse we may get many per frame. //@todo Slate: In directinput, number of samples in x/y could be different... const FVector2D CursorDelta = InMouseEvent.GetCursorDelta(); MouseDelta.X += CursorDelta.X; ++NumMouseSamplesX; MouseDelta.Y -= CursorDelta.Y; ++NumMouseSamplesY; } } } return CurrentReplyState; }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); int mouseX, mouseY; Vector2 ballPosition = { -100.0, -100.0 }; //--------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { mouseX = GetMouseX(); mouseY = GetMouseY(); ballPosition.x = (float)mouseX; ballPosition.y = (float)mouseY; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawCircleV(ballPosition, 40, GOLD); DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
void OnInitial(DEVICEINSTANCE *device) { D3DXMATRIX projection; D3DXMatrixPerspectiveFovLH(&projection, D3DX_PI / 4, 800 / 600.0f, 0.0001f, 1000.0f); device->d3dDevice->SetTransform(D3DTS_PROJECTION, &projection); D3DXLoadMeshFromX(L"skybox.x", 0, device->d3dDevice, nullptr, nullptr, nullptr, nullptr, &skybox); D3DXCreateTeapot(device->d3dDevice, &teapot, nullptr); D3DXCreateTextureFromFile(device->d3dDevice, L"sky copy.png", &texture); lastMouseX = GetMouseX(); lastMouseY = GetMouseY(); }
FReply FSceneViewport::OnMouseButtonUp( const FGeometry& InGeometry, const FPointerEvent& InMouseEvent ) { // Start a new reply state CurrentReplyState = FReply::Handled(); KeyStateMap.Add( InMouseEvent.GetEffectingButton(), false ); UpdateModifierKeys( InMouseEvent ); UpdateCachedMousePos( InGeometry, InMouseEvent ); UpdateCachedGeometry(InGeometry); // Switch to the viewport clients world before processing input FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient ); bool bCursorVisible = true; bool bReleaseMouse = true; if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue ) { if (!ViewportClient->InputKey(this, InMouseEvent.GetUserIndex(), InMouseEvent.GetEffectingButton(), IE_Released)) { CurrentReplyState = FReply::Unhandled(); } bCursorVisible = ViewportClient->GetCursor(this, GetMouseX(), GetMouseY()) != EMouseCursor::None; bReleaseMouse = bCursorVisible || ViewportClient->CaptureMouseOnClick() == EMouseCaptureMode::CaptureDuringMouseDown || ( ViewportClient->CaptureMouseOnClick() == EMouseCaptureMode::CaptureDuringRightMouseDown && InMouseEvent.GetEffectingButton() == EKeys::RightMouseButton ); } if (!((FApp::IsGame() && !GIsEditor) || bIsPlayInEditorViewport) || bReleaseMouse) { // On mouse up outside of the game (editor viewport) or if the cursor is visible in game, we should make sure the mouse is no longer captured // as long as the left or right mouse buttons are not still down if( !InMouseEvent.IsMouseButtonDown( EKeys::RightMouseButton ) && !InMouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton )) { if( bCursorHiddenDueToCapture ) { bCursorHiddenDueToCapture = false; CurrentReplyState.SetMousePos( MousePosBeforeHiddenDueToCapture ); MousePosBeforeHiddenDueToCapture = FIntPoint( -1, -1 ); } CurrentReplyState.ReleaseMouseCapture(); if (bCursorVisible) { CurrentReplyState.ReleaseMouseLock(); } } } return CurrentReplyState; }
/** * Toggles cheat menu. It should not allow cheats in Network mode. * @return Gives true if the menu was toggled, false if cheat is not allowed. */ short toggle_main_cheat_menu(void) { long mouse_x = GetMouseX(); long mouse_y = GetMouseY(); if ((gui_box==NULL) || (gui_box_is_not_valid(gui_box))) { if ((game.flags_font & FFlg_AlexCheat) == 0) return false; gui_box = gui_create_box(mouse_x,mouse_y,gui_main_cheat_list); gui_move_box(gui_box, mouse_x, mouse_y, Fnt_CenterPos); } else { gui_delete_box(gui_box); gui_box=NULL; } return true; }
void ReserveCellsAroundHere (void) { unsigned char MouseX = GetMouseX(); unsigned char MouseY = GetMouseY(); unsigned char Exits = GetExits(MouseX,MouseY); /* Reserve cell for this mouse by putting its mousenumber in 3rd Nibble of MAZE (0x0F00 is mask) Must check first that maze bounds not exceeded (can not reserve cell [-1] or cell [>MAZEX] or [>MAZEY] ) & Can not reserve cell if already reserved */ if (MouseY) { if ( (!GetCellReserved(MouseX, MouseY-1)) && (Exits & NORTH) ) { //bound check & not already reserved & No Wall SetCellReserved(MouseX, MouseY-1); //reserve north } } if ( (MouseX != (MAZEX-1)) ) { if ( (!GetCellReserved(MouseX+1, MouseY)) && (Exits & EAST) ) { SetCellReserved(MouseX+1, MouseY); //reserve east } } if ( (MouseY != (MAZEY-1)) ) { if ( (!GetCellReserved(MouseX, MouseY+1)) && (Exits & SOUTH) ) { SetCellReserved(MouseX, MouseY+1); //reserve south } } if (MouseX) { if ( (!GetCellReserved(MouseX-1, MouseY)) && (Exits & WEST) ) { SetCellReserved(MouseX-1, MouseY); //reserve west } } }
void ReleaseWalledCells (void) { unsigned char MouseX = GetMouseX(); unsigned char MouseY = GetMouseY(); unsigned char Walls = GetWalls(MouseX,MouseY); /* Having reserved all cells around destination, some may be unaccessible as there is a wall in the way. If so, cell does not need to be reserved, so release that cell. */ if (MouseY) //North boundary check { if ( (GetCellReserved(MouseX, MouseY-1)) && (Walls & NORTH) ) { ReleaseCell(MouseX, MouseY-1); //release north } } if ( MouseX != (MAZEX-1) ) //East boundary check { if( (GetCellReserved(MouseX+1, MouseY)) && (Walls & EAST) ) { ReleaseCell(MouseX+1, MouseY); //release east } } if ( MouseY != (MAZEY-1) ) //South boundary check { if ( (GetCellReserved(MouseX, MouseY+1)) && (Walls & SOUTH) ) { ReleaseCell(MouseX, MouseY+1); //release south } } if (MouseX) //West boundary check { if ( (GetCellReserved(MouseX-1, MouseY)) && (Walls & WEST) ) { ReleaseCell(MouseX-1, MouseY); //release west } } }
FCursorReply FSceneViewport::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent ) { if (bCursorHiddenDueToCapture) { return FCursorReply::Cursor(EMouseCursor::None); } EMouseCursor::Type MouseCursorToUse = EMouseCursor::Default; // If the cursor should be hidden, use EMouseCursor::None, // only when in the foreground, or we'll hide the mouse in the window/program above us. if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue ) { MouseCursorToUse = ViewportClient->GetCursor( this, GetMouseX(), GetMouseY() ); } // Use the default cursor if there is no viewport client or we dont have focus return FCursorReply::Cursor(MouseCursorToUse); }
FReply FSceneViewport::OnKeyboardFocusReceived( const FKeyboardFocusEvent& InKeyboardFocusEvent ) { CurrentReplyState = FReply::Handled(); if( ViewportClient ) { FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient ); ViewportClient->ReceivedFocus( this ); if( ( FApp::IsGame() && !GIsEditor ) || bIsPlayInEditorViewport ) { if( IsForegroundWindow() ) { const bool bIsCursorForcedVisible = ( ViewportClient != NULL && ViewportClient->GetCursor( this, GetMouseX(), GetMouseY() ) != EMouseCursor::None ); const bool bPlayInEditorCapture = !bIsPlayInEditorViewport || InKeyboardFocusEvent.GetCause() != EKeyboardFocusCause::SetDirectly || bPlayInEditorGetsMouseControl; // capturing the mouse interferes with slate UI (like the virtual joysticks) if (FPlatformProperties::SupportsWindowedMode() && bPlayInEditorCapture && !bIsCursorForcedVisible && !FSlateApplication::Get().IsFakingTouchEvents()) { // Only require the user to click in the window the first time - after that return focus to the game so long as it was the last focused widget. // Means that tabbing in/out will return the mouse control to where it was & the in-game console won't leave the mouse under editor control. bPlayInEditorGetsMouseControl = true; CurrentReplyState.UseHighPrecisionMouseMovement( ViewportWidget.Pin().ToSharedRef() ); CurrentReplyState.LockMouseToWidget( ViewportWidget.Pin().ToSharedRef() ); } else if(!bPlayInEditorCapture) { FSlateApplication::Get().ClearKeyboardFocus( EKeyboardFocusCause::SetDirectly ); FSlateApplication::Get().ResetToDefaultInputSettings(); } } else { FSlateApplication::Get().ClearKeyboardFocus( EKeyboardFocusCause::Cleared ); } } } return CurrentReplyState; }
const CvRect &ProcessSelection() { currentPos.x = GetMouseX(); currentPos.y = GetMouseY(); if (IsLMouseDown()) { if (!isSelectionStarted) { //start picking origin = currentPos; selection.x = origin.x; selection.y = origin.y; selection.width = origin.x; selection.height = origin.y; printf("staret picking\n"); } isSelectionStarted = true; selection.x = MIN(currentPos.x,origin.x); selection.y = MIN(currentPos.y,origin.y); selection.width = selection.x + CV_IABS(currentPos.x - origin.x); selection.height = selection.y + CV_IABS(currentPos.y - origin.y); selection.x = MAX( selection.x, 0 ); selection.y = MAX( selection.y, 0 ); selection.width = MIN( selection.width, 640); selection.height = MIN( selection.height, 480 ); selection.width -= selection.x; selection.height -= selection.y; } else { if (isSelectionStarted) { printf("end picking\n"); //end picking isSelectionStarted = false; hasSelection = true; /*selection.width = selection.x - currentPos.x; selection.height =selection.y - currentPos.y;*/ } } return selection; }
bool CCoherentInputEventListener::TraceMouse( int& outX, int& outY, CCoherentViewListener*& pViewListener ) { if ( gCoherentUISystem == nullptr ) { return false; } CCamera& camera = gEnv->pSystem->GetViewCamera(); int vpWidth = gEnv->pRenderer->GetWidth(); int vpHeight = gEnv->pRenderer->GetHeight(); float proj22 = 1.0f / cry_tanf( camera.GetFov() / 2.0f ); float proj11 = proj22 / camera.GetProjRatio(); float viewX = ( ( ( 2.0f * ( float )GetMouseX() ) / vpWidth ) - 1.0f ) / proj11; float viewY = ( ( ( -2.0f * ( float )GetMouseY() ) / vpHeight ) + 1.0f ) / proj22; Matrix34 invView = camera.GetMatrix(); Vec3 dir = invView.TransformVector( Vec3( viewX, 1.0f, viewY ) ); // Z is up Vec3 origin = camera.GetPosition(); return gCoherentUISystem->RaycastClosestViewListenersGeometry( origin, dir, outX, outY, pViewListener ); }
void Button::ExecuteButton( int screenWidth, int screenHeight, int fullscreen, float sfxVolume ) { float offset = 0; if ( !fullscreen ) offset = 40; float tMouseX = (float)GetMouseX(); float tMouseY = screenHeight - GetMouseY() - offset; if ( tMouseX > mXPos && tMouseX < mXPos + mWidth * mScale && tMouseY > mYPos && tMouseY < mYPos + mHeight * mScale ) { if ( mButtonHandler && GetLeftClick() ) { if ( !mClickPlayed ) { irrklang::ISound *tSFX = mAudioManager->play2D( mClickSFX.c_str(), false, true ); tSFX->setVolume( sfxVolume ); tSFX->setIsPaused( false ); mClickPlayed = true; } mButtonHandler( mState ); } else { mClickPlayed = false; } } }
void Button::DrawButton( int screenWidth, int screenHeight, int fullscreen, float sfxVolume ) { float offset = 0; if ( !fullscreen ) offset = 40; float tMouseX = (float)GetMouseX(); float tMouseY = screenHeight - GetMouseY() - offset; if ( tMouseX > mXPos && tMouseX < mXPos + mWidth * mScale && tMouseY > mYPos && tMouseY < mYPos + mHeight * mScale ) { glBindTexture( GL_TEXTURE_2D, mHoverTexture->GetTextureId() ); if ( !mHoverPlayed ) { irrklang::ISound *tSFX = mAudioManager->play2D( mHoverSFX.c_str(), false, true ); tSFX->setVolume( sfxVolume ); tSFX->setIsPaused( false ); mHoverPlayed = true; } } else { glBindTexture( GL_TEXTURE_2D, mTexture->GetTextureId() ); mHoverPlayed = false; } DrawRectangle2D( mXPos, mYPos, mXPos + mWidth * mScale, mYPos + mHeight * mScale ); }