Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ai/src/orxonox/LevelInfo.h @ 7922

Last change on this file since 7922 was 7652, checked in by landauf, 14 years ago

eol-style native

  • Property svn:eol-style set to native
File size: 8.0 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            static void initializeTags(void); //!< Initialize the set of allowed tags.
124            /**
125            @brief Check whether an input tag is allowed.
126            @param tag The tag to check.
127            @return Returns true if the input tag is allowed, false if not.
128            */
129            static bool validateTag(const std::string& tag)
130                { LevelInfoItem::initializeTags(); return LevelInfoItem::possibleTags_s.find(tag) != LevelInfoItem::possibleTags_s.end(); }
131
132            static std::set<std::string> possibleTags_s; //!< The set of allowed tags.
133            static const bool initialized_s = false; //!< Whether the set of allowed tags has been inizialized.
134
135            std::string name_; //!< The name of the Level.
136            std::string description_; //!< The description of the Level.
137            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
138            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
139    }; // tolua_export
140
141    /**
142    @brief
143        The LevelInfo class can be used to store information regarding a @ref orxonox::Level "Level" in its level file.
144        The following parameters can be specified:
145        - @b name The name of the level.
146        - @b description The description of the level.
147        - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>.
148
149        An example would be:
150        @code
151        <LevelInfo
152            name = "Levelname"
153            description = "This is just some awesome level."
154            tags = "test, awesome"
155        />
156        @endcode
157        The LevelInfo is best located at the top of the level file.
158
159    @author
160        Damian 'Mozork' Frick
161    */
162    class _OrxonoxExport LevelInfo : public BaseObject, public LevelInfoItem
163    {
164        public:
165            LevelInfo(BaseObject* creator);
166            virtual ~LevelInfo();
167
168            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
169
170            /**
171            @brief Set the description of the Level.
172            @param description The description to be set.
173            */
174            inline void setDescription(const std::string& description)
175                { this->LevelInfoItem::setDescription(description); }
176            /**
177            @brief Get the description of the Level.
178            @return Returns the description of the Level.
179            */
180            inline const std::string& getDescription() const
181                { return this->LevelInfoItem::getDescription(); }
182
183            /**
184            @brief Set the tags the Level is tagged with.
185            @param tags A comma-seperated string of all the tags to be set.
186            */
187            inline void setTags(const std::string& tags)
188                { this->LevelInfoItem::setTags(tags); }
189            /**
190            @brief Get the lis of the tags the Level is tagged with.
191            @return Returns a comma-seperated string of all the tags the Level is tagged with.
192            */
193            inline const std::string& getTags(void) const
194                { return this->LevelInfoItem::getTags(); }
195
196            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
197
198    };
199} // tolua_export
200
201#endif /* _LevelInfo_H__ */
Note: See TracBrowser for help on using the repository browser.