Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/overlays/OverlayGroup.h @ 3002

Last change on this file since 3002 was 2911, checked in by landauf, 16 years ago

Merged r1-2096 of questsystem5 back to trunk

I hope there weren't more "hidden merge changes" in r2909 than the one in OverlayGroup (removeElement) (and related to this the adjustments in NotificationQueue).

The corresponding media commit seems not yet to be done, but it doesn't break the build.

  • Property svn:eol-style set to native
File size: 3.5 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 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30@file
31@brief Declaration of the OverlayGroup class.
32*/
33
34#ifndef _OverlayGroup_H__
35#define _OverlayGroup_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include <set>
40#include <OgrePrerequisites.h>
41#include "core/BaseObject.h"
42#include "util/Math.h"
43
44namespace orxonox
45{
46    /**
47    @brief
48        OverlayGroup does almost exactly what it says: It groups OrxonoxOverlays together.
49        You can scroll the entire group by a certain amount. Scale however works differently
50        than expected: Each OrxonoxOverlay scales individually. That's quite useful when you
51        create your HUD with an OverlayGroup and then want to alter its size.
52    */
53    class _OrxonoxExport OverlayGroup : public BaseObject
54    {
55    public:
56        OverlayGroup(BaseObject* creator);
57        //! Empty destructor.
58        ~OverlayGroup();
59
60        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
61
62        static void toggleVisibility(const std::string& name);
63        static void scaleGroup(const std::string& name, float scale);
64        static void scrollGroup(const std::string& name, const Vector2& scroll);
65
66        inline const std::set<OrxonoxOverlay*>& getOverlays() const
67            { return this->hudElements_; }
68
69        void changedVisibility();
70
71        void setOwner(BaseObject* owner);
72        inline BaseObject* getOwner() const
73            { return this->owner_; }
74
75        //! Scales each OrxonoxOverlay individually by scale.
76        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
77        void setScale(const Vector2& scale);
78        //! Returns the current size of the group.
79        Vector2 getScale() const { return this->scale_; }
80
81        //! Scrolls each OrxonoxOverlay individually by scroll.
82        void scroll(const Vector2& scroll) { this->setScroll(scroll + this->scroll_); }
83        void setScroll(const Vector2& scroll);
84        //! Returns the current scrolling offset of the group.
85        Vector2 getScroll() const { return this->scale_; }
86
87        void addElement(OrxonoxOverlay* element);
88        bool removeElement(OrxonoxOverlay* element);
89        OrxonoxOverlay* getElement(unsigned int index);
90
91    private:
92        std::set<OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
93        Vector2 scale_;                            //!< Current scale (independent of the elements).
94        Vector2 scroll_;                           //!< Current scrolling offset.
95        BaseObject* owner_;                        //!< The owner of this OverlayGroup
96    };
97}
98
99#endif /* _OverlayGroup_H__ */
Note: See TracBrowser for help on using the repository browser.