Changeset 4597 in orxonox.OLD for orxonox/trunk/src/util/loading/game_loader.cc
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/game_loader.cc
r4511 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 39 39 \brief simple constructor 40 40 */ 41 GameLoader::GameLoader () 42 { 41 GameLoader::GameLoader () 42 { 43 this->setClassID(CL_GAME_LOADER, "GameLoader"); 44 this->setName("GameLoader"); 43 45 first = NULL; 44 46 } … … 110 112 switch(campaignID) 111 113 { 112 /* 113 114 115 116 114 /* 115 Debug Level 0: Debug level used to test the base frame work. 116 As you can see, all storyentity data is allocated before game 117 start. the storyentity will load themselfs shortly before start 118 through the StoryEntity::init() funtion. 117 119 */ 118 120 case DEBUG_CAMPAIGN_0: 119 121 { 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 122 Campaign* debugCampaign = new Campaign(); 123 124 World* world0 = new World(DEBUG_WORLD_0); 125 world0->setNextStoryID(WORLD_ID_1); 126 debugCampaign->addEntity(world0, WORLD_ID_0); 127 128 World* world1 = new World(DEBUG_WORLD_1); 129 world1->setNextStoryID(WORLD_ID_2); 130 debugCampaign->addEntity(world1, WORLD_ID_1); 131 132 World* world2 = new World(DEBUG_WORLD_2); 133 world2->setNextStoryID(WORLD_ID_GAMEEND); 134 debugCampaign->addEntity(world2, WORLD_ID_2); 135 136 this->currentCampaign = debugCampaign; 137 break; 136 138 } 137 139 } … … 139 141 140 142 141 /** 143 /** 142 144 \brief starts the current entity 143 \returns error code if this action has caused a error 145 \returns error code if this action has caused a error 144 146 */ 145 147 ErrorMessage GameLoader::start() … … 150 152 151 153 152 /** 154 /** 153 155 \brief stops the current entity 154 156 \returns error code if this action has caused a error … … 168 170 169 171 170 /** 172 /** 171 173 \brief pause the current entity 172 174 \returns error code if this action has caused a error … … 182 184 183 185 184 /** 186 /** 185 187 \brief resumes a pause 186 188 \returns error code if this action has caused a error … … 218 220 can load everything it needs into memory then. 219 221 */ 220 222 221 223 if( fileName == NULL) 222 224 { … … 224 226 return NULL; 225 227 } 226 228 227 229 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName); 228 230 // load the campaign document … … 234 236 return NULL; 235 237 } 236 238 237 239 // check basic validity 238 240 TiXmlElement* root = XMLDoc->RootElement(); 239 241 assert( root != NULL); 240 242 241 243 if( strcmp( root->Value(), "Campaign")) 242 244 { … … 246 248 return NULL; 247 249 } 248 250 249 251 // construct campaign 250 252 Campaign* c = new Campaign( root); 251 253 252 254 // free the XML data 253 255 delete XMLDoc; … … 258 260 259 261 /** 260 \brief handle keyboard commands 262 \brief handle keyboard commands 261 263 \param event the event to handle 262 264 */ … … 265 267 if( event.type == KeyMapper::PEV_NEXT_WORLD) 266 268 { 267 if( likely(event.bPressed)) 268 269 270 269 if( likely(event.bPressed)) 270 { 271 this->nextLevel(); 272 } 271 273 } 272 274 else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD) 273 275 { 274 276 if( likely(event.bPressed)) 275 276 277 277 { 278 this->previousLevel(); 279 } 278 280 } 279 281 else if( event.type == KeyMapper::PEV_PAUSE) 280 282 { 281 283 if( likely(event.bPressed)) 282 283 284 285 286 287 284 { 285 if(this->isPaused) 286 this->resume(); 287 else 288 this->pause(); 289 } 288 290 } 289 291 else if( event.type == KeyMapper::PEV_QUIT) … … 322 324 void GameLoader::registerFactory( Factory* factory) 323 325 { 324 325 326 327 328 329 326 assert( factory != NULL); 327 328 PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName()); 329 330 if( first == NULL) first = factory; 331 else first->registerFactory( factory); 330 332 } 331 333 … … 338 340 { 339 341 assert( element != NULL); 340 342 341 343 if( first == NULL) 342 344 { … … 344 346 return NULL; 345 347 } 346 348 347 349 if( element->Value() != NULL) 348 350 { 349 351 PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value()); 350 352 BaseObject* b = first->fabricate( element); 351 if( b == NULL) 352 353 else 354 353 if( b == NULL) 354 PRINTF(2)("Failed to fabricate a '%s'\n", element->Value()); 355 else 356 PRINTF(4)("Successfully fabricated a '%s'\n", element->Value()); 355 357 return b; 356 358 } 357 359 358 360 PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n"); 359 361 360 362 return NULL; 361 363 }
Note: See TracChangeset
for help on using the changeset viewer.