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 | |
---|
29 | #ifndef _HUDOverlay_H__ |
---|
30 | #define _HUDOverlay_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | |
---|
34 | #include <OgrePrerequisites.h> |
---|
35 | #include "tools/WindowEventListener.h" |
---|
36 | #include "util/Math.h" |
---|
37 | #include "core/BaseObject.h" |
---|
38 | |
---|
39 | namespace orxonox |
---|
40 | { |
---|
41 | class _OrxonoxExport HUDOverlay : public BaseObject, public WindowEventListener |
---|
42 | { |
---|
43 | public: |
---|
44 | HUDOverlay(); |
---|
45 | virtual ~HUDOverlay(); |
---|
46 | |
---|
47 | virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); |
---|
48 | |
---|
49 | void setAspectCorrection(bool val); |
---|
50 | bool getAspectCorrection() { return this->bCorrectAspect_; } |
---|
51 | |
---|
52 | /** Sets the position of this overlay. */ |
---|
53 | void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); } |
---|
54 | |
---|
55 | /** Gets the current position. */ |
---|
56 | Vector2 getPosition() const { return this->position_; } |
---|
57 | |
---|
58 | /** Scrolls the overlay by the offsets provided. */ |
---|
59 | void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); } |
---|
60 | |
---|
61 | /** Sets the origin point of this overlay. */ |
---|
62 | void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); } |
---|
63 | |
---|
64 | /** Gets the origin point of this overlay */ |
---|
65 | Vector2 getOrigin() const { return this->origin_; } |
---|
66 | |
---|
67 | /** Sets the rotation applied to this overlay.*/ |
---|
68 | void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); } |
---|
69 | |
---|
70 | /** Gets the rotation applied to this overlay, in degrees.*/ |
---|
71 | const Radian& getRotation() const { return this->angle_; } |
---|
72 | |
---|
73 | /** Adds the passed in angle to the rotation applied to this overlay. */ |
---|
74 | void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); } |
---|
75 | |
---|
76 | /** Sets the scaling factor of this overlay. */ |
---|
77 | void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); } |
---|
78 | |
---|
79 | /** Gets the current size (not corrected) */ |
---|
80 | Vector2 getSize() const { return this->size_; } |
---|
81 | |
---|
82 | /** Gets the current size (corrected) */ |
---|
83 | Vector2 getActualSize() const { return this->size_ * this->sizeCorrection_; } |
---|
84 | |
---|
85 | /** Gets the current size correction */ |
---|
86 | Vector2 getSizeCorrection() const { return this->sizeCorrection_; } |
---|
87 | |
---|
88 | /** Scales the overlay */ |
---|
89 | void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); } |
---|
90 | |
---|
91 | protected: |
---|
92 | virtual void changedVisibility(); |
---|
93 | virtual void sizeChanged(); |
---|
94 | virtual void angleChanged(); |
---|
95 | virtual void positionChanged(); |
---|
96 | float getWindowAspectRatio() { return windowAspectRatio_; } |
---|
97 | |
---|
98 | Ogre::Overlay* overlay_; |
---|
99 | |
---|
100 | private: |
---|
101 | void windowResized(int newWidth, int newHeight); |
---|
102 | |
---|
103 | float windowAspectRatio_; |
---|
104 | bool bCorrectAspect_; |
---|
105 | Vector2 size_; |
---|
106 | Vector2 sizeCorrection_; |
---|
107 | Radian angle_; |
---|
108 | Vector2 position_; |
---|
109 | Vector2 origin_; |
---|
110 | |
---|
111 | static unsigned int hudOverlayCounter_s; |
---|
112 | }; |
---|
113 | } |
---|
114 | |
---|
115 | #endif /* _HUDOverlay_H__ */ |
---|