Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/HUDBar.h @ 10302

Last change on this file since 10302 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 3.9 KB
RevLine 
[1588]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
[8706]28 *      Benjamin Knecht
[1588]29 *
30 */
31
32#ifndef _HUDBar_H__
33#define _HUDBar_H__
34
[5693]35#include "overlays/OverlaysPrereqs.h"
[1588]36
[1614]37#include <map>
[3196]38#include <vector>
39
[1588]40#include "util/Math.h"
[3196]41#include "util/OgreForwardRefs.h"
42#include "core/BaseObject.h"
[1601]43#include "overlays/OrxonoxOverlay.h"
[1588]44
45namespace orxonox
46{
[5693]47    class _OverlaysExport BarColour : public BaseObject
[1618]48    {
49    public:
[9667]50        BarColour(Context* context);
[3196]51        virtual ~BarColour() { }
[1618]52
[7401]53        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[1618]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
[1627]66
[5693]67    class _OverlaysExport HUDBar : public OrxonoxOverlay
[1615]68    {
[1588]69    public:
[9667]70        HUDBar(Context* context);
[1615]71        virtual ~HUDBar();
[1588]72
[7401]73        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[1588]74
[1615]75        void clearColours();
[1588]76
[2662]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_; }
[1588]87
[2662]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_; }
[1627]99
[2662]100        inline void setAutoColour(bool val)
101        {
102            if (val != this->autoColour_)
103            {
104                this->autoColour_ = val;
105                this->valueChanged();
[1627]106
[2662]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
[1627]120    protected:
121        virtual void valueChanged();
122
[1588]123    private:
[1618]124        void addColour(BarColour* colour);
125        BarColour* getColour(unsigned int index);
126
[1615]127        bool right2Left_;
128        bool autoColour_;                   //!< whether bar changes colour automatically
129        float value_;                       //!< progress of bar
[2662]130        ColourValue currentColour_;
[1588]131
[1615]132        Ogre::PanelOverlayElement* bar_;
133        Ogre::TextureUnitState* textureUnitState_;
134        std::map<float, ColourValue> colours_;
[1618]135        std::vector<BarColour*> barColours_;
[1615]136
137        static unsigned int materialcount_s;
[1588]138    };
139}
140#endif /* _HUDBar_H__ */
Note: See TracBrowser for help on using the repository browser.