Changeset 6424 in orxonox.OLD for trunk/src/util/loading/game_loader.cc
- Timestamp:
- Jan 7, 2006, 11:07:22 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/game_loader.cc
r6152 r6424 61 61 } 62 62 63 64 /**65 * this class is a singleton class66 * @returns an instance of itself67 *68 * if you are unsure about singleton classes, check the theory out on the internet :)69 */70 GameLoader* GameLoader::getInstance()71 {72 if(singletonRef == NULL)73 singletonRef = new GameLoader();74 return singletonRef;75 }76 63 77 64 /** … … 124 111 if (campaignName) 125 112 { 126 this->currentCampaign = this->fileTo NetworkCampaign(campaignName);113 this->currentCampaign = this->fileToCampaign(campaignName); 127 114 delete[] campaignName; 128 115 } … … 225 212 226 213 /** 227 * release the mem ATTENTION: not implemented228 */229 ErrorMessage GameLoader::destroy()230 {231 232 }233 234 235 /**236 214 * reads a campaign definition file into a campaign class 237 215 * @param fileName to be loaded … … 285 263 286 264 287 /**288 * reads a campaign definition file into a campaign class289 * @param fileName to be loaded290 * @returns the loaded campaign291 *292 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns293 */294 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName)295 {296 /* do not entirely load the campaign. just the current world297 before start of each world, it has to be initialized so it298 can load everything it needs into memory then.299 */300 301 if( fileName == NULL)302 {303 PRINTF(2)("No filename specified for loading");304 return NULL;305 }306 307 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);308 // load the campaign document309 if( !XMLDoc->LoadFile())310 {311 // report an error312 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());313 delete XMLDoc;314 return NULL;315 }316 317 // check basic validity318 TiXmlElement* root = XMLDoc->RootElement();319 assert( root != NULL);320 321 if( strcmp( root->Value(), "Campaign"))322 {323 // report an error324 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");325 delete XMLDoc;326 return NULL;327 }328 329 // construct campaign330 Campaign* c = new Campaign( root);331 332 // free the XML data333 delete XMLDoc;334 335 return c;336 }337 338 265 339 266 /** … … 347 274 if( likely(event.bPressed)) 348 275 { 349 this->nextLevel(); 350 } 351 } 352 else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD) 353 { 354 if( likely(event.bPressed)) 355 { 356 this->previousLevel(); 276 this->switchToNextLevel(); 357 277 } 358 278 } … … 377 297 378 298 /** 379 * \brief this changes to the next level 380 */ 381 void GameLoader::nextLevel() 382 { 383 if(this->currentCampaign != NULL) 384 this->currentCampaign->nextLevel(); 385 } 386 387 388 /** 389 * change to the previous level - not implemented 390 * 391 * this propably useless 392 */ 393 void GameLoader::previousLevel() 394 { 395 if(this->currentCampaign != NULL) 396 this->currentCampaign->previousLevel(); 397 } 299 * this changes to the next level 300 */ 301 void GameLoader::switchToNextLevel() 302 { 303 if(this->currentCampaign != NULL) 304 this->currentCampaign->switchToNextLevel(); 305 } 306 307
Note: See TracChangeset
for help on using the changeset viewer.