Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6520 in orxonox.OLD for branches/network/src/story_entities


Ignore:
Timestamp:
Jan 18, 2006, 12:58:14 AM (19 years ago)
Author:
patrick
Message:

network: the simple menu now works. now i need more graphics, more effects and more sound

Location:
branches/network/src/story_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/story_entities/simple_game_menu.cc

    r6504 r6520  
    2727
    2828#include "world_entity.h"
     29#include "image_entity.h"
    2930#include "terrain.h"
    3031
     
    105106  EventHandler::getInstance()->pushState(ES_MENU);
    106107
     108
     109//   const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
     110//   assert(playableList != NULL);
     111//   std::list<BaseObject*>::const_iterator entity;
     112
     113  /* get the menu list */
     114  const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY);
     115  std::list<BaseObject*>::const_iterator entity;
     116  for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)
     117  {
     118
     119    if( !strcmp("Selector_Menu", (*entity)->getName()))
     120    {
     121      this->menuSelector = dynamic_cast<ImageEntity*>(*entity);
     122      PRINTF(0)("Found the selector: %s\n", (*entity)->getName());
     123    }
     124    else if( !strcmp( "StartGame_Menu", (*entity)->getName()))
     125    {
     126      PRINTF(0)("Found a StartItem: %s\n", (*entity)->getName());
     127      this->menuStartGame = dynamic_cast<ImageEntity*>(*entity);
     128      this->menuList.push_back(dynamic_cast<ImageEntity*>(*entity));
     129    }
     130    else if( !strcmp( "Multiplayer_Menu", (*entity)->getName()))
     131    {
     132      PRINTF(0)("Found a MultiplayerItem: %s\n", (*entity)->getName());
     133      this->menuStartMultiplayerGame = dynamic_cast<ImageEntity*>(*entity);
     134      this->menuList.push_back(dynamic_cast<ImageEntity*>(*entity));
     135    }
     136    else if( !strcmp( "Quit_Menu", (*entity)->getName()))
     137    {
     138      PRINTF(0)("Found a QuitItem: %s\n", (*entity)->getName());
     139      this->menuQuitGame = dynamic_cast<ImageEntity*>(*entity);
     140      this->menuList.push_back(dynamic_cast<ImageEntity*>(*entity));
     141    }
     142  }
     143  this->menuSelectedIndex = 0;
     144  this->menuSelected = this->menuList[this->menuSelectedIndex];
     145  this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     146
    107147  /* now call the underlying*/
    108148  GameWorld::start();
     
    138178  if( event.type == SDLK_RETURN)
    139179  {
    140     this->stop();
     180    if( this->menuSelected == this->menuQuitGame)
     181    {
     182      this->setNextStoryID(999);
     183      this->stop();
     184    }
     185    if( this->menuSelected == this->menuStartGame)
     186    {
     187      this->stop();
     188    }
     189  }
     190  else if( event.type == SDLK_DOWN && event.bPressed == true)
     191  {
     192//     ImageEntity*
     193    if(this->menuSelectedIndex < (this->menuList.size() - 1))
     194    {
     195      this->menuSelected = this->menuList[++this->menuSelectedIndex];
     196      this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     197    }
     198  }
     199  else if( event.type == SDLK_UP && event.bPressed == true)
     200  {
     201    if(this->menuSelectedIndex > 0)
     202    {
     203      this->menuSelected = this->menuList[--this->menuSelectedIndex];
     204      this->menuSelector->setAbsCoor(this->menuSelected->getAbsCoor());
     205    }
    141206  }
    142207}
  • branches/network/src/story_entities/simple_game_menu.h

    r6504 r6520  
    1111#include "event_listener.h"
    1212#include "game_world_data.h"
    13 
     13#include <vector>
    1414
    1515
    1616class SimpleGameMenuData;
    1717class TiXmlElement;
    18 
     18class ImageEntity;
    1919
    2020//! a simple game menu based on a story entity
     
    4141  protected:
    4242    virtual void collide();
     43
     44
     45  private:
     46    std::vector<ImageEntity*>         menuList;                        //!< the list of the menu items
     47    ImageEntity*                      menuSelected;                    //!< ref to the selected menu entity
     48    ImageEntity*                      menuSelector;                    //!< ref to the selector image
     49    ImageEntity*                      menuStartGame;
     50    ImageEntity*                      menuStartMultiplayerGame;
     51    ImageEntity*                      menuQuitGame;
     52    int                               menuSelectedIndex;
    4353};
    4454
Note: See TracChangeset for help on using the changeset viewer.