Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Add first version of mousecursor

Location:
code/branches/MouseAPI_FS19/src/modules/MouseAPI
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/CMakeLists.txt

    r12301 r12309  
    33  mouseapiexample.cc
    44  mousegametype.cc
    5   mousecursor.cc
    65)
    76
  • 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}
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h

    r12302 r12309  
    1616#include "CameraManager.h"
    1717#include <functional>
     18#include "core/GUIManager.h"
     19#include "core/input/KeyBinderManager.h"
    1820
    1921namespace orxonox
     
    8789    float getRadiusScroll(ScrollableElementID id);
    8890
     91    Vector2 getMousePosition();
     92
    8993    void activate();
    9094    static bool isActive(){return singletonPtr_s != nullptr && getInstance().active;}
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mousegametype.cc

    r12301 r12309  
    99
    1010}
     11
    1112void MouseGametype::start(){
    1213
     
    1920    // Reset the variable.
    2021    this->bForceSpawn_ = temp;
    21 
    22     InputManager::getInstance().setMouseExclusive("game",false);//set show mouse, see guimanager
    2322}
    2423
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mousegametype.h

    r12301 r12309  
    55#include "infos/PlayerInfo.h"
    66#include <core/input/InputState.h>
    7 #include <CEGUI/MouseCursor.h> //todo: guimanager: fallunterscheidng cegui version
     7#include "core/GUIManager.h"
    88
    99namespace orxonox
     
    1919private:
    2020    PlayerInfo* player_ ;
     21    CEGUI::MouseCursor *cursor;
    2122};
    2223
Note: See TracChangeset for help on using the changeset viewer.