Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2019, 2:27:40 PM (5 years ago)
Author:
tkuonen
Message:

Improve MouseAPI
Add Comments
Cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.h

    r12363 r12377  
    22#define MOUSEAPICURSOR_H
    33#include <overlays/OrxonoxOverlay.h>
    4 #include "core/CoreIncludes.h"
    5 #include "tools/interfaces/Tickable.h"
    6 #include "overlays/OverlayGroup.h"
     4#include <core/CoreIncludes.h>
     5#include <tools/interfaces/Tickable.h>
    76#include "mouseapi.h"
    8 #include "core/XMLPort.h"
    9 
     7#include <core/XMLPort.h>
    108
    119#if OGRE_VERSION >= 0x010900
     
    1715#endif
    1816
    19 #include "tools/TextureGenerator.h"
    20 #include "util/StringUtils.h"
     17#include <tools/TextureGenerator.h>
     18#include <util/StringUtils.h>
    2119
    2220namespace orxonox{
     
    2523{
    2624private:
     25    //Pointer to the cursor overlay
    2726    Ogre::PanelOverlayElement* cursor;
     27    //Is Cursor activated?
    2828    bool running = false;
     29    //Name of the image-file used as the cursor shape
    2930    std::string cursorname = "cursor.png";
     31    //Color of the cursor
     32    Vector3 color = {1,1,1};
    3033public:
    3134    MouseAPICursor(Context* context);
    3235    ~MouseAPICursor();
     36    //Update cursor position
    3337    virtual void tick(float dt) override;
     38    //XMLPort: ability to set cursor shape & color
    3439    virtual void XMLPort(ticpp::Element &xmlelement, XMLPort::Mode mode) override;
     40    //Update cursol look (shape & color)
     41    inline void updateCursor(){
     42        cursor->setMaterialName(TextureGenerator::getMaterialName(
     43                                                      cursorname, Ogre::ColourValue(color[0],color[1],color[2],1)));
     44    }
    3545    inline void setCursorName(const std::string& name)
    3646    {
    3747        cursorname = name;
    38         cursor->setMaterialName(TextureGenerator::getMaterialName(
    39                                                       cursorname, Ogre::ColourValue::White));
     48        updateCursor();
    4049    }
    4150    inline std::string getCursorName(void) const
    4251    {
    4352        return cursorname;
     53    }
     54    inline void setCursorColor(const Vector3& cl)
     55    {
     56        color = cl;
     57        updateCursor();
     58    }
     59    inline Vector3 getCursorColor(void) const
     60    {
     61        return color;
    4462    }
    4563
Note: See TracChangeset for help on using the changeset viewer.