Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.h @ 1614

Last change on this file since 1614 was 1614, checked in by rgrieder, 16 years ago
  • Dots on the Radar actually disappear now when a Ship gets destroyed…
  • svn save to keep History of HUDText when renaming AND moving
  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
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 _OrxonoxOverlay_H__
30#define _OrxonoxOverlay_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
39namespace orxonox
40{
41    class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener
42    {
43    public:
44        Ogre::Overlay* getOverlay() { return this->overlay_; }
45        OrxonoxOverlay();
46        virtual ~OrxonoxOverlay();
47
48        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
49
50        void show() { this->setVisibility(true); }
51        void hide() { this->setVisibility(false); }
52
53        void setAspectCorrection(bool val);
54        bool getAspectCorrection() { return this->bCorrectAspect_; }
55
56        /** Sets the position of this overlay. */
57        void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }
58
59        /** Gets the current position. */
60        Vector2 getPosition() const { return this->position_; }
61
62        /** Scrolls the overlay by the offsets provided. */
63        void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }
64
65        /** Sets the origin point of this overlay. */
66        void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }
67
68        /** Gets the origin point of this overlay */
69        Vector2 getOrigin() const { return this->origin_; }
70
71        /** Sets the rotation applied to this overlay.*/
72        void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }
73
74        /** Gets the rotation applied to this overlay, in degrees.*/
75        const Radian& getRotation() const { return this->angle_; }
76
77        /** Adds the passed in angle to the rotation applied to this overlay. */
78        void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }
79
80        /** Sets the size of this overlay. */
81        void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); }
82
83        /** Gets the current size (not corrected) */
84        Vector2 getUncorrectedSize() const { return this->size_; }
85
86        /** Gets the current size (corrected) */
87        Vector2 getSize() const { return this->size_ * this->sizeCorrection_; }
88
89        /** Gets the current size correction */
90        Vector2 getSizeCorrection() const { return this->sizeCorrection_; }
91
92        /** Scales the overlay */
93        void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); }
94
95    protected:
96        virtual void changedVisibility();
97        virtual void sizeChanged();
98        virtual void angleChanged();
99        virtual void positionChanged();
100        float getWindowAspectRatio() { return windowAspectRatio_; }
101
102        void setBackgroundMaterial(const std::string& material);
103        std::string getBackgroundMaterial() const;
104
105        Ogre::Overlay* overlay_;
106        Ogre::PanelOverlayElement* background_;
107
108    private:
109        void windowResized(int newWidth, int newHeight);
110
111        float windowAspectRatio_;
112        bool bCorrectAspect_;
113        Vector2 size_;
114        Vector2 sizeCorrection_;
115        Radian angle_;
116        Vector2 position_;
117        Vector2 origin_;
118
119        static unsigned int hudOverlayCounter_s;
120  };
121}
122
123#endif /* _OrxonoxOverlay_H__ */
Note: See TracBrowser for help on using the repository browser.