Changeset 682 for code/branches/FICN/src/loader
- Timestamp:
- Dec 25, 2007, 10:37:29 PM (17 years ago)
- Location:
- code/branches/FICN/src/loader
- Files:
-
- 1 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/loader/LevelLoader.cc
r681 r682 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Nicolas Perrenoud <nicolape@ee.ethz.ch> 23 * Co-authors: 24 * ... 25 * 26 */ 27 28 // #include <string> 29 // #include <vector> 30 // #include <iostream> 31 #include <algorithm> 32 #include <iterator> 33 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Nicolas Perrenoud <nicolape@ee.ethz.ch> 23 * Co-authors: 24 * ... 25 * 26 */ 27 28 #include <OgreOverlay.h> 34 29 #include <OgreOverlayManager.h> 35 30 31 #include "orxonox/core/Error.h" 32 #include "orxonox/core/Debug.h" 33 #include "orxonox/core/CoreIncludes.h" 34 35 #include "audio/AudioManager.h" 36 #include "orxonox/objects/BaseObject.h" 37 #include "orxonox/Orxonox.h" 38 36 39 #include "LevelLoader.h" 37 // #include "tinyxml/tinyxml.h"38 #include "orxonox/core/CoreIncludes.h"39 #include "orxonox/core/Error.h"40 #include "orxonox/objects/BaseObject.h"41 #include "audio/AudioManager.h"42 #include "orxonox/Orxonox.h"43 44 using namespace std;45 40 46 41 namespace loader 47 42 { 48 43 49 LevelLoader::LevelLoader(string file, string path) 50 { 51 valid_ = false; 52 53 // Load XML level file 54 path.append("/"); 55 path.append(file); 56 57 // Open xml file 58 doc.LoadFile(path); 59 60 // Check if file was loaded 61 if (doc.LoadFile()) 44 LevelLoader::LevelLoader(std::string file, std::string path) 62 45 { 63 TiXmlHandle hDoc(&doc); 64 TiXmlHandle hRoot(0); 65 TiXmlElement* pElem; 66 67 // Check for root element 68 pElem = hDoc.FirstChildElement("orxonoxworld").Element(); 69 if (pElem) 46 valid_ = false; 47 48 // Load XML level file 49 path.append("/"); 50 path.append(file); 51 52 // Open xml file 53 doc_.LoadFile(path); 54 55 // Check if file was loaded 56 if (doc_.LoadFile()) 70 57 { 71 // Set root element72 hRoot = TiXmlHandle(pElem);73 rootElement = hRoot.Element();74 75 // Set level description76 pElem = h Root.FirstChild("description").Element();58 TiXmlHandle hDoc(&doc_); 59 TiXmlHandle hRoot(0); 60 TiXmlElement* pElem; 61 62 // Check for root element 63 pElem = hDoc.FirstChildElement("orxonoxworld").Element(); 77 64 if (pElem) 78 65 { 79 description_ = pElem->GetText(); 80 } 81 82 // Set level name 83 name_ = rootElement->Attribute("name"); 84 image_ = rootElement->Attribute("image"); 85 86 valid_ = true; 66 // Set root element 67 hRoot = TiXmlHandle(pElem); 68 rootElement_ = hRoot.Element(); 69 70 // Set level description 71 pElem = hRoot.FirstChild("description").Element(); 72 if (pElem) 73 { 74 description_ = pElem->GetText(); 75 } 76 77 // Set level name 78 name_ = rootElement_->Attribute("name"); 79 image_ = rootElement_->Attribute("image"); 80 81 valid_ = true; 82 } 83 else 84 { 85 orxonox::Error("Level file has no valid root node"); 86 } 87 87 } 88 88 else 89 89 { 90 orxonox::Error(" Level file has no valid root node");90 orxonox::Error("Could not load level file "); 91 91 } 92 92 } 93 else94 {95 orxonox::Error("Could not load level file ");96 }97 }98 93 99 94 void LevelLoader::loadLevel() … … 111 106 112 107 // Set loading screen 113 loadElem = rootElement ->FirstChildElement("loading");108 loadElem = rootElement_->FirstChildElement("loading"); 114 109 if (loadElem) 115 110 { … … 145 140 // Load audio 146 141 audio::AudioManager* auMan = orxonox::Orxonox::getSingleton()->getAudioManagerPointer(); 147 audioElem = rootElement ->FirstChildElement("audio");142 audioElem = rootElement_->FirstChildElement("audio"); 148 143 149 144 if (audioElem) … … 174 169 175 170 // Load world 176 worldElem = rootElement ->FirstChildElement("world");171 worldElem = rootElement_->FirstChildElement("world"); 177 172 if (worldElem) 178 173 { … … 192 187 else 193 188 { 194 189 COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname." << std::endl; 195 190 } 196 191 } … … 201 196 { 202 197 // FIXME: check for potential initialisation of mLoadOverlay 203 198 mLoadOverlay->hide(); 204 199 } 205 200 … … 214 209 } 215 210 216 217 218 211 } 219 -
code/branches/FICN/src/loader/LevelLoader.h
r678 r682 10 10 11 11 #include <string> 12 #include <vector>13 #include <iostream>14 12 15 #include "LoaderP latform.h"13 #include "LoaderPrereqs.h" 16 14 #include "tinyxml/tinyxml.h" 17 15 18 //#include "xml/xmlParser.h" 19 16 class TiXmlDocument; // Forward declaration 17 class TiXmlElement; // Forward declaration 20 18 21 19 namespace loader … … 25 23 public: 26 24 // Constructors, loads the level file and some information data 27 LevelLoader(std::string file, std::string dir ="levels");25 LevelLoader(std::string file, std::string dir = "levels"); 28 26 // Destructor 29 ~LevelLoader();27 virtual ~LevelLoader(); 30 28 // Loads all level data 31 29 void loadLevel(); … … 52 50 53 51 // Xml-Stuff 54 TiXmlDocument doc; 55 TiXmlElement* rootElement; 56 52 TiXmlDocument doc_; 53 TiXmlElement *rootElement_; 57 54 }; 58 55 }
Note: See TracChangeset
for help on using the changeset viewer.