Changeset 6520 in orxonox.OLD for branches/network/src/story_entities
- Timestamp:
- Jan 18, 2006, 12:58:14 AM (19 years ago)
- Location:
- branches/network/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/simple_game_menu.cc
r6504 r6520 27 27 28 28 #include "world_entity.h" 29 #include "image_entity.h" 29 30 #include "terrain.h" 30 31 … … 105 106 EventHandler::getInstance()->pushState(ES_MENU); 106 107 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 107 147 /* now call the underlying*/ 108 148 GameWorld::start(); … … 138 178 if( event.type == SDLK_RETURN) 139 179 { 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 } 141 206 } 142 207 } -
branches/network/src/story_entities/simple_game_menu.h
r6504 r6520 11 11 #include "event_listener.h" 12 12 #include "game_world_data.h" 13 13 #include <vector> 14 14 15 15 16 16 class SimpleGameMenuData; 17 17 class TiXmlElement; 18 18 class ImageEntity; 19 19 20 20 //! a simple game menu based on a story entity … … 41 41 protected: 42 42 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; 43 53 }; 44 54
Note: See TracChangeset
for help on using the changeset viewer.