- Timestamp:
- Apr 18, 2019, 4:02:06 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc
r12302 r12309 21 21 state->setMouseExclusive(false);//does this work 22 22 state->setMouseHandler(this); 23 state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 24 InputManager::getInstance().enterState("guiMouseOnly"); 23 25 InputManager::getInstance().enterState("MouseAPI"); 24 } 26 InputManager::getInstance().setMouseExclusive("game",false); 27 //InputManager::getInstance().setMouseExclusive("guiMouseOnly",false); 28 //InputManager::getInstance().getState("game")-> 29 } 30 //GUIManager::getInstance().showGUI("MouseAPICursor", true);//Display a mouse cursor by displaying a empty menu 25 31 } 26 32 … … 31 37 if(active) 32 38 { 39 GUIManager::getInstance().showGUI("MouseAPICursor", true); 33 40 active = false; 34 41 if(InputManager::exists()) … … 37 44 state->setMouseHandler(nullptr); 38 45 InputManager::getInstance().destroyState("MouseAPI"); 46 InputManager::getInstance().enterState("game"); 39 47 } 40 48 clickEvents.clear(); … … 59 67 for(auto wantedButton:event.buttons) 60 68 { 61 if(wantedButton == button && ray.intersects(Ogre::Sphere(event.position,event.radius)).first) 69 Ogre::Sphere sphere(event.position,event.radius); 70 if(wantedButton == button && ray.intersects(sphere).first && cam->isVisible(sphere)) 62 71 event.onClickedFunction(button); 63 72 } … … 68 77 { 69 78 //mousePos = abs; 79 InputManager::getInstance().leaveState("game");//hack: todo: crate 2nd input state with prioritz 98 for cegui(cursor) 80 GUIManager::getInstance().showGUI("MouseAPICursor", true);//hack todo: only if gui not shown & evt better if not in mouse mooved 70 81 } 71 82 … … 79 90 for(auto event:scrollEvents) 80 91 { 81 if(!event.considerPosition || ray.intersects(Ogre::Sphere(event.position,event.radius)).first)92 if(!event.considerPosition || (ray.intersects(Ogre::Sphere(event.position,event.radius)).first && cam->isVisible(Ogre::Sphere(event.position,event.radius)))) 82 93 event.onScrolledFunction(abs,rel,IntVector2(mouseposX,mouseposY)); 83 94 } … … 183 194 } 184 195 } 196 return 0; 185 197 } 186 198 … … 194 206 } 195 207 } 196 } 197 198 } 208 return 0; 209 } 210 211 //returns relative Position of the Mouse 212 Vector2 MouseAPI::getMousePosition() 213 { 214 Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport(); 215 return Vector2(InputManager::getInstance().getMousePosition().first/((float)vp->getActualWidth()),InputManager::getInstance().getMousePosition().second/((float)vp->getActualHeight())); 216 } 217 218 }
Note: See TracChangeset
for help on using the changeset viewer.