Changeset 480
- Timestamp:
- Dec 12, 2007, 7:54:44 PM (17 years ago)
- Location:
- code/branches/FICN
- Files:
-
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/bin/levels/sample.oxw
r470 r480 15 15 16 16 <world> 17 18 17 <Test1> 18 sdafa sdfj askjfdskdalfj 19 </Test1> 19 20 </world> 20 21 -
code/branches/FICN/src/CMakeLists.txt
r396 r480 7 7 ADD_SUBDIRECTORY(orxonox) 8 8 ADD_SUBDIRECTORY(audio) 9 ADD_SUBDIRECTORY(tinyxml) 9 10 10 11 # xml gets handled by loader -
code/branches/FICN/src/loader/CMakeLists.txt
r471 r480 4 4 SET( LOADER_SRC_FILES 5 5 LevelLoader.cc 6 #../xml/xmlParser.cc7 ../tinyxml/tinystr.cc8 ../tinyxml/tinyxml.cc9 ../tinyxml/tinyxmlerror.cc10 ../tinyxml/tinyxmlparser.cc11 6 ) 12 7 13 8 ADD_LIBRARY(loader SHARED ${LOADER_SRC_FILES}) 9 10 TARGET_LINK_LIBRARIES( loader 11 xml 12 ) -
code/branches/FICN/src/loader/LevelLoader.cc
r474 r480 5 5 #include "tinyxml/tinyxml.h" 6 6 #include "orxonox/core/IdentifierIncludes.h" 7 #include "orxonox/core/Error.h" 8 #include "orxonox/objects/BaseObject.h" 7 9 8 10 using namespace std; … … 11 13 { 12 14 13 LevelLoader::LevelLoader(string file, string dir) 14 { 15 LevelLoader::LevelLoader(string file, string path) 16 { 17 valid_ = false; 18 15 19 // Load XML level file 16 dir.append("/");17 dir.append(file);20 path.append("/"); 21 path.append(file); 18 22 19 23 // Open xml file 20 TiXmlDocument doc(file);24 doc.LoadFile(path); 21 25 22 26 // Check if file was loaded … … 24 28 { 25 29 TiXmlHandle hDoc(&doc); 26 TiXmlHandle hRoot(0); 27 30 TiXmlHandle hRoot(0); 28 31 TiXmlElement* pElem; 29 30 32 31 33 // Check for root element … … 35 37 // Set root element 36 38 hRoot = TiXmlHandle(pElem); 39 rootElement = hRoot.Element(); 37 40 38 41 // Set level description … … 44 47 45 48 // Set level name 46 pElem = hRoot.Element(); 47 name_ = pElem->Attribute("name"); 48 image_ = pElem->Attribute("image"); 49 name_ = rootElement->Attribute("name"); 50 image_ = rootElement->Attribute("image"); 51 52 valid_ = true; 53 } 54 else 55 { 56 orxonox::Error("Level file has no valid root node"); 57 } 58 } 59 else 60 { 61 orxonox::Error("Could not load level file "); 62 } 63 } 64 65 void LevelLoader::loadLevel() 66 { 67 if (valid_) 68 { 69 TiXmlElement* loadElem; 70 TiXmlElement* worldElem; 71 TiXmlElement* tElem; 72 TiXmlNode* tNode; 73 49 74 50 75 // Set loading screen 51 pElem = hRoot.FirstChild("loading").Element();52 if ( pElem)76 loadElem = rootElement->FirstChildElement("loading"); 77 if (loadElem) 53 78 { 54 79 // Set background 55 pElem = hRoot.FirstChild("loading").FirstChild("background").Element();56 if ( pElem)80 tElem = loadElem->FirstChildElement("background"); 81 if (tElem) 57 82 { 58 loadingBackgroundColor_ = pElem->Attribute("color");59 loadingBackgroundImage_ = pElem->Attribute("image");83 loadingBackgroundColor_ = tElem->Attribute("color"); 84 loadingBackgroundImage_ = tElem->Attribute("image"); 60 85 } 61 86 // Set bar 62 pElem = hRoot.FirstChild("loading").FirstChild("bar").Element();63 if ( pElem)87 tElem = loadElem->FirstChildElement("bar"); 88 if (tElem) 64 89 { 65 loadingBarImage_ = pElem->Attribute("image");;66 loadingBarTop_ = pElem->Attribute("top");67 loadingBarLeft_ = pElem->Attribute("left");68 loadingBarWidth_ = pElem->Attribute("width");69 loadingBarHeight_ = pElem->Attribute("height");90 loadingBarImage_ = tElem->Attribute("image");; 91 loadingBarTop_ = tElem->Attribute("top"); 92 loadingBarLeft_ = tElem->Attribute("left"); 93 loadingBarWidth_ = tElem->Attribute("width"); 94 loadingBarHeight_ = tElem->Attribute("height"); 70 95 } 96 showLoadingScreen(); 71 97 } 72 73 74 } 75 else 76 { 77 std::string err = "Level file has no valid root node"; 78 std::cout << err << std::endl; 79 } 80 } 81 else 82 { 83 std::string err = "Could not load level file "; 84 err.append(file); 85 std::cout << err << std::endl; 86 } 98 99 // Load audio 100 // TODO 101 102 // Load scripts 103 // TODO 104 105 // Load world 106 worldElem = rootElement->FirstChildElement("world"); 107 if (worldElem) 108 { 109 tNode = 0; 110 while( tNode = worldElem->IterateChildren( tNode ) ) 111 { 112 tElem = tNode->ToElement(); 113 orxonox::BaseObject* obj = orxonox::ID(tElem->Value())->fabricate(); 114 obj->loadParams(tElem); 115 } 116 } 117 118 std::cout << "Loading finished!\n\n\n\n\n"; 119 } 120 } 121 122 void LevelLoader::showLoadingScreen() 123 { 124 std::cout << "\n\n\nThis is Orxonox\nthe hottest 3D action shooter ever to exist\n\n\n"; 125 std::cout << "Level: " << name() << "\nDescription:" << description() << "\nImage:"<<image()<<"\n\n\n"; 126 std::cout << "Backgroundcolor: " << loadingBackgroundColor_ << "\nBackgroundimage:" << loadingBackgroundImage_ << "\n\n\n"; 127 } 87 128 88 129 … … 130 171 */ 131 172 132 } 173 133 174 134 175 LevelLoader::~LevelLoader() … … 154 195 } 155 196 156 void LevelLoader::showLoadingScreen()157 {158 cout << "\n\n\nThis is Orxonox\nthe hottest 3D action shooter ever to exist\n\n\n";159 cout << "Level: " << name() << "\nDescription:" << description() << "\nImage:"<<image()<<"\n\n\n";160 }161 197 162 198 /* -
code/branches/FICN/src/loader/LevelLoader.h
r474 r480 24 24 { 25 25 private: 26 /*27 // XML Nodes28 XMLNode rootNode;29 XMLNode loadingScreenNode;30 XMLNode worldNode;31 XMLNode audioNode;32 XMLNode scriptsNode;33 */34 26 // Level information 35 27 std::string name_; 36 28 std::string description_; 37 29 std::string image_; 38 39 30 std::string loadingBackgroundColor_; 40 31 std::string loadingBackgroundImage_; … … 44 35 std::string loadingBarWidth_; 45 36 std::string loadingBarHeight_; 37 38 bool valid_; 46 39 40 TiXmlDocument doc; 41 TiXmlElement* rootElement; 47 42 public: 48 43 … … 52 47 53 48 void showLoadingScreen(); 49 void loadLevel(); 54 50 55 51 // Getters -
code/branches/FICN/src/orxonox/CMakeLists.txt
r462 r480 32 32 objects 33 33 weapon 34 xml 34 35 ) 35 36 -
code/branches/FICN/src/orxonox/core/OrxonoxClass.h
r474 r480 92 92 inline const bool isVisible() const { return this->bVisible_; } 93 93 94 //virtual void loadParams(TIXMLNode n);95 94 96 95 private: -
code/branches/FICN/src/orxonox/objects/BaseObject.cc
r258 r480 13 13 { 14 14 } 15 15 16 } -
code/branches/FICN/src/orxonox/objects/BaseObject.h
r384 r480 11 11 BaseObject(); 12 12 virtual ~BaseObject(); 13 virtual void loadParams(TiXmlElement* xmlElem) {} 14 13 15 }; 14 16 } -
code/branches/FICN/src/orxonox/objects/CMakeLists.txt
r376 r480 9 9 10 10 ADD_LIBRARY(objects SHARED ${OBJECTS_SRC_FILES}) 11 12 TARGET_LINK_LIBRARIES( objects 13 xml 14 ) -
code/branches/FICN/src/orxonox/objects/test1.cc
r384 r480 2 2 #include "test2.h" 3 3 #include "test3.h" 4 #include "../../tinyxml/tinyxml.h" 4 5 5 6 namespace orxonox … … 66 67 this->usefullClass3_ = identifier; 67 68 } 69 70 void Test1::loadParams(TiXmlElement* xmlElem) 71 { 72 std::cout<< xmlElem->GetText()<<std::endl; 73 } 68 74 } -
code/branches/FICN/src/orxonox/objects/test1.h
r384 r480 5 5 #include "Tickable.h" 6 6 #include "test3.h" 7 #include "../../tinyxml/tinyxml.h" 7 8 8 9 namespace orxonox … … 22 23 void setUsefullClass2(Identifier* identifier); 23 24 void setUsefullClassOfTypeTest3(Identifier* identifier); 25 26 void loadParams(TiXmlElement* xmlElem); 24 27 25 28 private: -
code/branches/FICN/src/orxonox/orxonox.cc
r473 r480 218 218 { 219 219 //TODO: start modules 220 ogre_->startRender(); 221 auMan_ = new audio::AudioManager(); 222 // load this file from config 223 string levelFile = "sample.oxw"; 224 //loader_ = new loader::LevelLoader(levelFile); 220 225 221 //TODO: run engine 226 222 } … … 339 335 void Orxonox::createScene(void) 340 336 { 337 // Init audio 341 338 auMan_ = new audio::AudioManager(); 342 339 340 // load this file from config 341 loader_ = new loader::LevelLoader("sample.oxw"); 342 loader_->loadLevel(); 343 344 /* 343 345 auMan_->ambientAdd("a1"); 344 346 auMan_->ambientAdd("a2"); … … 346 348 //auMan->ambientAdd("ambient1"); 347 349 auMan_->ambientStart(); 348 349 string levelFile = "sp_level_moonstation.oxw"; 350 // loader::LevelLoader* loader = new loader::LevelLoader(levelFile); 350 */ 351 351 } 352 352
Note: See TracChangeset
for help on using the changeset viewer.