[12334] | 1 | #include "mouseapicursor.h" |
---|
| 2 | |
---|
| 3 | namespace orxonox{ |
---|
| 4 | |
---|
| 5 | RegisterClass(MouseAPICursor); |
---|
| 6 | |
---|
| 7 | MouseAPICursor::MouseAPICursor(Context* context):OrxonoxOverlay(context) |
---|
| 8 | { |
---|
[12348] | 9 | RegisterObject(MouseAPICursor); |
---|
[12363] | 10 | cursor = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() |
---|
| 11 | .createOverlayElement("Panel", "MouseAPI_cursor_" + getUniqueNumberString())); |
---|
[12377] | 12 | updateCursor(); |
---|
[12363] | 13 | overlay_->add2D(this->cursor); |
---|
| 14 | scale(Vector2(0.03,0.03)); |
---|
| 15 | setVisible(true); |
---|
[12334] | 16 | } |
---|
| 17 | |
---|
[12363] | 18 | MouseAPICursor::~MouseAPICursor() |
---|
| 19 | { |
---|
| 20 | if(running) |
---|
| 21 | MouseAPI::getInstance().deactivate(); |
---|
[12377] | 22 | if(this->isInitialized()) |
---|
| 23 | Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->cursor); |
---|
[12334] | 24 | } |
---|
[12363] | 25 | |
---|
| 26 | void 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); |
---|
[12377] | 32 | XMLPortParam(MouseAPICursor, "cursorColor", setCursorColor, getCursorColor,xmlelement, mode); |
---|
[12363] | 33 | } |
---|
| 34 | |
---|
| 35 | void MouseAPICursor::tick(float dt) |
---|
| 36 | { |
---|
| 37 | if(running) |
---|
| 38 | { |
---|
| 39 | this->cursor->show(); |
---|
| 40 | this->show(); |
---|
| 41 | this->setPosition(MouseAPI::getInstance().getMousePosition()); |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | } |
---|