Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6992 in orxonox.OLD for trunk


Ignore:
Timestamp:
Feb 2, 2006, 10:55:43 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now the StoryEntity stores the path it was loaded with, not the GameWorld

Location:
trunk/src/story_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/game_world.cc

    r6989 r6992  
    8888
    8989  this->dataXML = NULL;
    90   this->path = NULL;
    9190}
    9291
     
    111110{
    112111  StoryEntity::loadParams(root);
    113 
    114   LoadParam(root, "path", this, GameWorld, setPath)
    115       .describe("The Filename of this GameWorld (relative from the data-dir)");
    116112
    117113  PRINTF(4)("Loaded GameWorld specific stuff\n");
     
    145141  PRINTF(0)("Loading the GameWorld\n");
    146142
    147   PRINTF(3)("> Loading world: '%s'\n", getPath());
     143  PRINTF(3)("> Loading world: '%s'\n", getLoadFile());
    148144  TiXmlElement* element;
    149145  GameLoader* loader = GameLoader::getInstance();
    150146
    151   if( getPath() == NULL)
     147  if( getLoadFile() == NULL)
    152148  {
    153149    PRINTF(1)("GameWorld has no path specified for loading\n");
     
    155151  }
    156152
    157   TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
     153  TiXmlDocument* XMLDoc = new TiXmlDocument( getLoadFile());
    158154  // load the xml world file for further loading
    159155  if( !XMLDoc->LoadFile())
    160156  {
    161     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     157    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    162158    delete XMLDoc;
    163159    return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
     
    444440}
    445441
    446 
    447 /**
    448  *  sets the track path of this world
    449  * @param name the name of the path
    450  */
    451 void GameWorld::setPath( const char* name)
    452 {
    453   if (this->path)
    454     delete this->path;
    455   if (ResourceManager::isFile(name))
    456   {
    457     this->path = new char[strlen(name)+1];
    458     strcpy(this->path, name);
    459   }
    460   else
    461   {
    462     this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
    463     sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
    464   }
    465 }
    466 
    467 
    468442/**
    469443 *  shows the loading screen
  • trunk/src/story_entities/game_world.h

    r6989 r6992  
    4747    inline void setSpeed(float speed) { this->speed = speed; };
    4848    /**  returns the track path of this world @returns the track path */
    49     const char* getPath() { return this->path; }
    50     void setPath( const char* name);
    5149
    5250    /** toggles the PNode visibility in the world (drawn as boxes) */
     
    8179    GameWorldData*      dataTank;                     //!< reference to the GameWorld Data Tank
    8280    TiXmlElement*       dataXML;                      //!< The XML-Element this World has been loaded with.
    83     char*               path;                         //!< The file from which this world is loaded
    8481
    8582    bool                showPNodes;                   //!< if the PNodes should be visible.
  • trunk/src/story_entities/simple_game_menu.cc

    r6991 r6992  
    243243  EventHandler::getInstance()->unsubscribe(this, ES_MENU);
    244244
    245   std::vector<ImageEntity*>::iterator it;
    246245  std::vector<MenuLayer>::iterator mit;
    247246  for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++)
  • trunk/src/story_entities/story_entity.cc

    r6878 r6992  
    2222#include "story_entity.h"
    2323
     24#include "resource_manager.h"
    2425#include "load_param.h"
    2526
     
    3940  this->isRunning = false;
    4041
     42  this->loadFile = NULL;
    4143  this->storyID = -1;
    4244  this->description = NULL;
     
    6668      .describe("A Unique Identifier for this StoryEntity");
    6769
     70  LoadParam(root, "path", this, StoryEntity, setLoadFile)
     71      .describe("DEPRICATED FORM OF file. The Filename of this StoryEntity (relative from the data-dir)");
     72
     73  LoadParam(root, "file", this, StoryEntity, setLoadFile)
     74      .describe("The Filename of this StoryEntity (relative from the data-dir)");
     75
    6876  LoadParam(root, "nextid", this, StoryEntity, setNextStoryID)
    6977      .describe("Sets the ID of the next StoryEntity");
     
    8694
    8795/**
     96 *  sets the track path of this world
     97 * @param name the name of the path
     98 */
     99void StoryEntity::setLoadFile(const char* fileName)
     100{
     101  if (this->loadFile)
     102    delete this->loadFile;
     103  if (ResourceManager::isFile(fileName))
     104  {
     105    this->loadFile = new char[strlen(fileName)+1];
     106    strcpy(this->loadFile, fileName);
     107  }
     108  else
     109    this->loadFile = ResourceManager::getFullName(fileName);
     110}
     111
     112
     113/**
    88114 * sets the descroption of this StoryEntity
    89115 * @param name name
     
    101127}
    102128
     129/**
     130 * sets the id of the next story entity: StoryEntities can choose their following entity themselfs.
     131 * the entity id defined here  will be startet after this entity ends. this can be convenient if you
     132 * want to have a non linear story with switches.
     133 * @param nextStoryID the story id of the next StoryEntity
     134 */
     135void StoryEntity::setNextStoryID(int nextStoryID)
     136{
     137   this->nextStoryID = nextStoryID;
     138}
    103139
    104140/**
  • trunk/src/story_entities/story_entity.h

    r6853 r6992  
    6060  /** sets the story id of the current entity, this enables it to be identified in a  global context. @returns  the story id  */
    6161  inline int getStoryID() { return this->storyID; }
    62   /**  sets the id of the next story entity: StoryEntities can choose their following entity themselfs.
    63    * the entity id defined here  will be startet after this entity ends. this can be convenient if you
    64    * want to have a non linear story with switches.
    65    * @param nextStoryID the story id of the next StoryEntity   */
    66   inline void setNextStoryID(int nextStoryID) { this->nextStoryID = nextStoryID; }
     62
     63  void setLoadFile( const char* fileName);
     64  /** @returns the Filename this StoryEntity was loaded with */
     65  const char* getLoadFile() const { return this->loadFile; }
     66
     67  void setNextStoryID(int nextStoryID);
    6768  /**  gets the story id of the current entity @returns story id */
    68   inline int getNextStoryID() { return this->nextStoryID; }
     69  inline int getNextStoryID() const { return this->nextStoryID; }
    6970  inline void setDescription(const char* description);
    7071  /** @returns the description of this StoryEntity */
    7172  inline const char* getDescription() { return this->description; }
     73
     74
     75
    7276  /** toggle the menu visibility: SimpleMenu specific */
    7377  inline void addToGameMenu(int toggle) { this->bMenuEntry = (bool)toggle; }
     
    9094
    9195 private:
    92     int storyID;            //!< this is the number of this entity, identifying it in a list/tree...
    93     int nextStoryID;        //!< if this entity has finished, this entity shall be called
    94     char* description;      //!< the description of the StoryEntity
    95     char* menuItemImage;    //!< the item image of the StoryEntity
    96     char* menuScreenshoot;  //!< the screenshoot of the StoryEntity
    97     bool        bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
     96    int     storyID;          //!< this is the number of this entity, identifying it in a list/tree...
     97    int     nextStoryID;      //!< if this entity has finished, this entity shall be called
     98    char*   loadFile;         //!< The file from which this world is loaded
     99
     100    char*   description;      //!< the description of the StoryEntity
     101    char*   menuItemImage;    //!< the item image of the StoryEntity
     102    char*   menuScreenshoot;  //!< the screenshoot of the StoryEntity
     103    bool    bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    98104};
    99105
Note: See TracChangeset for help on using the changeset viewer.