| 484 | } |
| 485 | |
| 486 | bool GameMode::mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id) |
| 487 | { |
| 488 | InputManager& inputManager = mModeManager->getInputManager(); |
| 489 | |
| 490 | CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseButtonDown( |
| 491 | Gui::convertButton(id)); |
| 492 | |
| 493 | if (!isConnected()) |
| 494 | return true; |
| 495 | |
| 496 | inputManager.mMouseDownOnCEGUIWindow = isMouseDownOnCEGUIWindow(); |
| 497 | if (inputManager.mMouseDownOnCEGUIWindow) |
| 498 | return true; |
| 499 | |
| 500 | if(mGameMap->getLocalPlayer() == nullptr) |
| 501 | { |
| 502 | static bool log = true; |
| 503 | if(log) |
| 504 | { |
| 505 | log = false; |
| 506 | OD_LOG_ERR("LOCAL PLAYER DOES NOT EXIST!!"); |
| 507 | } |
| 508 | return true; |
| 509 | } |
| 510 | |
| 511 | // There is a bug in OIS. When playing in windowed mode, if we clic outside the window |
| 512 | // and then we restore the window, we will receive a clic event on the last place where |
| 513 | // the mouse was. |
| 514 | Ogre::RenderWindow* mainWindows = static_cast<Ogre::RenderWindow*>( |
| 515 | Ogre::Root::getSingleton().getRenderTarget("OpenDungeons " + ODApplication::VERSION)); |
| 516 | if((!mainWindows->isFullScreen()) && |
| 517 | ((arg.state.X.abs == 0) || (arg.state.Y.abs == 0) || |
| 518 | (static_cast<Ogre::uint32>(arg.state.X.abs) == mainWindows->getWidth()) || |
| 519 | (static_cast<Ogre::uint32>(arg.state.Y.abs) == mainWindows->getHeight()))) |
| 520 | { |
| 521 | return true; |
| 522 | } |
| 523 | |
| 524 | if(mGameMap->getGamePaused()) |
| 525 | return true; |
| 526 | |
| 527 | if(!ODFrameListener::getSingleton().findWorldPositionFromMouse(arg, inputManager.mKeeperHandPos)) |
| 528 | return true; |
| 529 | |
| 530 | RenderManager::getSingleton().moveWorldCoords(inputManager.mKeeperHandPos.x, inputManager.mKeeperHandPos.y); |
| 531 | |
| 532 | // The player should be able to move the mouse even if not clicking on a tile. Because of that, we set |
| 533 | // mMMouseDown before checking which tile is clicked |
| 534 | if (id == OIS::MB_Middle) |
| 535 | inputManager.mMMouseDown = true; |
| 536 | |
| 537 | int tileX = Helper::round(inputManager.mKeeperHandPos.x); |
| 538 | int tileY = Helper::round(inputManager.mKeeperHandPos.y); |
| 539 | Tile* tileClicked = mGameMap->getTile(tileX, tileY); |
| 540 | if(tileClicked == nullptr) |
| 541 | return true; |
| 542 | |
| 543 | if (id == OIS::MB_Middle) |
nothing calls this directly
no test coverage detected