| [12334] | 1 | #ifndef MOUSEAPICURSOR_H |
|---|
| 2 | #define MOUSEAPICURSOR_H |
|---|
| 3 | #include <overlays/OrxonoxOverlay.h> |
|---|
| [12377] | 4 | #include <core/CoreIncludes.h> |
|---|
| 5 | #include <tools/interfaces/Tickable.h> |
|---|
| [12363] | 6 | #include "mouseapi.h" |
|---|
| [12377] | 7 | #include <core/XMLPort.h> |
|---|
| [12334] | 8 | |
|---|
| [12363] | 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 | |
|---|
| [12377] | 17 | #include <tools/TextureGenerator.h> |
|---|
| 18 | #include <util/StringUtils.h> |
|---|
| [12363] | 19 | |
|---|
| [12348] | 20 | namespace orxonox{ |
|---|
| [12334] | 21 | |
|---|
| [12363] | 22 | class MouseAPICursor: public OrxonoxOverlay, public Tickable |
|---|
| [12334] | 23 | { |
|---|
| [12363] | 24 | private: |
|---|
| [12377] | 25 | //Pointer to the cursor overlay |
|---|
| [12363] | 26 | Ogre::PanelOverlayElement* cursor; |
|---|
| [12377] | 27 | //Is Cursor activated? |
|---|
| [12363] | 28 | bool running = false; |
|---|
| [12377] | 29 | //Name of the image-file used as the cursor shape |
|---|
| [12363] | 30 | std::string cursorname = "cursor.png"; |
|---|
| [12377] | 31 | //Color of the cursor |
|---|
| 32 | Vector3 color = {1,1,1}; |
|---|
| [12334] | 33 | public: |
|---|
| 34 | MouseAPICursor(Context* context); |
|---|
| [12363] | 35 | ~MouseAPICursor(); |
|---|
| [12377] | 36 | //Update cursor position |
|---|
| [12363] | 37 | virtual void tick(float dt) override; |
|---|
| [12377] | 38 | //XMLPort: ability to set cursor shape & color |
|---|
| [12363] | 39 | virtual void XMLPort(ticpp::Element &xmlelement, XMLPort::Mode mode) override; |
|---|
| [12377] | 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 | } |
|---|
| [12363] | 45 | inline void setCursorName(const std::string& name) |
|---|
| 46 | { |
|---|
| 47 | cursorname = name; |
|---|
| [12377] | 48 | updateCursor(); |
|---|
| [12363] | 49 | } |
|---|
| 50 | inline std::string getCursorName(void) const |
|---|
| 51 | { |
|---|
| 52 | return cursorname; |
|---|
| 53 | } |
|---|
| [12377] | 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 | } |
|---|
| [12363] | 63 | |
|---|
| [12334] | 64 | }; |
|---|
| 65 | |
|---|
| [12348] | 66 | } |
|---|
| 67 | |
|---|
| [12334] | 68 | #endif // MOUSEAPICURSOR_H |
|---|