Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.h @ 12384

Last change on this file since 12384 was 12377, checked in by tkuonen, 6 years ago

Improve MouseAPI
Add Comments
Cleanup

File size: 1.8 KB
Line 
1#ifndef MOUSEAPICURSOR_H
2#define MOUSEAPICURSOR_H
3#include <overlays/OrxonoxOverlay.h>
4#include <core/CoreIncludes.h>
5#include <tools/interfaces/Tickable.h>
6#include "mouseapi.h"
7#include <core/XMLPort.h>
8
9#if OGRE_VERSION >= 0x010900
10#   include <Overlay/OgreOverlayManager.h>
11#   include <Overlay/OgrePanelOverlayElement.h>
12#else
13#   include <OgreOverlayManager.h>
14#   include <OgrePanelOverlayElement.h>
15#endif
16
17#include <tools/TextureGenerator.h>
18#include <util/StringUtils.h>
19
20namespace orxonox{
21
22class MouseAPICursor: public OrxonoxOverlay, public Tickable
23{
24private:
25    //Pointer to the cursor overlay
26    Ogre::PanelOverlayElement* cursor;
27    //Is Cursor activated?
28    bool running = false;
29    //Name of the image-file used as the cursor shape
30    std::string cursorname = "cursor.png";
31    //Color of the cursor
32    Vector3 color = {1,1,1};
33public:
34    MouseAPICursor(Context* context);
35    ~MouseAPICursor();
36    //Update cursor position
37    virtual void tick(float dt) override;
38    //XMLPort: ability to set cursor shape & color
39    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    }
45    inline void setCursorName(const std::string& name)
46    {
47        cursorname = name;
48        updateCursor();
49    }
50    inline std::string getCursorName(void) const
51    {
52        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;
62    }
63
64};
65
66}
67
68#endif // MOUSEAPICURSOR_H
Note: See TracBrowser for help on using the repository browser.