Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDHealthBar.h @ 2662

Last change on this file since 2662 was 2369, checked in by landauf, 16 years ago
  • Added a health bar
  • Some changes in CameraManager to handle the case when no camera exists after removing the last one, but this is still somehow buggy (freezes and later crashes reproducible but inexplicable after a few respawns)
  • Added PawnManager to handle destruction of Pawns without using delete within tick()
  • Property svn:eol-style set to native
File size: 4.6 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _HUDHealthBar_H__
30#define _HUDHealthBar_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "HUDBar.h"
35#include "objects/Tickable.h"
36#include "overlays/OverlayText.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport HUDHealthBar : public HUDBar, public Tickable
41    {
42        public:
43            HUDHealthBar(BaseObject* creator);
44            ~HUDHealthBar();
45
46            virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
47            virtual void tick(float dt);
48            virtual void changedOwner();
49            virtual void changedOverlayGroup();
50            virtual void changedVisibility();
51            virtual void changedName();
52
53            inline void setTextFont(const std::string& font)
54                { if (font != "") { this->textoverlay_->setFont(font); } }
55            inline const std::string& getTextFont() const
56                { return this->textoverlay_->getFont(); }
57
58            void setTextColour(const ColourValue& colour);
59            inline const ColourValue& getTextColour() const
60                { return this->textoverlay_->getColour(); }
61
62            void setTextUseBarColour(bool bUseBarColour);
63            inline bool getTextUseBarColour() const
64                { return this->bUseBarColour_; }
65
66            inline void setTextAlignment(Ogre::TextAreaOverlayElement::Alignment alignment)
67                { this->textoverlay_->setAlignment(alignment); }
68            inline Ogre::TextAreaOverlayElement::Alignment getTextAlignment() const
69                { return this->textoverlay_->getAlignment(); }
70
71            void setTextAlignmentString(const std::string& alignment)
72                { this->textoverlay_->setAlignmentString(alignment); }
73            std::string getTextAlignmentString() const
74                { return this->textoverlay_->getAlignmentString(); }
75
76            inline void setTextSize(float size)
77                { this->textoverlay_->setTextSize(size); }
78            inline float getTextSize() const
79                { return this->textoverlay_->getTextSize(); }
80
81            inline void setTextVisible(bool bVisible)
82                { this->textoverlay_->setVisible(bVisible); }
83            inline bool getTextVisible() const
84                { return this->textoverlay_->isVisible(); }
85
86            inline void setTextPickPoint(const Vector2& pickpoint)
87                { this->textoverlay_->setPickPoint(pickpoint); }
88            inline Vector2 getTextPickPoint() const
89                { return this->textoverlay_->getPickPoint(); }
90
91            inline void setTextOffset(const Vector2& position)
92                { this->textoverlay_->setPosition(this->getPosition() + (position - this->getPickPoint()) * this->getSize()); }
93            inline Vector2 getTextOffset() const
94                { return (this->textoverlay_->getPosition() - this->getPosition()) / this->getSize() + this->getPickPoint(); }
95
96            inline void setTextAspectCorrection(bool correct)
97                { this->textoverlay_->setAspectCorrection(correct); }
98            inline bool getTextAspectCorrection() const
99                { return this->textoverlay_->getAspectCorrection(); }
100
101            inline void setTextRotation(const Degree& angle)
102                { this->textoverlay_->setRotation(angle); }
103            inline const Degree& getTextRotation() const
104                { return this->textoverlay_->getRotation(); }
105
106            inline void setTextSpaceWidth(float width)
107                { this->textoverlay_->setSpaceWidth(width); }
108            inline float getTextSpaceWidth() const
109                { return this->textoverlay_->getSpaceWidth(); }
110
111        private:
112            Pawn* owner_;
113            OverlayText* textoverlay_;
114            bool bUseBarColour_;
115            ColourValue textColour_;
116    };
117}
118#endif /* _HUDHealthBar_H__ */
Note: See TracBrowser for help on using the repository browser.