- Timestamp:
- May 16, 2019, 2:27:40 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc
r12363 r12377 1 1 #include "mouseapi.h" 2 3 #if OGRE_VERSION >= 0x0109004 # include <Overlay/OgreOverlayManager.h>5 # include <Overlay/OgrePanelOverlayElement.h>6 #else7 # include <OgreOverlayManager.h>8 # include <OgrePanelOverlayElement.h>9 #endif10 11 #include "util/StringUtils.h"12 2 13 3 namespace orxonox{ … … 27 17 if(InputManager::exists()) 28 18 { 29 //cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();30 19 state = InputManager::getInstance().createInputState("MouseAPI",true,true,99); 31 20 state->setMouseExclusive(false);//does this work 32 21 state->setMouseHandler(this); 22 gameInputActivated = false; 33 23 state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 34 24 InputManager::getInstance().enterState("guiMouseOnly"); 35 25 InputManager::getInstance().enterState("MouseAPI"); 36 26 InputManager::getInstance().setMouseExclusive("game",false); 37 //InputManager::getInstance().setMouseExclusive("guiMouseOnly",false); 38 //InputManager::getInstance().getState("game")-> 39 } 40 //GUIManager::getInstance().showGUI("MouseAPICursor", true);//Display a mouse cursor by displaying a empty menu 41 /*cursor = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 42 .createOverlayElement("Panel", "MouseAPI_cursor_" + getUniqueNumberString())); 43 cursor->setMaterialName("Orxonox/RadarMarker");//todo: better material 44 cursor->setPosition(0,0); 45 cursor->setDimensions(0.1,0.1); 46 Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create( "MouseAPI_cursor_" + getUniqueNumberString() ); 47 overlay->show();*/ 48 //this->overlay_->add2D(this->cursor); 27 } 49 28 } 50 29 … … 55 34 if(active) 56 35 { 57 GUIManager::getInstance().showGUI("MouseAPICursor", true);58 36 active = false; 59 37 if(InputManager::exists()) … … 66 44 clickEvents.clear(); 67 45 scrollEvents.clear(); 46 gameInputActivated=false; 68 47 } 69 48 } … … 76 55 void MouseAPI::buttonPressed(MouseButtonCode::ByEnum button) 77 56 { 78 cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //todo: trycatch57 cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera(); 79 58 Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport(); 80 59 int mouseposX = InputManager::getInstance().getMousePosition().first; … … 94 73 void MouseAPI::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 95 74 { 96 //mousePos = abs;97 75 } 98 76 99 77 void MouseAPI::tick(float dt) 100 78 { 101 if(active) 102 { 103 InputManager::getInstance().leaveState("game");//hack: todo: crate 2nd input state with prioritz 98 for cegui(cursor) 104 //GUIManager::getInstance().showGUI("MouseAPICursor", false);//hack todo: only if gui not shown & evt better if not in mouse mooved 79 if(active && !gameInputActivated) 80 { 81 InputManager::getInstance().leaveState("game"); 105 82 } 106 83 … … 239 216 } 240 217 241 //returns relative Position of the Mouse242 218 Vector2 MouseAPI::getMousePosition() 243 219 { … … 246 222 } 247 223 248 } 224 void MouseAPI::activateGameInput() 225 { 226 gameInputActivated = true; 227 state->setKeyHandler(nullptr); 228 } 229 230 void MouseAPI::deactivateGameInput() 231 { 232 gameInputActivated = false; 233 state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 234 } 235 236 }
Note: See TracChangeset
for help on using the changeset viewer.