Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6853 in orxonox.OLD


Ignore:
Timestamp:
Jan 30, 2006, 3:40:05 AM (18 years ago)
Author:
patrick
Message:

trunk: safe load param reading, menu better

Location:
trunk/src/story_entities
Files:
3 edited

Legend:

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

    r6852 r6853  
    194194      PRINTF(0)("Got a new menu entry |%s|\n", se->getName());
    195195      ImageEntity* ie = new ImageEntity();
     196      PRINTF(0)("setting texture to: |%s|\n", se->getMenuItemImage());
    196197      ie->setTexture(se->getMenuItemImage());
    197198      ie->setRelCoor(0.0f,- (this->menuLayer[1]->menuList.size() * 10.0f), 0.0f);
     
    288289
    289290        this->switchMenuLayer(this->layerIndex, 1);
    290 
    291       }
    292     }
    293     else if( event.type == SDLK_DOWN && event.bPressed == true)
    294     {
    295 //     ImageEntity*
    296       if(this->menuSelectedIndex < (this->menuLayer[this->layerIndex]->menuList.size() - 1))
    297       {
    298         this->menuSelected = this->menuLayer[this->layerIndex]->menuList[++this->menuSelectedIndex];
    299         this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
    300       }
    301     }
    302     else if( event.type == SDLK_UP && event.bPressed == true)
    303     {
    304       if(this->menuSelectedIndex > 0)
    305       {
    306         this->menuSelected = this->menuLayer[this->layerIndex]->menuList[--this->menuSelectedIndex];
    307         this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
    308291      }
    309292    }
     
    315298      this->setNextStoryID( this->menuLayer[1]->storyList[this->menuSelectedIndex]->getStoryID());
    316299      this->stop();
     300    }
     301  }
     302
     303
     304
     305  // The menu selction cursor
     306  if( event.type == SDLK_DOWN && event.bPressed == true)
     307  {
     308    if(this->menuSelectedIndex < (this->menuLayer[this->layerIndex]->menuList.size() - 1))
     309    {
     310      this->menuSelected = this->menuLayer[this->layerIndex]->menuList[++this->menuSelectedIndex];
     311      this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     312    }
     313  }
     314  else if( event.type == SDLK_UP && event.bPressed == true)
     315  {
     316    if(this->menuSelectedIndex > 0)
     317    {
     318      this->menuSelected = this->menuLayer[this->layerIndex]->menuList[--this->menuSelectedIndex];
     319      this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
    317320    }
    318321  }
  • trunk/src/story_entities/story_entity.cc

    r6848 r6853  
    4141  this->storyID = -1;
    4242  this->description = NULL;
    43   this->menuItemImage = "pictures/menu/DefaultMenuItem.png";
     43  this->menuItemImage = NULL;
    4444  this->nextStoryID = WORLD_ID_GAMEEND;
    4545  this->bMenuEntry = false;
     
    8282  PRINTF(4)("Loaded StoryEntity specific stuff\n");
    8383}
     84
     85
     86/**
     87 * sets the descroption of this StoryEntity
     88 * @param name name
     89 */
     90void StoryEntity::setDescription(const char* description)
     91{
     92  if (this->description)
     93    delete[] this->description;
     94  if (description!= NULL)
     95  {
     96    this->description= new char[strlen(description)+1];
     97    strcpy(this->description, description);
     98  }
     99  else this->description= NULL;
     100}
     101
     102
     103/**
     104 * sets the menu item image of this StoryEntity
     105 * @param name name
     106 */
     107void StoryEntity::setMenuItemImage(const char* image)
     108{
     109  if (this->menuItemImage)
     110    delete[] this->menuItemImage;
     111  if (image != NULL)
     112  {
     113    this->menuItemImage = new char[strlen(image)+1];
     114    strcpy(this->menuItemImage, image);
     115  }
     116  else this->menuItemImage = NULL;
     117}
     118
     119
     120/** sets the menu screenshoot of this StoryEntity @param name name */
     121void StoryEntity::setMenuScreenshoot(const char* image)
     122{
     123  if (this->menuScreenshoot)
     124    delete[] this->menuScreenshoot;
     125  if (image != NULL)
     126  {
     127    this->menuScreenshoot = new char[strlen(image)+1];
     128    strcpy(this->menuScreenshoot, image);
     129  }
     130  else this->menuScreenshoot = NULL;
     131}
     132
     133
  • trunk/src/story_entities/story_entity.h

    r6841 r6853  
    6767  /**  gets the story id of the current entity @returns story id */
    6868  inline int getNextStoryID() { return this->nextStoryID; }
    69   /** sets the descroption of this StoryEntity @param name name */
    70   inline void setDescription(const char* description) { this->description = description; }
     69  inline void setDescription(const char* description);
    7170  /** @returns the description of this StoryEntity */
    7271  inline const char* getDescription() { return this->description; }
     
    7675  inline bool isContainedInMenu() { return this->bMenuEntry; }
    7776  /** sets the menu item image of this StoryEntity @param name name */
    78   inline void setMenuItemImage(const char* image) { this->menuItemImage = image; }
     77  inline void setMenuItemImage(const char* image);
    7978  /** @returns the menu item image of this StoryEntity */
    8079  inline const char* getMenuItemImage() { return this->menuItemImage; }
    81   /** sets the menu screenshoot of this StoryEntity @param name name */
    82   inline void setMenuScreenshoot(const char* image) { this->menuScreenshoot = image; }
     80  inline void setMenuScreenshoot(const char* image);
    8381  /** @returns the menu screenshoot of this StoryEntity */
    8482  inline const char* getMenuScreenshoot() { return this->menuScreenshoot; }
     
    9492    int storyID;            //!< this is the number of this entity, identifying it in a list/tree...
    9593    int nextStoryID;        //!< if this entity has finished, this entity shall be called
    96     const char* description;//!< the description of the StoryEntity
    97     const char* menuItemImage;//!< the item image of the StoryEntity
    98     const char* menuScreenshoot;//!< the screenshoot of the StoryEntity
     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
    9997    bool        bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    10098};
Note: See TracChangeset for help on using the changeset viewer.