Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/HUDHealthBar.h @ 11071

Last change on this file since 11071 was 11071, checked in by landauf, 8 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 4.7 KB
RevLine 
[2369]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
[5693]32#include "overlays/OverlaysPrereqs.h"
[2369]33
[3196]34#include "util/Math.h"
[5693]35#include "tools/interfaces/Tickable.h"
[3196]36#include "overlays/OverlayText.h"
[2369]37#include "HUDBar.h"
38
39namespace orxonox
40{
[5693]41    class _OverlaysExport HUDHealthBar : public HUDBar, public Tickable
[2369]42    {
43        public:
[9667]44            HUDHealthBar(Context* context);
[3196]45            virtual ~HUDHealthBar();
[2369]46
[11071]47            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
48            virtual void tick(float dt) override;
49            virtual void changedOwner() override;
50            virtual void changedOverlayGroup() override;
51            virtual void changedVisibility() override;
52            virtual void changedName() override;
[2369]53
54            inline void setTextFont(const std::string& font)
[6417]55                { if (!font.empty()) { this->textoverlay_->setFont(font); } }
[2369]56            inline const std::string& getTextFont() const
57                { return this->textoverlay_->getFont(); }
58
59            void setTextColour(const ColourValue& colour);
60            inline const ColourValue& getTextColour() const
61                { return this->textoverlay_->getColour(); }
62
63            void setTextUseBarColour(bool bUseBarColour);
64            inline bool getTextUseBarColour() const
65                { return this->bUseBarColour_; }
66
[3196]67            inline void setTextAlignment(OverlayText::Alignment alignment)
[2369]68                { this->textoverlay_->setAlignment(alignment); }
[3196]69            inline OverlayText::Alignment getTextAlignment() const
[2369]70                { return this->textoverlay_->getAlignment(); }
71
72            void setTextAlignmentString(const std::string& alignment)
73                { this->textoverlay_->setAlignmentString(alignment); }
74            std::string getTextAlignmentString() const
75                { return this->textoverlay_->getAlignmentString(); }
76
77            inline void setTextVisible(bool bVisible)
78                { this->textoverlay_->setVisible(bVisible); }
79            inline bool getTextVisible() const
80                { return this->textoverlay_->isVisible(); }
81
[11052]82            inline void setTextScale(float scale)
83                { this->textScale_ = scale;
84                  positionText();
85                }
86            inline float getTextScale() const
87                { return this->textScale_; }
88
[2369]89            inline void setTextPickPoint(const Vector2& pickpoint)
90                { this->textoverlay_->setPickPoint(pickpoint); }
91            inline Vector2 getTextPickPoint() const
92                { return this->textoverlay_->getPickPoint(); }
93
94            inline void setTextOffset(const Vector2& position)
[11052]95                { this->textOffset_ = position;
96                  this->positionText();
97                }
[2369]98            inline Vector2 getTextOffset() const
[11052]99                { return this->textOffset_; }
[2369]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
[9259]111            inline void setHealthBarOwner(Pawn* owner)
112                { this->owner_ = owner; }
[11052]113        protected:
[11071]114            virtual void positionChanged() override;
115            virtual void sizeChanged() override;
[2369]116        private:
[11071]117            void positionText();
[5929]118            WeakPtr<Pawn> owner_;
[10624]119            StrongPtr<OverlayText> textoverlay_;
[2369]120            bool bUseBarColour_;
121            ColourValue textColour_;
[11052]122            Vector2 textOffset_;
123            float textScale_;
[2369]124    };
125}
126#endif /* _HUDHealthBar_H__ */
Note: See TracBrowser for help on using the repository browser.