Changeset 4598 in orxonox.OLD for orxonox/trunk/src/story_entities
- Timestamp:
- Jun 11, 2005, 3:08:36 AM (20 years ago)
- Location:
- orxonox/trunk/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/story_entities/campaign.cc
r4597 r4598 41 41 Campaign::Campaign ( TiXmlElement* root) 42 42 { 43 //! \todo loading with load_param....44 43 this->setClassID(CL_CAMPAIGN, "Campaign"); 44 45 PRINTF(3)("Loading Campaign...\n"); 46 47 assert( root != NULL); 48 49 this->entities = new tList<StoryEntity>(); 50 this->isInit = false; 51 52 this->loadParams(root); 53 54 55 //if( lastCreated != NULL) 56 //lastCreated->setStoryID( WORLD_ID_GAMEEND); 57 } 58 59 Campaign::~Campaign () {} 60 61 62 ErrorMessage Campaign::init() 63 { 64 this->isInit = true; 65 } 66 67 /** 68 \brief loads the Parameters of a Campaign 69 \param root: The XML-element to load from 70 */ 71 void Campaign::loadParams(const TiXmlElement* root) 72 { 45 73 TiXmlElement* element; 46 74 const char* string; 47 int id; 48 49 PRINTF(3)("Loading Campaign...\n"); 50 51 assert( root != NULL); 52 GameLoader* loader = GameLoader::getInstance(); 53 54 this->entities = new tList<StoryEntity>(); 55 this->isInit = false; 56 57 // grab all the necessary parameters 58 string = grabParameter( root, "identifier"); 59 if( string == NULL || sscanf(string, "%d", &id) != 1) 60 { 61 PRINTF(2)("Campaign is missing a proper 'identifier'\n"); 62 this->setStoryID( -1); 63 } 64 else this->setStoryID( id); 65 66 // find WorldList 67 element = root->FirstChildElement( "WorldList"); 68 if( element == NULL) 69 { 70 PRINTF(2)("Campaign is missing a proper 'WorldList'\n"); 71 } 72 else 73 element = element->FirstChildElement(); 74 75 76 LoadParam<Campaign>(root, "identifier", this, &Campaign::setStoryID); 77 78 LoadParam<Campaign>(root, "WorldList", this, &Campaign::loadWorldListParams, root->FirstChildElement("WorldList")); 79 } 80 81 /** 82 \brief loads a WorldList 83 \param root: the XML-element to load from 84 */ 85 void Campaign::loadWorldListParams(const TiXmlElement* root) 86 { 87 const TiXmlElement* element = root->FirstChildElement(); 75 88 // load Worlds/Subcampaigns/Whatever 76 89 StoryEntity* lastCreated = NULL; 77 90 while( element != NULL) 78 79 80 StoryEntity* created = (StoryEntity*) loader->fabricate(element);91 { 92 printf("Campaign: Constructor: adding a world\n"); 93 StoryEntity* created = (StoryEntity*) GameLoader::getInstance()->fabricate(element); 81 94 /* 82 83 84 85 95 if( lastCreated != NULL) 96 created->setNextStoryID( lastCreated->getStoryID()); 97 else 98 created->setNextStoryID( WORLD_ID_GAMEEND); 86 99 */ 87 if( created != NULL) 88 { 89 this->addEntity( created); 90 lastCreated = created; 91 } 92 element = element->NextSiblingElement(); 93 } 94 //if( lastCreated != NULL) 95 //lastCreated->setStoryID( WORLD_ID_GAMEEND); 96 } 97 98 Campaign::~Campaign () {} 99 100 101 ErrorMessage Campaign::init() 102 { 103 this->isInit = true; 104 } 105 100 if( created != NULL) 101 { 102 this->addEntity( created); 103 lastCreated = created; 104 } 105 element = element->NextSiblingElement(); 106 } 107 } 106 108 107 109 ErrorMessage Campaign::start() -
orxonox/trunk/src/story_entities/campaign.h
r4597 r4598 17 17 Campaign ( TiXmlElement* root); 18 18 virtual ~Campaign (); 19 20 void loadParams(const TiXmlElement* root); 21 void loadWorldListParams(const TiXmlElement* root); 19 22 20 23 StoryEntity* currentEntity;
Note: See TracChangeset
for help on using the changeset viewer.