Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2019, 4:02:06 PM (5 years ago)
Author:
tkuonen
Message:

Add first version of mousecursor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc

    r12302 r12309  
    2121            state->setMouseExclusive(false);//does this work
    2222            state->setMouseHandler(this);
     23            state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
     24            InputManager::getInstance().enterState("guiMouseOnly");
    2325            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
    2531    }
    2632
     
    3137    if(active)
    3238    {
     39        GUIManager::getInstance().showGUI("MouseAPICursor", true);
    3340        active = false;
    3441        if(InputManager::exists())
     
    3744            state->setMouseHandler(nullptr);
    3845            InputManager::getInstance().destroyState("MouseAPI");
     46            InputManager::getInstance().enterState("game");
    3947        }
    4048        clickEvents.clear();
     
    5967        for(auto wantedButton:event.buttons)
    6068        {
    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))
    6271                event.onClickedFunction(button);
    6372        }
     
    6877{
    6978    //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
    7081}
    7182
     
    7990    for(auto event:scrollEvents)
    8091    {
    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))))
    8293            event.onScrolledFunction(abs,rel,IntVector2(mouseposX,mouseposY));
    8394    }
     
    183194         }
    184195     }
     196     return 0;
    185197}
    186198
     
    194206         }
    195207     }
    196 }
    197 
    198 }
     208     return 0;
     209}
     210
     211//returns relative Position of the Mouse
     212Vector2 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.