[1588] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Reto Grieder |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[1601] | 29 | #ifndef _OrxonoxOverlay_H__ |
---|
| 30 | #define _OrxonoxOverlay_H__ |
---|
[1588] | 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
| 33 | |
---|
| 34 | #include <OgrePrerequisites.h> |
---|
[1590] | 35 | #include "tools/WindowEventListener.h" |
---|
[1588] | 36 | #include "util/Math.h" |
---|
| 37 | #include "core/BaseObject.h" |
---|
| 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
[1601] | 41 | class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener |
---|
[1588] | 42 | { |
---|
| 43 | public: |
---|
[1604] | 44 | Ogre::Overlay* getOverlay() { return this->overlay_; } |
---|
[1601] | 45 | OrxonoxOverlay(); |
---|
| 46 | virtual ~OrxonoxOverlay(); |
---|
[1588] | 47 | |
---|
| 48 | virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); |
---|
| 49 | |
---|
[1595] | 50 | void setAspectCorrection(bool val); |
---|
| 51 | bool getAspectCorrection() { return this->bCorrectAspect_; } |
---|
[1588] | 52 | |
---|
[1598] | 53 | /** Sets the position of this overlay. */ |
---|
| 54 | void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); } |
---|
[1588] | 55 | |
---|
[1598] | 56 | /** Gets the current position. */ |
---|
| 57 | Vector2 getPosition() const { return this->position_; } |
---|
[1588] | 58 | |
---|
| 59 | /** Scrolls the overlay by the offsets provided. */ |
---|
[1598] | 60 | void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); } |
---|
[1588] | 61 | |
---|
[1598] | 62 | /** Sets the origin point of this overlay. */ |
---|
| 63 | void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); } |
---|
| 64 | |
---|
| 65 | /** Gets the origin point of this overlay */ |
---|
| 66 | Vector2 getOrigin() const { return this->origin_; } |
---|
| 67 | |
---|
[1588] | 68 | /** Sets the rotation applied to this overlay.*/ |
---|
[1598] | 69 | void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); } |
---|
[1588] | 70 | |
---|
| 71 | /** Gets the rotation applied to this overlay, in degrees.*/ |
---|
[1598] | 72 | const Radian& getRotation() const { return this->angle_; } |
---|
[1588] | 73 | |
---|
| 74 | /** Adds the passed in angle to the rotation applied to this overlay. */ |
---|
[1598] | 75 | void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); } |
---|
[1588] | 76 | |
---|
[1604] | 77 | /** Sets the size of this overlay. */ |
---|
[1595] | 78 | void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); } |
---|
[1588] | 79 | |
---|
[1595] | 80 | /** Gets the current size (not corrected) */ |
---|
[1604] | 81 | Vector2 getUncorrectedSize() const { return this->size_; } |
---|
[1588] | 82 | |
---|
[1595] | 83 | /** Gets the current size (corrected) */ |
---|
[1604] | 84 | Vector2 getSize() const { return this->size_ * this->sizeCorrection_; } |
---|
[1595] | 85 | |
---|
| 86 | /** Gets the current size correction */ |
---|
| 87 | Vector2 getSizeCorrection() const { return this->sizeCorrection_; } |
---|
| 88 | |
---|
[1588] | 89 | /** Scales the overlay */ |
---|
[1595] | 90 | void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); } |
---|
[1588] | 91 | |
---|
| 92 | protected: |
---|
[1595] | 93 | virtual void changedVisibility(); |
---|
| 94 | virtual void sizeChanged(); |
---|
[1598] | 95 | virtual void angleChanged(); |
---|
| 96 | virtual void positionChanged(); |
---|
[1595] | 97 | float getWindowAspectRatio() { return windowAspectRatio_; } |
---|
[1590] | 98 | |
---|
[1588] | 99 | Ogre::Overlay* overlay_; |
---|
[1595] | 100 | |
---|
| 101 | private: |
---|
| 102 | void windowResized(int newWidth, int newHeight); |
---|
| 103 | |
---|
[1590] | 104 | float windowAspectRatio_; |
---|
[1595] | 105 | bool bCorrectAspect_; |
---|
| 106 | Vector2 size_; |
---|
| 107 | Vector2 sizeCorrection_; |
---|
[1598] | 108 | Radian angle_; |
---|
| 109 | Vector2 position_; |
---|
| 110 | Vector2 origin_; |
---|
[1588] | 111 | |
---|
[1590] | 112 | static unsigned int hudOverlayCounter_s; |
---|
[1588] | 113 | }; |
---|
| 114 | } |
---|
| 115 | |
---|
[1601] | 116 | #endif /* _OrxonoxOverlay_H__ */ |
---|