[6501] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #include "simple_game_menu.h" |
---|
| 20 | |
---|
[6502] | 21 | #include "state.h" |
---|
| 22 | #include "class_list.h" |
---|
| 23 | |
---|
| 24 | #include "load_param.h" |
---|
| 25 | #include "fast_factory.h" |
---|
| 26 | #include "factory.h" |
---|
| 27 | |
---|
[6521] | 28 | #include "p_node.h" |
---|
[6502] | 29 | #include "world_entity.h" |
---|
[6520] | 30 | #include "image_entity.h" |
---|
[6502] | 31 | #include "terrain.h" |
---|
[6521] | 32 | #include "camera.h" |
---|
[6502] | 33 | |
---|
[6504] | 34 | #include "event_handler.h" |
---|
[6524] | 35 | #include "graphics_engine.h" |
---|
[6841] | 36 | #include "object_manager.h" |
---|
[6504] | 37 | |
---|
[6841] | 38 | |
---|
[6502] | 39 | #include "cd_engine.h" |
---|
| 40 | |
---|
| 41 | |
---|
[6501] | 42 | using namespace std; |
---|
| 43 | |
---|
| 44 | |
---|
[6502] | 45 | //! This creates a Factory to fabricate a SimpleGameMenu |
---|
| 46 | CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU); |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) |
---|
[6989] | 51 | : GameWorld() |
---|
[6502] | 52 | { |
---|
| 53 | this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); |
---|
| 54 | this->setName("SimpleGameMenu uninitialized"); |
---|
| 55 | |
---|
| 56 | this->dataTank = new SimpleGameMenuData(); |
---|
| 57 | |
---|
[6521] | 58 | this->cameraVector = Vector(50.0, 0.0, 0.0); |
---|
[6835] | 59 | this->menuLayer.push_back(new MenuLayer()); |
---|
[6839] | 60 | this->menuLayer.push_back(new MenuLayer()); |
---|
[6862] | 61 | |
---|
[6837] | 62 | this->layerIndex = 0; |
---|
[6862] | 63 | this->menuSelectedIndex = 0; |
---|
[6521] | 64 | |
---|
[6502] | 65 | this->loadParams(root); |
---|
[6878] | 66 | |
---|
| 67 | State::setMenuMode(true); |
---|
[6502] | 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
[6501] | 71 | /** |
---|
[6502] | 72 | * remove the SimpleGameMenu from memory |
---|
| 73 | * |
---|
| 74 | * delete everything explicitly, that isn't contained in the parenting tree! |
---|
| 75 | * things contained in the tree are deleted automaticaly |
---|
[6501] | 76 | */ |
---|
[6502] | 77 | SimpleGameMenu::~SimpleGameMenu () |
---|
| 78 | { |
---|
| 79 | PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n"); |
---|
[6501] | 80 | |
---|
[6502] | 81 | if( this->dataTank) |
---|
| 82 | delete this->dataTank; |
---|
| 83 | } |
---|
[6501] | 84 | |
---|
[6502] | 85 | |
---|
| 86 | /** |
---|
| 87 | * loads the parameters of a SimpleGameMenu from an XML-element |
---|
| 88 | * @param root the XML-element to load from |
---|
[6501] | 89 | */ |
---|
[6502] | 90 | void SimpleGameMenu::loadParams(const TiXmlElement* root) |
---|
| 91 | { |
---|
| 92 | /* skip the GameWorld, since it does not define any useful loadParams for this class */ |
---|
[6696] | 93 | //static_cast<GameWorld*>(this)->loadParams(root); |
---|
| 94 | GameWorld::loadParams(root); |
---|
[6501] | 95 | |
---|
[6502] | 96 | PRINTF(4)("Loaded SimpleGameMenu specific stuff\n"); |
---|
| 97 | } |
---|
[6501] | 98 | |
---|
[6502] | 99 | |
---|
[6501] | 100 | /** |
---|
[6504] | 101 | * this is executed just before load |
---|
| 102 | * |
---|
| 103 | * since the load function sometimes needs data, that has been initialized |
---|
| 104 | * before the load and after the proceeding storyentity has finished |
---|
| 105 | */ |
---|
| 106 | ErrorMessage SimpleGameMenu::init() |
---|
| 107 | { |
---|
| 108 | /* call underlying init funciton */ |
---|
| 109 | GameWorld::init(); |
---|
| 110 | |
---|
| 111 | EventHandler::getInstance()->subscribe(this, ES_MENU, SDLK_UP); |
---|
| 112 | EventHandler::getInstance()->subscribe(this, ES_MENU, SDLK_DOWN); |
---|
| 113 | EventHandler::getInstance()->subscribe(this, ES_MENU, SDLK_RETURN); |
---|
| 114 | EventHandler::getInstance()->subscribe(this, ES_MENU, SDLK_SPACE); |
---|
[6854] | 115 | EventHandler::getInstance()->subscribe(this, ES_MENU, SDLK_ESCAPE); |
---|
[6521] | 116 | |
---|
| 117 | this->dataTank->localCamera->setRelCoor(this->cameraVector); |
---|
[6524] | 118 | |
---|
| 119 | GraphicsEngine::getInstance()->displayFPS(false); |
---|
[6862] | 120 | |
---|
| 121 | this->layerIndex = 0; |
---|
| 122 | this->menuSelectedIndex = 0; |
---|
[6504] | 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
[6524] | 126 | /** |
---|
| 127 | * load the data |
---|
| 128 | */ |
---|
[6521] | 129 | ErrorMessage SimpleGameMenu::loadData() |
---|
[6504] | 130 | { |
---|
[6521] | 131 | GameWorld::loadData(); |
---|
[6504] | 132 | |
---|
[6845] | 133 | if (this->dataXML != NULL) |
---|
| 134 | { |
---|
| 135 | TiXmlElement* element = this->dataXML->FirstChildElement("Elements"); |
---|
| 136 | |
---|
| 137 | if( element == NULL) |
---|
| 138 | { |
---|
| 139 | PRINTF(1)("SimpleGameMenu is missing 'Elements'\n"); |
---|
| 140 | } |
---|
| 141 | else |
---|
| 142 | { |
---|
| 143 | element = element->FirstChildElement(); |
---|
| 144 | // load Players/Objects/Whatever |
---|
| 145 | PRINTF(4)("Loading Elements\n"); |
---|
| 146 | while( element != NULL) |
---|
| 147 | { |
---|
| 148 | BaseObject* created = Factory::fabricate(element); |
---|
| 149 | if( created != NULL ) |
---|
[6852] | 150 | { |
---|
| 151 | PRINTF(4)("Created a %s::%s\n", created->getClassName(), created->getName()); |
---|
| 152 | if (!created->isA(CL_ELEMENT_2D)) |
---|
| 153 | PRINTF(2)("Error the Created Entity is not an Element2D but an %s::%s\n", created->getClassName(), created->getName()); |
---|
| 154 | } |
---|
[6851] | 155 | element = element->NextSiblingElement(); |
---|
[6845] | 156 | } |
---|
| 157 | PRINTF(4)("Done loading Elements\n"); |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | |
---|
[6520] | 161 | /* get the menu list */ |
---|
| 162 | const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY); |
---|
| 163 | std::list<BaseObject*>::const_iterator entity; |
---|
| 164 | for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++) |
---|
| 165 | { |
---|
| 166 | |
---|
| 167 | if( !strcmp("Selector_Menu", (*entity)->getName())) |
---|
| 168 | { |
---|
| 169 | this->menuSelector = dynamic_cast<ImageEntity*>(*entity); |
---|
[6878] | 170 | this->menuSelector->setBindNode((const PNode*)NULL); |
---|
[6520] | 171 | } |
---|
| 172 | else if( !strcmp( "StartGame_Menu", (*entity)->getName())) |
---|
| 173 | { |
---|
| 174 | this->menuStartGame = dynamic_cast<ImageEntity*>(*entity); |
---|
[6878] | 175 | this->menuStartGame->setBindNode((const PNode*)NULL); |
---|
[6883] | 176 | this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
| 177 | State::getResY() / 2.0f - 60.0f, |
---|
| 178 | 0.0f); |
---|
[6835] | 179 | this->menuLayer[0]->menuList.push_back(dynamic_cast<ImageEntity*>(*entity)); |
---|
| 180 | |
---|
[6520] | 181 | } |
---|
| 182 | else if( !strcmp( "Multiplayer_Menu", (*entity)->getName())) |
---|
| 183 | { |
---|
| 184 | this->menuStartMultiplayerGame = dynamic_cast<ImageEntity*>(*entity); |
---|
[6878] | 185 | this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL); |
---|
[6883] | 186 | this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
| 187 | State::getResY() / 2.0f + ((this->menuLayer[0]->menuList.size() -1 ) * 60.0f), |
---|
| 188 | 0.0f); |
---|
[6835] | 189 | this->menuLayer[0]->menuList.push_back(dynamic_cast<ImageEntity*>(*entity)); |
---|
[6520] | 190 | } |
---|
| 191 | else if( !strcmp( "Quit_Menu", (*entity)->getName())) |
---|
| 192 | { |
---|
| 193 | this->menuQuitGame = dynamic_cast<ImageEntity*>(*entity); |
---|
[6878] | 194 | this->menuQuitGame->setBindNode((const PNode*)NULL); |
---|
[6883] | 195 | this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
| 196 | State::getResY() / 2.0f + ((this->menuLayer[0]->menuList.size() -1 )* 60.0f), |
---|
| 197 | 0.0f); |
---|
[6835] | 198 | this->menuLayer[0]->menuList.push_back(dynamic_cast<ImageEntity*>(*entity)); |
---|
[6520] | 199 | } |
---|
| 200 | } |
---|
[6980] | 201 | this->menuSelected->getNullElement()->update2D(0.1f); |
---|
[6520] | 202 | this->menuSelectedIndex = 0; |
---|
[6835] | 203 | this->menuSelected = this->menuLayer[0]->menuList[this->menuSelectedIndex]; |
---|
[6878] | 204 | this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D()); |
---|
[6839] | 205 | |
---|
| 206 | |
---|
| 207 | // loading the storyentities submenu (singleplayer) |
---|
| 208 | const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY); |
---|
| 209 | std::list<BaseObject*>::const_iterator it; |
---|
| 210 | for( it = storyEntities->begin(); it != storyEntities->end(); it++) |
---|
| 211 | { |
---|
| 212 | StoryEntity* se = dynamic_cast<StoryEntity*>(*it); |
---|
| 213 | if( se->isContainedInMenu()) |
---|
| 214 | { |
---|
| 215 | this->menuLayer[1]->storyList.push_back(se); |
---|
[6874] | 216 | |
---|
| 217 | // generating menu item |
---|
[6841] | 218 | ImageEntity* ie = new ImageEntity(); |
---|
[6848] | 219 | ie->setTexture(se->getMenuItemImage()); |
---|
| 220 | ie->setVisibility(false); |
---|
[6878] | 221 | ie->setBindNode((const PNode*)NULL); |
---|
[6883] | 222 | ie->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayer[1]->menuList.size() - 2.0f) * 60.0f), 0.0f); |
---|
| 223 | ie->setSize2D(100.0f, 50.0f); |
---|
[6848] | 224 | this->menuLayer[1]->menuList.push_back(ie); |
---|
[6874] | 225 | |
---|
| 226 | // generating screenshoot item |
---|
[6878] | 227 | ie = new ImageEntity(); |
---|
| 228 | ie->setTexture(se->getMenuScreenshoot()); |
---|
| 229 | ie->setVisibility(false); |
---|
| 230 | ie->setBindNode((const PNode*)NULL); |
---|
[6883] | 231 | ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f, 0.0f); |
---|
[6884] | 232 | ie->setSize2D(140.0f, 105.0f); |
---|
[6878] | 233 | this->menuLayer[1]->screenshootList.push_back(ie); |
---|
[6839] | 234 | } |
---|
| 235 | } |
---|
[6521] | 236 | } |
---|
[6520] | 237 | |
---|
[6521] | 238 | |
---|
[6862] | 239 | ErrorMessage SimpleGameMenu::unloadData() |
---|
| 240 | { |
---|
| 241 | GameWorld::unloadData(); |
---|
[6521] | 242 | |
---|
[6862] | 243 | EventHandler::getInstance()->unsubscribe(this, ES_MENU); |
---|
| 244 | |
---|
| 245 | std::vector<ImageEntity*>::iterator it; |
---|
| 246 | std::vector<MenuLayer*>::iterator mit; |
---|
| 247 | for(mit = this->menuLayer.begin(); mit != this->menuLayer.end(); mit++) |
---|
| 248 | { |
---|
| 249 | (*mit)->menuList.erase((*mit)->menuList.begin(), (*mit)->menuList.end()); |
---|
| 250 | (*mit)->storyList.erase((*mit)->storyList.begin(), (*mit)->storyList.end()); |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | |
---|
[6524] | 255 | /** |
---|
| 256 | * start the menu |
---|
| 257 | */ |
---|
[6521] | 258 | bool SimpleGameMenu::start() |
---|
| 259 | { |
---|
| 260 | EventHandler::getInstance()->pushState(ES_MENU); |
---|
| 261 | |
---|
[6504] | 262 | /* now call the underlying*/ |
---|
| 263 | GameWorld::start(); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | |
---|
[6524] | 268 | /** |
---|
| 269 | * stop the menu |
---|
| 270 | */ |
---|
[6504] | 271 | bool SimpleGameMenu::stop() |
---|
| 272 | { |
---|
| 273 | EventHandler::getInstance()->popState(); |
---|
| 274 | |
---|
| 275 | /* now call the underlying*/ |
---|
| 276 | GameWorld::stop(); |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | |
---|
[6521] | 280 | /** |
---|
| 281 | * override the standard tick for more functionality |
---|
| 282 | */ |
---|
| 283 | void SimpleGameMenu::tick() |
---|
| 284 | { |
---|
| 285 | GameWorld::tick(); |
---|
[6504] | 286 | |
---|
[6521] | 287 | this->animateScene(this->dt); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | |
---|
[6504] | 291 | /** |
---|
[6521] | 292 | * no collision detection in the menu |
---|
[6501] | 293 | */ |
---|
[6502] | 294 | void SimpleGameMenu::collide() |
---|
[6521] | 295 | { |
---|
| 296 | // this->dataTank->localCamera-> |
---|
| 297 | } |
---|
[6501] | 298 | |
---|
| 299 | |
---|
[6504] | 300 | /** |
---|
[6521] | 301 | * animate the scene |
---|
| 302 | */ |
---|
| 303 | void SimpleGameMenu::animateScene(float dt) |
---|
| 304 | { |
---|
[6524] | 305 | Quaternion q(/*0.00005*/ 0.0001* dt, Vector(0.0, 1.0, 0.0)); |
---|
[6521] | 306 | this->cameraVector = q.apply(this->cameraVector); |
---|
| 307 | this->dataTank->localCamera->setRelCoor(this->cameraVector); |
---|
| 308 | this->dataTank->localCamera->getTarget()->setRelCoorSoft(0,0,0); |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | /** |
---|
[6504] | 313 | * event dispatcher funciton |
---|
| 314 | * @param event the incoming event |
---|
| 315 | */ |
---|
| 316 | void SimpleGameMenu::process(const Event &event) |
---|
| 317 | { |
---|
[6839] | 318 | /* ----------------- LAYER 1 ---------------*/ |
---|
[6837] | 319 | if( this->layerIndex == 0) |
---|
[6504] | 320 | { |
---|
[6837] | 321 | if( event.type == SDLK_RETURN && event.bPressed == true) |
---|
[6520] | 322 | { |
---|
[6837] | 323 | if( this->menuSelected == this->menuQuitGame) |
---|
| 324 | { |
---|
| 325 | this->setNextStoryID(WORLD_ID_GAMEEND); |
---|
| 326 | this->stop(); |
---|
| 327 | } |
---|
| 328 | if( this->menuSelected == this->menuStartGame) |
---|
| 329 | { |
---|
| 330 | // switch to first submenu |
---|
[6839] | 331 | if( this->menuLayer[1]->menuList.size() == 0) |
---|
[6837] | 332 | { |
---|
[6839] | 333 | PRINTF(1)("Haven't got any StoryEntities to play!\n"); |
---|
[6837] | 334 | return; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | this->switchMenuLayer(this->layerIndex, 1); |
---|
| 338 | } |
---|
[6520] | 339 | } |
---|
[6854] | 340 | if( event.type == SDLK_ESCAPE && event.bPressed == true) |
---|
| 341 | { |
---|
| 342 | this->setNextStoryID(WORLD_ID_GAMEEND); |
---|
| 343 | this->stop(); |
---|
| 344 | } |
---|
[6839] | 345 | } /* ----------------- LAYER 2 ---------------*/ |
---|
[6837] | 346 | else if( this->layerIndex == 1) |
---|
[6520] | 347 | { |
---|
[6848] | 348 | if( event.type == SDLK_RETURN && event.bPressed == true) |
---|
| 349 | { |
---|
| 350 | this->setNextStoryID( this->menuLayer[1]->storyList[this->menuSelectedIndex]->getStoryID()); |
---|
| 351 | this->stop(); |
---|
| 352 | } |
---|
[6854] | 353 | if( event.type == SDLK_ESCAPE && event.bPressed == true) |
---|
| 354 | { |
---|
| 355 | this->switchMenuLayer(this->layerIndex, 0); |
---|
| 356 | } |
---|
[6520] | 357 | } |
---|
[6853] | 358 | |
---|
| 359 | |
---|
| 360 | |
---|
| 361 | // The menu selction cursor |
---|
| 362 | if( event.type == SDLK_DOWN && event.bPressed == true) |
---|
| 363 | { |
---|
| 364 | if(this->menuSelectedIndex < (this->menuLayer[this->layerIndex]->menuList.size() - 1)) |
---|
| 365 | { |
---|
| 366 | this->menuSelected = this->menuLayer[this->layerIndex]->menuList[++this->menuSelectedIndex]; |
---|
[6878] | 367 | this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D()); |
---|
[6883] | 368 | |
---|
| 369 | if( this->layerIndex == 1) |
---|
| 370 | { |
---|
| 371 | this->menuLayer[1]->screenshootList[this->menuSelectedIndex]->setVisibility(true); |
---|
| 372 | this->menuLayer[1]->screenshootList[this->menuSelectedIndex-1]->setVisibility(false); |
---|
| 373 | } |
---|
[6853] | 374 | } |
---|
| 375 | } |
---|
| 376 | else if( event.type == SDLK_UP && event.bPressed == true) |
---|
| 377 | { |
---|
| 378 | if(this->menuSelectedIndex > 0) |
---|
| 379 | { |
---|
| 380 | this->menuSelected = this->menuLayer[this->layerIndex]->menuList[--this->menuSelectedIndex]; |
---|
[6878] | 381 | this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D()); |
---|
[6883] | 382 | |
---|
| 383 | if( this->layerIndex == 1) |
---|
| 384 | { |
---|
| 385 | this->menuLayer[1]->screenshootList[this->menuSelectedIndex]->setVisibility(true); |
---|
| 386 | this->menuLayer[1]->screenshootList[this->menuSelectedIndex+1]->setVisibility(false); |
---|
| 387 | } |
---|
[6853] | 388 | } |
---|
| 389 | } |
---|
[6504] | 390 | } |
---|
[6502] | 391 | |
---|
| 392 | |
---|
[6837] | 393 | /** |
---|
| 394 | * switches to from one meny layer to an other |
---|
| 395 | * @param layer1 from layer |
---|
| 396 | * @param layer2 to layer |
---|
| 397 | */ |
---|
| 398 | void SimpleGameMenu::switchMenuLayer(int layer1, int layer2) |
---|
| 399 | { |
---|
| 400 | // wrong sizes |
---|
| 401 | if(layer1 >= this->menuLayer.size() || layer2 >= this->menuLayer.size()) |
---|
| 402 | return; |
---|
[6502] | 403 | |
---|
| 404 | |
---|
[6837] | 405 | PRINTF(0)("Removing layer %i\n", layer1); |
---|
| 406 | std::vector<ImageEntity*>::iterator it; |
---|
| 407 | // fade old menu |
---|
[6878] | 408 | for( it = this->menuLayer[layer1]->menuList.begin(); it != this->menuLayer[layer1]->menuList.end(); it++) |
---|
[6837] | 409 | { |
---|
[6848] | 410 | (*it)->setVisibility(false); |
---|
[6837] | 411 | } |
---|
[6878] | 412 | //also fade the screenshots if in level choosement mode |
---|
| 413 | for( it = this->menuLayer[layer1]->screenshootList.begin(); it != this->menuLayer[layer1]->screenshootList.end(); it++) |
---|
| 414 | { |
---|
| 415 | (*it)->setVisibility(false); |
---|
| 416 | } |
---|
[6502] | 417 | |
---|
| 418 | |
---|
[6837] | 419 | PRINTF(0)("Showing layer %i\n", layer1); |
---|
| 420 | // beam here the new menu |
---|
| 421 | for( it = this->menuLayer[layer2]->menuList.begin(); it != this->menuLayer[layer2]->menuList.end(); it++ ) |
---|
[6848] | 422 | { |
---|
| 423 | (*it)->setVisibility(true); |
---|
| 424 | } |
---|
[6837] | 425 | |
---|
[6878] | 426 | |
---|
[6837] | 427 | this->layerIndex = layer2; |
---|
[6854] | 428 | this->menuSelected = this->menuLayer[layer2]->menuList[0]; |
---|
[6878] | 429 | this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D()); |
---|
[6855] | 430 | this->menuSelectedIndex = 0; |
---|
[6883] | 431 | |
---|
| 432 | if( layer2 == 1) |
---|
| 433 | this->menuLayer[layer2]->screenshootList[0]->setVisibility(true); |
---|
[6837] | 434 | } |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | |
---|
[6502] | 439 | /********************************************************************************************** |
---|
| 440 | SimpleGameMenuData |
---|
| 441 | **********************************************************************************************/ |
---|
| 442 | |
---|
| 443 | |
---|
[6501] | 444 | /** |
---|
[6502] | 445 | * SimpleGameMenuData constructor |
---|
[6501] | 446 | */ |
---|
[6502] | 447 | SimpleGameMenuData::SimpleGameMenuData() |
---|
[6501] | 448 | {} |
---|
| 449 | |
---|
| 450 | /** |
---|
[6502] | 451 | * SimpleGameMenuData decontructor |
---|
[6501] | 452 | */ |
---|
[6502] | 453 | SimpleGameMenuData::~SimpleGameMenuData() |
---|
[6501] | 454 | {} |
---|
| 455 | |
---|
| 456 | |
---|
| 457 | /** |
---|
[6502] | 458 | * initialize the GameWorldDataData |
---|
[6501] | 459 | */ |
---|
[6502] | 460 | ErrorMessage SimpleGameMenuData::init() |
---|
| 461 | { |
---|
| 462 | /* call underlying function */ |
---|
| 463 | GameWorldData::init(); |
---|
| 464 | } |
---|
[6501] | 465 | |
---|
| 466 | |
---|
| 467 | /** |
---|
[6502] | 468 | * loads the GUI data |
---|
| 469 | * @param root reference to the xml root element |
---|
[6501] | 470 | */ |
---|
[6502] | 471 | ErrorMessage SimpleGameMenuData::loadGUI(TiXmlElement* root) |
---|
| 472 | { |
---|
| 473 | /* call underlying function */ |
---|
| 474 | GameWorldData::loadGUI(root); |
---|
| 475 | } |
---|
[6501] | 476 | |
---|
| 477 | |
---|
| 478 | /** |
---|
[6502] | 479 | * unloads the GUI data |
---|
[6501] | 480 | */ |
---|
[6502] | 481 | ErrorMessage SimpleGameMenuData::unloadGUI() |
---|
| 482 | { |
---|
| 483 | /* call underlying function */ |
---|
| 484 | GameWorldData::unloadGUI(); |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | |
---|
| 488 | /** |
---|
| 489 | * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) |
---|
| 490 | * @param root reference to the xml root parameter |
---|
| 491 | */ |
---|
| 492 | ErrorMessage SimpleGameMenuData::loadWorldEntities(TiXmlElement* root) |
---|
| 493 | { |
---|
| 494 | TiXmlElement* element = root->FirstChildElement("WorldEntities"); |
---|
| 495 | |
---|
| 496 | if( element != NULL) |
---|
| 497 | { |
---|
| 498 | element = element->FirstChildElement(); |
---|
| 499 | PRINTF(4)("Loading WorldEntities\n"); |
---|
| 500 | while( element != NULL) |
---|
| 501 | { |
---|
| 502 | BaseObject* created = Factory::fabricate(element); |
---|
| 503 | if( created != NULL ) |
---|
| 504 | printf("Created a %s: %s\n", created->getClassName(), created->getName()); |
---|
| 505 | |
---|
| 506 | if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) |
---|
| 507 | this->sky = dynamic_cast<WorldEntity*>(created); |
---|
| 508 | if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) |
---|
| 509 | this->terrain = dynamic_cast<Terrain*>(created); |
---|
| 510 | element = element->NextSiblingElement(); |
---|
| 511 | } |
---|
| 512 | PRINTF(4)("Done loading WorldEntities\n"); |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | /* init the pnode tree */ |
---|
| 516 | PNode::getNullParent()->init(); |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | |
---|
| 520 | /** |
---|
| 521 | * unloads the world entities from the xml file |
---|
| 522 | */ |
---|
| 523 | ErrorMessage SimpleGameMenuData::unloadWorldEntities() |
---|
| 524 | { |
---|
| 525 | /* call underlying function */ |
---|
| 526 | GameWorldData::unloadWorldEntities(); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | /** |
---|
| 531 | * loads the scene data |
---|
| 532 | * @param root reference to the xml root element |
---|
| 533 | */ |
---|
| 534 | ErrorMessage SimpleGameMenuData::loadScene(TiXmlElement* root) |
---|
| 535 | { |
---|
| 536 | /* call underlying function */ |
---|
| 537 | GameWorldData::loadScene(root); |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | |
---|
| 541 | /** |
---|
| 542 | * unloads the scene data |
---|
| 543 | */ |
---|
| 544 | ErrorMessage SimpleGameMenuData::unloadScene() |
---|
| 545 | { |
---|
| 546 | /* call underlying function */ |
---|
| 547 | GameWorldData::unloadScene(); |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | |
---|
| 551 | |
---|