Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6837 in orxonox.OLD for trunk/src/story_entities/simple_game_menu.cc


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

trunk: more submenu structure

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.