Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h @ 11185

Last change on this file since 11185 was 11185, checked in by sagerj, 8 years ago

fix the charging during reloadtime, the hudchargebar working so far…

File size: 4.9 KB
Line 
1
2/*
3 *   ORXONOX - the hottest 3D action shooter ever to exist
4 *                    > www.orxonox.net <
5 *
6 *
7 *   License notice:
8 *
9 *   This program is free software; you can redistribute it and/or
10 *   modify it under the terms of the GNU General Public License
11 *   as published by the Free Software Foundation; either version 2
12 *   of the License, or (at your option) any later version.
13 *
14 *   This program is distributed in the hope that it will be useful,
15 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *   GNU General Public License for more details.
18 *
19 *   You should have received a copy of the GNU General Public License
20 *   along with this program; if not, write to the Free Software
21 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 *
23 *   Author:
24 *      Fabian 'x3n' Landau
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30#ifndef _HUDHealthBar_H__
31#define _HUDHealthBar_H__
32
33#include "overlays/OverlaysPrereqs.h"
34
35#include "util/Math.h"
36#include "tools/interfaces/Tickable.h"
37#include "overlays/OverlayText.h"
38#include "HUDBar.h"
39#include "weaponsystem/WeaponSystem.h"
40#include "weaponsystem/WeaponPack.h"
41#include "weaponsystem/WeaponMode.h"
42#include "weaponsystem/Weapon.h"
43
44namespace orxonox
45{
46    class _OverlaysExport HUDChargeBar : public HUDBar, public Tickable
47    {
48        public:
49            HUDChargeBar(Context* context);
50            virtual ~HUDChargeBar();
51
52            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
53            virtual void tick(float dt) override;
54            virtual void changedOwner() override;
55            virtual void changedOverlayGroup() override;
56            virtual void changedVisibility() override;
57            virtual void changedName() override;
58
59            inline void setTextFont(const std::string& font)
60                { if (!font.empty()) { this->textoverlay_->setFont(font); } }
61            inline const std::string& getTextFont() const
62                { return this->textoverlay_->getFont(); }
63
64            void setTextColour(const ColourValue& colour);
65            inline const ColourValue& getTextColour() const
66                { return this->textoverlay_->getColour(); }
67
68            void setTextUseBarColour(bool bUseBarColour);
69            inline bool getTextUseBarColour() const
70                { return this->bUseBarColour_; }
71
72            inline void setTextAlignment(OverlayText::Alignment alignment)
73                { this->textoverlay_->setAlignment(alignment); }
74            inline OverlayText::Alignment getTextAlignment() const
75                { return this->textoverlay_->getAlignment(); }
76
77            void setTextAlignmentString(const std::string& alignment)
78                { this->textoverlay_->setAlignmentString(alignment); }
79            std::string getTextAlignmentString() const
80                { return this->textoverlay_->getAlignmentString(); }
81
82            inline void setTextVisible(bool bVisible)
83                { this->textoverlay_->setVisible(bVisible); }
84            inline bool getTextVisible() const
85                { return this->textoverlay_->isVisible(); }
86
87            inline void setTextScale(float scale)
88                { this->textScale_ = scale;
89                  positionText();
90                }
91            inline float getTextScale() const
92                { return this->textScale_; }
93
94            inline void setTextPickPoint(const Vector2& pickpoint)
95                { this->textoverlay_->setPickPoint(pickpoint); }
96            inline Vector2 getTextPickPoint() const
97                { return this->textoverlay_->getPickPoint(); }
98
99            inline void setTextOffset(const Vector2& position)
100                { this->textOffset_ = position;
101                  this->positionText();
102                }
103            inline Vector2 getTextOffset() const
104                { return this->textOffset_; }
105
106            inline void setTextRotation(const Degree& angle)
107                { this->textoverlay_->setRotation(angle); }
108            inline const Degree& getTextRotation() const
109                { return this->textoverlay_->getRotation(); }
110
111            inline void setTextSpaceWidth(float width)
112                { this->textoverlay_->setSpaceWidth(width); }
113            inline float getTextSpaceWidth() const
114                { return this->textoverlay_->getSpaceWidth(); }
115
116            inline void setHealthBarOwner(Pawn* owner)
117                { this->owner_ = owner; }
118        protected:
119            virtual void positionChanged() override;
120            virtual void sizeChanged() override;
121        private:
122            WeaponMode* correspondingMode_;
123            void positionText();
124            WeakPtr<Pawn> owner_;
125            StrongPtr<OverlayText> textoverlay_;
126            bool bUseBarColour_;
127            ColourValue textColour_;
128            Vector2 textOffset_;
129            float textScale_;
130    };
131}
132#endif /* _HUDChargeBar_H__ */
Note: See TracBrowser for help on using the repository browser.