Orxonox  0.0.5 Codename: Arcturus
LevelInfo.h
Go to the documentation of this file.
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 
35 #ifndef _LevelInfo_H__
36 #define _LevelInfo_H__
37 
38 #include "OrxonoxPrereqs.h"
39 
40 #include <set>
41 #include <string>
42 #include "util/StringUtils.h"
43 
44 #include "core/BaseObject.h"
45 #include <iostream>
46 #include <fstream>
48 
49 namespace orxonox // tolua_export
50 { // tolua_export
51 
62  class _OrxonoxExport LevelInfoItem // tolua_export
63  : virtual public OrxonoxInterface
64  { // tolua_export
65  public:
66  LevelInfoItem();
67  LevelInfoItem(const std::string& name, const std::string filename);
68  virtual ~LevelInfoItem();
69 
74  inline void setName(const std::string& name)
75  { this->name_ = std::string(name); }
80  inline const std::string& getName(void) const { return this->name_; } // tolua_export
81 
86  inline void setScreenshot(const std::string& screenshot) { this->screenshot_ = std::string(screenshot); }
91  inline const std::string& getScreenshot() const { return this->screenshot_; } // tolua_export
92 
97  inline void setDescription(const std::string& description)
98  { this->description_ = std::string(description); }
103  inline const std::string& getDescription() const { return this->description_; } // tolua_export
104 
105  void setTags(const std::string& tags);
106  bool addTag(const std::string& tag, bool update = true);
107 
111  inline const std::string& getTags(void) const
112  { return this->tagsString_; }
118  inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
119 
120  void setStartingShips(const std::string& ships);
121  bool addStartingShip(const std::string& ship, bool update = true);
122 
126  inline const std::string& getStartingShips(void) const
127  { return this->startingShipsString_; }
133  inline bool hasStartingShip(const std::string& ship) const { return this->startingShips_.find(ship) != this->startingShips_.end(); } // tolua_export
134  inline void selectStartingShip(const std::string& ship) { this->changeStartingShip(ship); } // tolua_export
139  inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
140 
141 
142  protected:
147  inline void setXMLFilename(const std::string& filename)
148  { this->xmlfilename_ = std::string(filename); }
149 
151 
152  private:
153  void changeStartingShip (const std::string& model);
154  void startingshipsUpdated(void);
155  void tagsUpdated(void);
156  static void initializeTags(void);
157 
162  static bool validateTag(const std::string& tag)
164 
165  static std::set<std::string> possibleTags_s;
166  static const bool initialized_s = false;
167 
171  std::set<std::string> tags_;
173  std::set<std::string> startingShips_;
175  }; // tolua_export
176 
203  {
204  public:
205  LevelInfo(Context* context);
206  virtual ~LevelInfo();
207 
208  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
209 
214  inline void setScreenshot(const std::string& screenshot) { this->LevelInfoItem::setScreenshot(screenshot); }
219  inline const std::string& getScreenshot() const { return this->LevelInfoItem::getScreenshot(); }
220 
225  inline void setDescription(const std::string& description)
226  { this->LevelInfoItem::setDescription(description); }
231  inline const std::string& getDescription() const
232  { return this->LevelInfoItem::getDescription(); }
233 
238  inline void setTags(const std::string& tags)
239  { this->LevelInfoItem::setTags(tags); }
244  inline const std::string& getTags(void) const
245  { return this->LevelInfoItem::getTags(); }
250  inline void setStartingShips(const std::string& ships)
251  { this->LevelInfoItem::setStartingShips(ships); }
256  inline const std::string& getStartingShips(void) const
257  { return this->LevelInfoItem::getStartingShips(); }
258 
259  LevelInfoItem* copy(void);
260  };
261 
269  {
270  bool operator() (const LevelInfoItem* lhs, const LevelInfoItem* rhs) const
271  {
272  if(getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) == 0)
273  return getLowercase(lhs->getXMLFilename()).compare(getLowercase(rhs->getXMLFilename())) < 0;
274  return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0;
275  }
276  };
277 
278 } // tolua_export
279 
280 #endif /* _LevelInfo_H__ */
The BaseObject is the parent of all classes representing an instance in the game. ...
Definition: BaseObject.h:63
void setStartingShips(const std::string &ships)
Set the starting ship models of the level.
Definition: LevelInfo.cc:120
const std::string & getName(void) const
Get the name of the Level.
Definition: LevelInfo.h:80
std::set< std::string > startingShips_
The set of starting ship models the Level allows.
Definition: LevelInfo.h:173
void setDescription(const std::string &description)
Set the description of the Level.
Definition: LevelInfo.h:225
std::string startingShipsString_
The comma-seperated string of all the allowed ship models for the shipselection.
Definition: LevelInfo.h:174
const std::string & getTags(void) const
Get the lis of the tags the Level is tagged with.
Definition: LevelInfo.h:111
void setTags(const std::string &tags)
Set the tags the Level is tagged with.
Definition: LevelInfo.h:238
std::string screenshot_
The screenshot of the Level.
Definition: LevelInfo.h:170
bool hasStartingShip(const std::string &ship) const
Get whether the Level allows a specific starting ship model.
Definition: LevelInfo.h:133
::std::string string
Definition: gtest-port.h:756
std::string description_
The description of the Level.
Definition: LevelInfo.h:169
void setScreenshot(const std::string &screenshot)
Set the screenshot of the Level.
Definition: LevelInfo.h:214
const std::string & getDescription() const
Get the description of the Level.
Definition: LevelInfo.h:231
This is the class from which all interfaces of the game-logic (not the engine) are derived from...
Definition: OrxonoxInterface.h:50
const std::string & getStartingShips(void) const
Get the starting ship models of the level.
Definition: LevelInfo.h:256
const std::string & getXMLFilename(void) const
Get the XML-filename of the Level.
Definition: LevelInfo.h:139
std::string getLowercase(const std::string &str)
Returns a copy of the given string where all chars are converted to lowercase.
Definition: StringUtils.cc:342
std::set< std::string > tags_
The set of tags the Level is tagged with.
Definition: LevelInfo.h:171
std::string name_
The name of the Level.
Definition: LevelInfo.h:168
std::string xmlfilename_
The XML-filename of the Level.
Definition: LevelInfo.h:150
void setDescription(const std::string &description)
Set the description of the Level.
Definition: LevelInfo.h:97
xmlelement
Definition: Super.h:519
static bool validateTag(const std::string &tag)
Check whether an input tag is allowed.
Definition: LevelInfo.h:162
const std::string & getStartingShips(void) const
Get the set of starting ship models the Level allows.
Definition: LevelInfo.h:126
void setXMLFilename(const std::string &filename)
Set the XML-filename of the Level.
Definition: LevelInfo.h:147
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Declaration of OrxonoxInterface, the base class of all interfaces in Orxonox.
Struct that overloads the compare operation between two LevelInfoItem pointers.
Definition: LevelInfo.h:268
Mode
Definition: CorePrereqs.h:102
const std::string & getDescription() const
Get the description of the Level.
Definition: LevelInfo.h:103
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Declaration of BaseObject, the base class of all objects in Orxonox.
Definition: Context.h:45
Declaration of several string manipulation functions, used in many parts of the game.
The LevelInfo class can be used to store information regarding a Level in its level file...
Definition: LevelInfo.h:202
void setName(const std::string &name)
Set the name of the Level.
Definition: LevelInfo.h:74
void setStartingShips(const std::string &ships)
Set the starting ship models of the level.
Definition: LevelInfo.h:250
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
static void initializeTags(void)
Initialize the set of allowed tags.
Definition: LevelInfo.cc:84
bool hasTag(const std::string &tag) const
Get whether the Level has a specific tag.
Definition: LevelInfo.h:118
void setScreenshot(const std::string &screenshot)
Set the screenshot of the Level.
Definition: LevelInfo.h:86
void setTags(const std::string &tags)
Set the tags the Level is tagged with.
Definition: LevelInfo.cc:105
The LevelInfoItem class stores information regarding a Level and makes that information accessible th...
Definition: LevelInfo.h:62
static std::set< std::string > possibleTags_s
The set of allowed tags.
Definition: LevelInfo.h:165
internal::String name_
Definition: gtest.cc:2289
const std::string & getScreenshot() const
Get the screenshot of the Level.
Definition: LevelInfo.h:91
const std::string & getTags(void) const
Get the lis of the tags the Level is tagged with.
Definition: LevelInfo.h:244
std::string tagsString_
The comma-seperated string of all the tags the Level is tagged with.
Definition: LevelInfo.h:172
void selectStartingShip(const std::string &ship)
Definition: LevelInfo.h:134
const std::string & getScreenshot() const
Get the screenshot of the Level.
Definition: LevelInfo.h:219