- Timestamp:
- Jan 30, 2006, 12:28:03 AM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/simple_game_menu.cc
r6835 r6837 56 56 this->cameraVector = Vector(50.0, 0.0, 0.0); 57 57 this->menuLayer.push_back(new MenuLayer()); 58 this->layerIndex = 0; 58 59 59 60 this->loadParams(root); … … 216 217 void SimpleGameMenu::process(const Event &event) 217 218 { 218 if( event.type == SDLK_RETURN)219 if( this->layerIndex == 0) 219 220 { 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 } 228 258 } 229 259 } 230 else if( event.type == SDLK_DOWN && event.bPressed == true)260 else if( this->layerIndex == 1) 231 261 { 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 238 263 } 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 */ 272 void 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++ ) 240 283 { 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)); 246 285 } 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 } 250 295 251 296 -
trunk/src/story_entities/simple_game_menu.h
r6835 r6837 63 63 private: 64 64 void animateScene(float dt); 65 void switchMenuLayer(int layer1, int layer2); 65 66 66 67 … … 68 69 std::vector<MenuLayer*> menuLayer; //!< the menu layer 69 70 MenuLayer* selectedLayer; //!< the selected menu layer 71 int layerIndex; 70 72 71 73 //std::vector<ImageEntity*> menuList; //!< the list of the menu items -
trunk/src/story_entities/story_entity.cc
r6835 r6837 40 40 41 41 this->storyID = -1; 42 this->name = NULL; 42 43 this->nextStoryID = WORLD_ID_GAMEEND; 43 44 } … … 68 69 .describe("Sets the name of this StoryEntity"); 69 70 71 LoadParam(root, "description", this, StoryEntity, setDescription) 72 .describe("Sets the description of this StoryEntity"); 73 74 70 75 PRINTF(4)("Loaded StoryEntity specific stuff\n"); 71 76 } -
trunk/src/story_entities/story_entity.h
r6835 r6837 71 71 /** @returns the name of this StoryEntity */ 72 72 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; } 73 77 74 78 75 79 protected: 76 bool isInit; //!< if the entity is initialized, this has to be true.77 bool isRunning; //!< is true if the entity is running78 bool isPaused; //!< is true if the entity is paused80 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 79 83 80 84 81 85 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 85 90 }; 86 91
Note: See TracChangeset
for help on using the changeset viewer.