Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12363 for code/branches


Ignore:
Timestamp:
May 9, 2019, 4:04:30 PM (6 years ago)
Author:
tkuonen
Message:

Added MouseCursor

Location:
code/branches/MouseAPI_FS19
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/data/levels/MouseAPIExample.oxw

    r12334 r12363  
    99  include("stats.oxo")
    1010  include("HUDTemplates3.oxo")
     11  include("MouseCursor.oxo")
     12  include("tetrisHUD.oxo")
    1113  include("templates/lodInformation.oxt")
    1214?>
     
    2123    <Template link=lodtemplate_default />
    2224  </templates>
    23        
     25
    2426  <Scene
    2527    ambientlight = "0.8, 0.8, 0.8"
     
    4951</MouseAPIExample>
    5052
    51  
     53<!--<MouseAPICursor></MouseAPICursor>
     54<MouseCursor></MouseCursor>-->
    5255  </Scene>
    5356</Level>
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc

    r12362 r12363  
    11#include "mouseapi.h"
     2
     3#if OGRE_VERSION >= 0x010900
     4#   include <Overlay/OgreOverlayManager.h>
     5#   include <Overlay/OgrePanelOverlayElement.h>
     6#else
     7#   include <OgreOverlayManager.h>
     8#   include <OgrePanelOverlayElement.h>
     9#endif
     10
     11#include "util/StringUtils.h"
    212
    313namespace orxonox{
     
    2939        }
    3040        //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);
    3149    }
    3250
     
    84102    {
    85103        InputManager::getInstance().leaveState("game");//hack: todo: crate 2nd input state with prioritz 98 for cegui(cursor)
    86         GUIManager::getInstance().showGUI("MouseAPICursor", false);//hack todo: only if gui not shown & evt better if not in mouse mooved
     104        //GUIManager::getInstance().showGUI("MouseAPICursor", false);//hack todo: only if gui not shown & evt better if not in mouse mooved
    87105    }
    88106
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h

    r12362 r12363  
    9696    bool active = false;
    9797
     98    Ogre::PanelOverlayElement* cursor;
     99
    98100public:
    99101
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.cc

    r12348 r12363  
    88{
    99    RegisterObject(MouseAPICursor);
    10 //TODO: copy from radar overlay
     10    cursor = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     11                                                          .createOverlayElement("Panel", "MouseAPI_cursor_" + getUniqueNumberString()));
     12    cursor->setMaterialName(TextureGenerator::getMaterialName(
     13                                      cursorname, Ogre::ColourValue::White));
     14
     15    overlay_->add2D(this->cursor);
     16    scale(Vector2(0.03,0.03));
     17    setVisible(true);
     18}
     19
     20MouseAPICursor::~MouseAPICursor()
     21{
     22    if(running)
     23        MouseAPI::getInstance().deactivate();
     24}
     25
     26void MouseAPICursor::XMLPort(ticpp::Element &xmlelement, XMLPort::Mode mode)
     27{
     28    MouseAPI::getInstance().activate();
     29    running = true;
     30    SUPER(MouseAPICursor, XMLPort, xmlelement, mode);
     31    XMLPortParam(MouseAPICursor, "cursorShape", setCursorName, getCursorName,xmlelement, mode);
     32    //XMLPortParam(MouseAPICursor, "cursorColor", setCursorColor, getCursorColor,xmlelement, mode);//TODO: ColoValue::setAsARGB()
     33}
     34
     35void MouseAPICursor::tick(float dt)
     36{
     37    if(running)
     38    {
     39        this->cursor->show();
     40        this->show();
     41        this->setPosition(MouseAPI::getInstance().getMousePosition());
     42    }
    1143}
    1244
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.h

    r12348 r12363  
    33#include <overlays/OrxonoxOverlay.h>
    44#include "core/CoreIncludes.h"
     5#include "tools/interfaces/Tickable.h"
     6#include "overlays/OverlayGroup.h"
     7#include "mouseapi.h"
     8#include "core/XMLPort.h"
     9
     10
     11#if OGRE_VERSION >= 0x010900
     12#   include <Overlay/OgreOverlayManager.h>
     13#   include <Overlay/OgrePanelOverlayElement.h>
     14#else
     15#   include <OgreOverlayManager.h>
     16#   include <OgrePanelOverlayElement.h>
     17#endif
     18
     19#include "tools/TextureGenerator.h"
     20#include "util/StringUtils.h"
    521
    622namespace orxonox{
    723
    8 class MouseAPICursor: public OrxonoxOverlay
     24class MouseAPICursor: public OrxonoxOverlay, public Tickable
    925{
     26private:
     27    Ogre::PanelOverlayElement* cursor;
     28    bool running = false;
     29    std::string cursorname = "cursor.png";
    1030public:
    1131    MouseAPICursor(Context* context);
     32    ~MouseAPICursor();
     33    virtual void tick(float dt) override;
     34    virtual void XMLPort(ticpp::Element &xmlelement, XMLPort::Mode mode) override;
     35    inline void setCursorName(const std::string& name)
     36    {
     37        cursorname = name;
     38        cursor->setMaterialName(TextureGenerator::getMaterialName(
     39                                                      cursorname, Ogre::ColourValue::White));
     40    }
     41    inline std::string getCursorName(void) const
     42    {
     43        return cursorname;
     44    }
     45
    1246};
    1347
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mousegametype.cc

    r12309 r12363  
    88    player_ =nullptr;
    99
     10    this->setHUDTemplate("MouseCursor");
     11
    1012}
    1113
    12 void MouseGametype::start(){
    13 
     14void MouseGametype::start()
     15{
    1416    bool temp = this->bForceSpawn_;
    1517    this->bForceSpawn_ = true;
     
    2022    // Reset the variable.
    2123    this->bForceSpawn_ = temp;
     24
    2225}
    2326
     
    3942        this->player_ = player;
    4043        this->players_[player].state_ = PlayerState::Alive;
    41 
    4244    }
    4345}
Note: See TracChangeset for help on using the changeset viewer.