Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/formationupdate/src/modules/overlays/hud/HUDBar.h @ 10111

Last change on this file since 10111 was 8706, checked in by dafrick, 13 years ago

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

  • Property svn:eol-style set to native
File size: 3.9 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 *      Yuning Chai
24 *   Co-authors:
25 *      Felix Schulthess
26 *      Fabian 'x3n' Landau
27 *      Reto Grieder
28 *      Benjamin Knecht
29 *
30 */
31
32#ifndef _HUDBar_H__
33#define _HUDBar_H__
34
35#include "overlays/OverlaysPrereqs.h"
36
37#include <map>
38#include <vector>
39
40#include "util/Math.h"
41#include "util/OgreForwardRefs.h"
42#include "core/BaseObject.h"
43#include "overlays/OrxonoxOverlay.h"
44
45namespace orxonox
46{
47    class _OverlaysExport BarColour : public BaseObject
48    {
49    public:
50        BarColour(BaseObject* creator);
51        virtual ~BarColour() { }
52
53        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
54
55        void setColour(const ColourValue& colour) { this->colour_ = colour; }
56        const ColourValue& getColour() const { return this->colour_; }
57
58        void setPosition(float pos) { this->position_ = pos; }
59        float getPosition() const    { return this->position_; }
60
61    private:
62        ColourValue colour_;
63        float position_;
64    };
65
66
67    class _OverlaysExport HUDBar : public OrxonoxOverlay
68    {
69    public:
70        HUDBar(BaseObject* creator);
71        virtual ~HUDBar();
72
73        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
74
75        void clearColours();
76
77        inline void setRightToLeft(bool r2l)
78        {
79            if (r2l != this->right2Left_)
80            {
81                this->right2Left_ = r2l;
82                this->valueChanged();
83            }
84        }
85        inline bool getRightToLeft() const
86            { return this->right2Left_; }
87
88        inline void setValue(float value)
89        {
90            float temp = clamp(value, 0.0f, 1.0f);
91            if (temp != this->value_)
92            {
93                this->value_ = temp;
94                this->valueChanged();
95            }
96        }
97        inline float getValue() const
98            { return this->value_; }
99
100        inline void setAutoColour(bool val)
101        {
102            if (val != this->autoColour_)
103            {
104                this->autoColour_ = val;
105                this->valueChanged();
106
107                if (!val)
108                    this->currentColour_ = ColourValue::White;
109            }
110        }
111        inline bool getAutoColour() const
112            { return this->autoColour_; }
113
114        void setBarTexture(const std::string& texture);
115        const std::string& getBarTexture() const;
116
117        inline const ColourValue& getCurrentBarColour() const
118            { return this->currentColour_; }
119
120    protected:
121        virtual void valueChanged();
122
123    private:
124        void addColour(BarColour* colour);
125        BarColour* getColour(unsigned int index);
126
127        bool right2Left_;
128        bool autoColour_;                   //!< whether bar changes colour automatically
129        float value_;                       //!< progress of bar
130        ColourValue currentColour_;
131
132        Ogre::PanelOverlayElement* bar_;
133        Ogre::TextureUnitState* textureUnitState_;
134        std::map<float, ColourValue> colours_;
135        std::vector<BarColour*> barColours_;
136
137        static unsigned int materialcount_s;
138    };
139}
140#endif /* _HUDBar_H__ */
Note: See TracBrowser for help on using the repository browser.