MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / mousePressed

Method mousePressed

source/modes/EditorMode.cpp:310–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310bool EditorMode::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
311{
312 CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseButtonDown(
313 Gui::convertButton(id));
314
315 if (!isConnected())
316 return true;
317
318 CEGUI::Window *tempWindow = CEGUI::System::getSingleton().getDefaultGUIContext().getWindowContainingMouse();
319
320 InputManager& inputManager = mModeManager->getInputManager();
321
322 // If the mouse press is on a CEGUI window ignore it
323 if (tempWindow != nullptr && tempWindow->getName().compare("EDITORGUI") != 0)
324 {
325 inputManager.mMouseDownOnCEGUIWindow = true;
326 return true;
327 }
328
329 inputManager.mMouseDownOnCEGUIWindow = false;
330
331 if(mGameMap->getLocalPlayer() == nullptr)
332 {
333 static bool log = true;
334 if(log)
335 {
336 log = false;
337 OD_LOG_ERR("LOCAL PLAYER DOES NOT EXIST!!");
338 }
339 return true;
340 }
341
342 // There is a bug in OIS. When playing in windowed mode, if we clic outside the window
343 // and then we restore the window, we will receive a clic event on the last place where
344 // the mouse was.
345 Ogre::RenderWindow* mainWindows = static_cast<Ogre::RenderWindow*>(
346 Ogre::Root::getSingleton().getRenderTarget("OpenDungeons " + ODApplication::VERSION));
347 if((!mainWindows->isFullScreen()) &&
348 ((arg.state.X.abs == 0) || (arg.state.Y.abs == 0) ||
349 (static_cast<Ogre::uint32>(arg.state.X.abs) == mainWindows->getWidth()) ||
350 (static_cast<Ogre::uint32>(arg.state.Y.abs) == mainWindows->getHeight())))
351 {
352 return true;
353 }
354
355 Ogre::Vector3 keeperHandPos;
356 if(!ODFrameListener::getSingleton().findWorldPositionFromMouse(arg, keeperHandPos))
357 return true;
358
359 RenderManager::getSingleton().moveWorldCoords(keeperHandPos.x, keeperHandPos.y);
360
361 int tileX = Helper::round(keeperHandPos.x);
362 int tileY = Helper::round(keeperHandPos.y);
363 Tile* tileClicked = mGameMap->getTile(tileX, tileY);
364 if(tileClicked == nullptr)
365 return true;
366
367 if (id == OIS::MB_Middle)

Callers

nothing calls this directly

Calls 15

roundFunction · 0.85
squaredDistanceFunction · 0.85
getLocalPlayerMethod · 0.80
moveWorldCoordsMethod · 0.80
fillWithEntitiesMethod · 0.80
setTextMethod · 0.80
getCurrentActionMethod · 0.80
setCurrentActionMethod · 0.80
numObjectsInHandMethod · 0.80
isDropHandPossibleMethod · 0.80
tileToPacketMethod · 0.80

Tested by

no test coverage detected