Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6837 in orxonox.OLD


Ignore:
Timestamp:
Jan 30, 2006, 12:28:03 AM (18 years ago)
Author:
patrick
Message:

trunk: more submenu structure

Location:
trunk/src/story_entities
Files:
4 edited

Legend:

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

    r6835 r6837  
    5656  this->cameraVector = Vector(50.0, 0.0, 0.0);
    5757  this->menuLayer.push_back(new MenuLayer());
     58  this->layerIndex = 0;
    5859
    5960  this->loadParams(root);
     
    216217void SimpleGameMenu::process(const Event &event)
    217218{
    218   if( event.type == SDLK_RETURN)
     219  if( this->layerIndex == 0)
    219220  {
    220     if( this->menuSelected == this->menuQuitGame)
    221     {
    222       this->setNextStoryID(WORLD_ID_GAMEEND);
    223       this->stop();
    224     }
    225     if( this->menuSelected == this->menuStartGame)
    226     {
    227       this->stop();
     221    if( event.type == SDLK_RETURN && event.bPressed == true)
     222    {
     223      if( this->menuSelected == this->menuQuitGame)
     224      {
     225        this->setNextStoryID(WORLD_ID_GAMEEND);
     226        this->stop();
     227      }
     228      if( this->menuSelected == this->menuStartGame)
     229      {
     230        //this->stop();
     231        // switch to first submenu
     232        if( this->menuLayer[1] == NULL)
     233        {
     234          PRINTF(1)("Haven't got any Story Entities to play!\n");
     235          return;
     236        }
     237
     238        this->switchMenuLayer(this->layerIndex, 1);
     239
     240      }
     241    }
     242    else if( event.type == SDLK_DOWN && event.bPressed == true)
     243    {
     244//     ImageEntity*
     245      if(this->menuSelectedIndex < (this->menuLayer[this->layerIndex]->menuList.size() - 1))
     246      {
     247        this->menuSelected = this->menuLayer[this->layerIndex]->menuList[++this->menuSelectedIndex];
     248        this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     249      }
     250    }
     251    else if( event.type == SDLK_UP && event.bPressed == true)
     252    {
     253      if(this->menuSelectedIndex > 0)
     254      {
     255        this->menuSelected = this->menuLayer[this->layerIndex]->menuList[--this->menuSelectedIndex];
     256        this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     257      }
    228258    }
    229259  }
    230   else if( event.type == SDLK_DOWN && event.bPressed == true)
     260  else if( this->layerIndex == 1)
    231261  {
    232 //     ImageEntity*
    233     if(this->menuSelectedIndex < (this->menuLayer[0]->menuList.size() - 1))
    234     {
    235       this->menuSelected = this->menuLayer[0]->menuList[++this->menuSelectedIndex];
    236       this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
    237     }
     262
    238263  }
    239   else if( event.type == SDLK_UP && event.bPressed == true)
     264}
     265
     266
     267/**
     268 *  switches to from one meny layer to an other
     269 * @param layer1 from layer
     270 * @param layer2 to layer
     271 */
     272void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
     273{
     274  // wrong sizes
     275  if(layer1 >= this->menuLayer.size() || layer2 >= this->menuLayer.size())
     276    return;
     277
     278
     279  PRINTF(0)("Removing layer %i\n", layer1);
     280  std::vector<ImageEntity*>::iterator it;
     281  // fade old menu
     282  for( it = this->menuLayer[layer1]->menuList.begin(); it != this->menuLayer[layer1]->menuList.end(); it++ )
    240283  {
    241     if(this->menuSelectedIndex > 0)
    242     {
    243       this->menuSelected = this->menuLayer[0]->menuList[--this->menuSelectedIndex];
    244       this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
    245     }
     284    (*it)->setAbsCoor(Vector(-100, -100, -100));
    246285  }
    247 }
    248 
    249 
     286
     287
     288  PRINTF(0)("Showing layer %i\n", layer1);
     289  // beam here the new menu
     290  for( it = this->menuLayer[layer2]->menuList.begin(); it != this->menuLayer[layer2]->menuList.end(); it++ )
     291  {}
     292
     293  this->layerIndex = layer2;
     294}
    250295
    251296
  • trunk/src/story_entities/simple_game_menu.h

    r6835 r6837  
    6363  private:
    6464    void animateScene(float dt);
     65    void switchMenuLayer(int layer1, int layer2);
    6566
    6667
     
    6869    std::vector<MenuLayer*>           menuLayer;                       //!< the menu layer
    6970    MenuLayer*                        selectedLayer;                   //!< the selected menu layer
     71    int                               layerIndex;
    7072
    7173    //std::vector<ImageEntity*>         menuList;                        //!< the list of the menu items
  • trunk/src/story_entities/story_entity.cc

    r6835 r6837  
    4040
    4141  this->storyID = -1;
     42  this->name = NULL;
    4243  this->nextStoryID = WORLD_ID_GAMEEND;
    4344}
     
    6869      .describe("Sets the name of this StoryEntity");
    6970
     71  LoadParam(root, "description", this, StoryEntity, setDescription)
     72      .describe("Sets the description of this StoryEntity");
     73
     74
    7075  PRINTF(4)("Loaded StoryEntity specific stuff\n");
    7176}
  • trunk/src/story_entities/story_entity.h

    r6835 r6837  
    7171  /** @returns the name of this StoryEntity */
    7272  inline const char* getName() { return this->name; }
     73  /** sets the descroption of this StoryEntity @param name name */
     74  inline void setDescription(const char* description) { this->description = description; }
     75  /** @returns the description of this StoryEntity */
     76  inline const char* getDescription() { return this->description; }
    7377
    7478
    7579  protected:
    76     bool isInit;         //!< if the entity is initialized, this has to be true.
    77     bool isRunning;      //!< is true if the entity is running
    78     bool isPaused;       //!< is true if the entity is paused
     80    bool isInit;            //!< if the entity is initialized, this has to be true.
     81    bool isRunning;         //!< is true if the entity is running
     82    bool isPaused;          //!< is true if the entity is paused
    7983
    8084
    8185 private:
    82     int storyID;           //!< this is the number of this entity, identifying it in a list/tree...
    83     int nextStoryID;       //!< if this entity has finished, this entity shall be called
    84     const char* name;      //!< name of this StoryEntity
     86    int storyID;            //!< this is the number of this entity, identifying it in a list/tree...
     87    int nextStoryID;        //!< if this entity has finished, this entity shall be called
     88    const char* name;       //!< name of this StoryEntity
     89    const char* description;//!< the description of the StoryEntity
    8590};
    8691
Note: See TracChangeset for help on using the changeset viewer.