Changeset 7625 for code/branches/releasetodo
- Timestamp:
- Nov 6, 2010, 8:17:20 PM (14 years ago)
- Location:
- code/branches/releasetodo
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua
r7163 r7625 6 6 listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox") 7 7 preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 8 orxonox.LevelManager:getInstance():compileAvailableLevelList()8 size = orxonox.LevelManager:getInstance():getNumberOfLevels() 9 9 local levelList = {} 10 10 local index = 0 11 11 local level = "" 12 while true do12 while index < size do 13 13 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 14 if level == "" then15 break16 end17 14 table.insert(levelList, level) 18 15 index = index + 1 -
code/branches/releasetodo/data/levels/empty_level.oxw
r7163 r7625 1 <LevelInfo 2 name = "Empty level" 3 description = "A level with absolutely nothing in it." 4 tags = "test, empty" 5 /> 6 1 7 <?lua 2 8 include("stats.oxo") -
code/branches/releasetodo/data/levels/notifications.oxw
r7614 r7625 1 <LevelInfo 2 name = "Notifications showcase" 3 description = "Level to test and showcase notifications." 4 tags = "test, showcase, notifications" 5 /> 6 1 7 <?lua 2 8 include("hudtemplates3.oxo") … … 5 11 include("templates/lodinformation.oxt") 6 12 ?> 7 8 <LevelInfo9 name = "Notifications showcase"10 description = "Level to test and showcase notifications."11 tags = "test, showcase, notifications"12 />13 13 14 14 <Level -
code/branches/releasetodo/src/orxonox/LevelInfo.h
r7614 r7625 27 27 */ 28 28 29 /** 30 @file LevelInfo.h 31 @brief Definition of the LevelInfo and LevelInfoItem class. 32 @ingroup Orxonox 33 */ 34 29 35 #ifndef _LevelInfo_H__ 30 36 #define _LevelInfo_H__ … … 34 40 #include <set> 35 41 #include <string> 42 36 43 #include "core/BaseObject.h" 44 #include "core/OrxonoxClass.h" 37 45 38 namespace orxonox // tolua_export 39 { // tolua_export 40 class _OrxonoxExport LevelInfo // tolua_export 41 : public BaseObject 42 { // tolua_export 43 46 namespace orxonox 47 { 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 : virtual public OrxonoxClass 58 { 59 public: 60 LevelInfoItem(); //!< Default constructor. 61 LevelInfoItem(const std::string& name, const std::string filename); //!< Constructor. Initializes the object. 62 virtual ~LevelInfoItem(); //!< Destructor. 63 64 /** 65 @brief Set the name of the Level. 66 @param name The name to be set. 67 */ 68 inline void setName(const std::string& name) 69 { this->name_ = std::string(name); } 70 /** 71 @brief Get the name of the Level. 72 @return Returns the name of the Level. 73 */ 74 inline const std::string& getName(void) 75 { return this->name_; } 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 88 { return this->description_; } 89 90 void setTags(const std::string& tags); //!< Set the tags the Level is tagged with. 91 bool addTag(const std::string& tag, bool update = true); //!< Add a tag to the set of tags the Level is tagged with. 92 /** 93 @brief Get the lis of the tags the Level is tagged with. 94 @return Returns a comma-seperated string of all the tags the Level is tagged with. 95 */ 96 inline const std::string& getTags(void) const 97 { return this->tagsString_; } 98 /** 99 @brief Get whether the Level has a specific tag. 100 @param tag The tag for which is checked. 101 @return Returns true if the Level is tagged with the input tag. 102 */ 103 bool hasTag(const std::string& tag) const 104 { return this->tags_.find(tag) != this->tags_.end(); } 105 106 /** 107 @brief Get the XML-filename of the Level. 108 @return Returns the XML-filename (including *.oxw extension) of the Level. 109 */ 110 inline const std::string& getXMLFilename(void) 111 { return this->xmlfilename_; } 112 113 protected: 114 /** 115 @brief Set the XML-filename of the Level. 116 @param filename The XML-filename to be set. 117 */ 118 inline void setXMLFilename(const std::string& filename) 119 { this->xmlfilename_ = std::string(filename); } 120 121 std::string xmlfilename_; //!< The XML-filename of the Level. 122 123 private: 124 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 125 126 std::string name_; //!< The name of the Level. 127 std::string description_; //!< The description of the Level. 128 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 129 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 130 }; 131 132 /** 133 @brief 134 The LevelInfo class can be used to store information regarding a @ref orxonox::Level "Level" in its level file. 135 The following parameters can be specified: 136 - @b name The name of the level. 137 - @b description The description of the level. 138 - @b tags A comma-seperated string of tags. 139 140 An example would be: 141 @code 142 <LevelInfo 143 name = "Levelname" 144 description = "This is just some awesome level." 145 tags = "test, awesome" 146 /> 147 @endcode 148 The LevelInfo is best located at the top of the level file. 149 150 @author 151 Damian 'Mozork' Frick 152 */ 153 class _OrxonoxExport LevelInfo : public BaseObject, public LevelInfoItem 154 { 44 155 public: 45 156 LevelInfo(BaseObject* creator); 46 157 virtual ~LevelInfo(); 47 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);49 158 159 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML. 160 161 /** 162 @brief Set the description of the Level. 163 @param description The description to be set. 164 */ 50 165 inline void setDescription(const std::string& description) 51 { this->description_ = description; } 52 inline const std::string& getDescription() const // tolua_export 53 { return this->description_; } 54 55 void setTags(const std::string& tags); 56 inline bool addTag(const std::string& tag) 57 { bool success = this->tags_.insert(tag).second; if(success) this->tagsUpdated(); return success; } 166 { this->LevelInfoItem::setDescription(description); } 167 /** 168 @brief Get the description of the Level. 169 @return Returns the description of the Level. 170 */ 171 inline const std::string& getDescription() const 172 { return this->LevelInfoItem::getDescription(); } 173 174 /** 175 @brief Set the tags the Level is tagged with. 176 @param tags A comma-seperated string of all the tags to be set. 177 */ 178 inline void setTags(const std::string& tags) 179 { this->LevelInfoItem::setTags(tags); } 180 /** 181 @brief Get the lis of the tags the Level is tagged with. 182 @return Returns a comma-seperated string of all the tags the Level is tagged with. 183 */ 58 184 inline const std::string& getTags(void) const 59 { return this->tagsString_; } 60 bool hasTag(const std::string& tag) { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 61 62 private: 63 void tagsUpdated(void); 64 65 std::string description_; 66 std::set<std::string> tags_; 67 std::string tagsString_; 68 69 }; // tolua_export 70 } // tolua_export 185 { return this->LevelInfoItem::getTags(); } 71 186 72 #endif /* _Level_H__ */ 187 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 188 189 }; 190 } 191 192 #endif /* _LevelInfo_H__ */ -
code/branches/releasetodo/src/orxonox/LevelManager.cc
r7614 r7625 59 59 ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString()); 60 60 } 61 62 this->compileAvailableLevelList(); 61 63 } 62 64 … … 128 130 } 129 131 132 unsigned int LevelManager::getNumberOfLevels() 133 { 134 this->updateAvailableLevelList(); 135 136 COUT(0) << "Number of Levels: " << this->infos_.size() << std::endl; 137 138 return this->availableLevels_.size(); 139 } 140 130 141 const std::string& LevelManager::getAvailableLevelListItem(unsigned int index) const 131 142 { 132 if (index >= availableLevels_.size())143 if (index >= this->availableLevels_.size()) 133 144 return BLANKSTRING; 134 145 else 135 return availableLevels_[index]; 146 { 147 std::map<std::string, LevelInfoItem*>::const_iterator it = this->infos_.find(this->availableLevels_[index]); 148 assert(it->second); 149 return it->second->getName(); 150 } 136 151 } 137 152 138 153 void LevelManager::compileAvailableLevelList() 139 154 { 140 this->availableLevels_.clear();141 155 Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw"); 156 // Iterate over all *.oxw level files. 142 157 for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it) 143 158 { 159 //TODO: Replace with tag, 144 160 if (it->find("old/") != 0) 145 161 { 146 162 size_t pos = it->find(".oxw"); 147 COUT(0) << *it << std::endl; 163 164 bool infoExists = false; 165 // Load the LevelInfo object from the level file. 148 166 XMLFile file = XMLFile(*it); 149 167 ClassTreeMask mask = ClassTreeMask(); … … 151 169 mask.include(ClassIdentifier<LevelInfo>::getIdentifier()); 152 170 Loader::load(&file, mask); 153 171 for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item) 172 { 173 LevelInfoItem* info = item->copy(); 174 COUT(0) << "BUUUUUUUUUH: " << info->getName() << " | " << info->getXMLFilename() << " | " << it->substr(0, pos) << std::endl; 175 if(info->getXMLFilename() == *it) 176 { 177 this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos),info)); 178 infoExists = true; 179 } 180 } 181 Loader::unload(&file, mask); 182 if(!infoExists) 183 { 184 this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos), new LevelInfoItem(it->substr(0, pos), *it))); 185 } 186 154 187 this->availableLevels_.push_back(it->substr(0, pos)); 155 188 } 156 189 } 190 } 157 191 192 void LevelManager::updateAvailableLevelList(void) 193 { 194 //TODO: Implement some kind of update? 158 195 } 159 196 } -
code/branches/releasetodo/src/orxonox/LevelManager.h
r6746 r7625 34 34 #include <cassert> 35 35 #include <list> 36 #include <map> 36 37 #include <string> 37 38 … … 59 60 void setDefaultLevel(const std::string& levelName); //tolua_export 60 61 const std::string& getDefaultLevel() const; //tolua_export 61 void compileAvailableLevelList(); //tolua_export62 unsigned int getNumberOfLevels(void); //tolua_export 62 63 const std::string& getAvailableLevelListItem(unsigned int index) const; //tolua_export 63 64 … … 69 70 void activateNextLevel(); 70 71 72 void compileAvailableLevelList(void); 73 void updateAvailableLevelList(void); 74 71 75 std::list<Level*> levels_s; 72 76 std::vector<std::string> availableLevels_; 77 std::map<std::string, LevelInfoItem*> infos_; 73 78 74 79 // config values -
code/branches/releasetodo/src/orxonox/OrxonoxPrereqs.h
r7614 r7625 68 68 class Level; 69 69 class LevelInfo; 70 class LevelInfoItem; 70 71 class LevelManager; 71 72 class PawnManager;
Note: See TracChangeset
for help on using the changeset viewer.