Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4598 in orxonox.OLD for orxonox/trunk/src/story_entities


Ignore:
Timestamp:
Jun 11, 2005, 3:08:36 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: campaign now gets loaded via LoadParam

Location:
orxonox/trunk/src/story_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/campaign.cc

    r4597 r4598  
    4141Campaign::Campaign ( TiXmlElement* root)
    4242{
    43   //! \todo loading with load_param....
    4443  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
     59Campaign::~Campaign () {}
     60
     61
     62ErrorMessage 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 */
     71void Campaign::loadParams(const TiXmlElement* root)
     72{
    4573  TiXmlElement* element;
    4674  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 */
     85void Campaign::loadWorldListParams(const TiXmlElement* root)
     86{
     87  const TiXmlElement* element = root->FirstChildElement();
    7588  // load Worlds/Subcampaigns/Whatever
    7689  StoryEntity* lastCreated = NULL;
    7790  while( element != NULL)
    78     {
    79       printf("Campaign: Constructor: adding a world\n");
    80       StoryEntity* created = (StoryEntity*) loader->fabricate( element);
     91  {
     92    printf("Campaign: Constructor: adding a world\n");
     93    StoryEntity* created = (StoryEntity*) GameLoader::getInstance()->fabricate(element);
    8194      /*
    82       if( lastCreated != NULL)
    83         created->setNextStoryID( lastCreated->getStoryID());
    84       else
    85         created->setNextStoryID( WORLD_ID_GAMEEND);
     95    if( lastCreated != NULL)
     96    created->setNextStoryID( lastCreated->getStoryID());
     97    else
     98    created->setNextStoryID( WORLD_ID_GAMEEND);
    8699      */
    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}
    106108
    107109ErrorMessage Campaign::start()
  • orxonox/trunk/src/story_entities/campaign.h

    r4597 r4598  
    1717  Campaign ( TiXmlElement* root);
    1818  virtual ~Campaign ();
     19
     20  void loadParams(const TiXmlElement* root);
     21  void loadWorldListParams(const TiXmlElement* root);
    1922
    2023  StoryEntity* currentEntity;
Note: See TracChangeset for help on using the changeset viewer.