Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/releasetodo/src/orxonox/LevelInfo.h @ 7626

Last change on this file since 7626 was 7626, checked in by dafrick, 14 years ago

Accidentally removed a file. Re-adding it.
Levels that are tagged with "test" are now not displayed by default, but can be displayed by choosing show all.

File size: 7.2 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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file LevelInfo.h
31    @brief Definition of the LevelInfo and LevelInfoItem class.
32    @ingroup Orxonox
33*/
34
35#ifndef _LevelInfo_H__
36#define _LevelInfo_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include <set>
41#include <string>
42
43#include "core/BaseObject.h"
44#include "core/OrxonoxClass.h"
45
46namespace orxonox // tolua_export
47{ // tolua_export
48
49    /**
50    @brief
51        The LevelInfoItem class stores information regarding a @ref orxonox::Level "Level" and makes that information it accessible trough the @ref orxonox::LevelManager "LevelManager".
52        A LevelInfoItem object is commonly created from a @ref orxonox::LevelInfo "LevelInfo" object, using its <code>copy()</code> method.
53
54    @author
55        Damian 'Mozork' Frick
56    */
57    class _OrxonoxExport LevelInfoItem // tolua_export
58        : virtual public OrxonoxClass
59    { // tolua_export
60        public:
61            LevelInfoItem(); //!< Default constructor.
62            LevelInfoItem(const std::string& name, const std::string filename); //!< Constructor. Initializes the object.
63            virtual ~LevelInfoItem(); //!< Destructor.
64
65            /**
66            @brief Set the name of the Level.
67            @param name The name to be set.
68            */
69            inline void setName(const std::string& name)
70                { this->name_ = std::string(name); }
71            /**
72            @brief Get the name of the Level.
73            @return Returns the name of the Level.
74            */
75            inline const std::string& getName(void) { return this->name_; } // tolua_export
76
77            /**
78            @brief Set the description of the Level.
79            @param description The description to be set.
80            */
81            inline void setDescription(const std::string& description)
82                { this->description_ = std::string(description); }
83            /**
84            @brief Get the description of the Level.
85            @return Returns the description of the Level.
86            */
87            inline const std::string& getDescription() const { return this->description_; } // tolua_export
88
89            void setTags(const std::string& tags); //!< Set the tags the Level is tagged with.
90            bool addTag(const std::string& tag, bool update = true); //!< Add a tag to the set of tags the Level is tagged with.
91            /**
92            @brief Get the lis of the tags the Level is tagged with.
93            @return Returns a comma-seperated string of all the tags the Level is tagged with.
94            */
95            inline const std::string& getTags(void) const
96                { return this->tagsString_; }
97            /**
98            @brief Get whether the Level has a specific tag.
99            @param tag The tag for which is checked.
100            @return Returns true if the Level is tagged with the input tag.
101            */
102            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
103
104            /**
105            @brief Get the XML-filename of the Level.
106            @return Returns the XML-filename (including *.oxw extension) of the Level.
107            */
108            inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export
109
110        protected:
111            /**
112            @brief Set the XML-filename of the Level.
113            @param filename The XML-filename to be set.
114            */
115            inline void setXMLFilename(const std::string& filename)
116                { this->xmlfilename_ = std::string(filename); }
117
118            std::string xmlfilename_; //!< The XML-filename of the Level.
119
120        private:
121            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
122
123            std::string name_; //!< The name of the Level.
124            std::string description_; //!< The description of the Level.
125            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
126            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
127    }; // tolua_export
128
129    /**
130    @brief
131        The LevelInfo class can be used to store information regarding a @ref orxonox::Level "Level" in its level file.
132        The following parameters can be specified:
133        - @b name The name of the level.
134        - @b description The description of the level.
135        - @b tags A comma-seperated string of tags.
136
137        An example would be:
138        @code
139        <LevelInfo
140            name = "Levelname"
141            description = "This is just some awesome level."
142            tags = "test, awesome"
143        />
144        @endcode
145        The LevelInfo is best located at the top of the level file.
146
147    @author
148        Damian 'Mozork' Frick
149    */
150    class _OrxonoxExport LevelInfo : public BaseObject, public LevelInfoItem
151    {
152        public:
153            LevelInfo(BaseObject* creator);
154            virtual ~LevelInfo();
155
156            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
157
158            /**
159            @brief Set the description of the Level.
160            @param description The description to be set.
161            */
162            inline void setDescription(const std::string& description)
163                { this->LevelInfoItem::setDescription(description); }
164            /**
165            @brief Get the description of the Level.
166            @return Returns the description of the Level.
167            */
168            inline const std::string& getDescription() const
169                { return this->LevelInfoItem::getDescription(); }
170
171            /**
172            @brief Set the tags the Level is tagged with.
173            @param tags A comma-seperated string of all the tags to be set.
174            */
175            inline void setTags(const std::string& tags)
176                { this->LevelInfoItem::setTags(tags); }
177            /**
178            @brief Get the lis of the tags the Level is tagged with.
179            @return Returns a comma-seperated string of all the tags the Level is tagged with.
180            */
181            inline const std::string& getTags(void) const
182                { return this->LevelInfoItem::getTags(); }
183
184            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
185
186    };
187} // tolua_export
188
189#endif /* _LevelInfo_H__ */
Note: See TracBrowser for help on using the repository browser.