Changeset 7918 in orxonox.OLD for branches/gui/src/story_entities
- Timestamp:
- May 28, 2006, 3:45:31 PM (18 years ago)
- Location:
- branches/gui/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/story_entities/simple_game_menu.cc
r7917 r7918 48 48 49 49 SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) 50 : GameWorld()50 : GameWorld() 51 51 { 52 52 this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); … … 67 67 ///(this is as modular as it is possible). 68 68 OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME"); 69 pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui)); 69 70 pb->show(); 70 71 pb->setAbsCoor2D(50, 50); 71 72 72 OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("DO NOT PUSH ME"); 73 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 74 OrxGui::GLGuiHandler::getInstance()->activate(); 75 ///// 76 77 if (root != NULL) 78 this->loadParams(root); 79 80 State::setMenuID(this->getNextStoryID()); 81 } 82 83 /// HACK only for testing. 84 void SimpleGameMenu::enterGui() 85 { 86 /// 87 OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button"); 73 88 dnpb->show(); 74 89 dnpb->setAbsCoor2D(350, 50); 75 76 OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("REALLY DO NOT PUSH ME!!"); 90 dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL)); 91 92 OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!"); 77 93 rdnpb->show(); 78 94 rdnpb->setAbsCoor2D(200, 180); … … 84 100 input->setAbsCoor2D(200, 230); 85 101 86 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 87 OrxGui::GLGuiHandler::getInstance()->activate(); 102 88 103 ///// 89 90 if (root != NULL) 91 this->loadParams(root); 92 93 State::setMenuID(this->getNextStoryID()); 94 } 95 96 97 /** 98 * @brief remove the SimpleGameMenu from memory 99 * 100 * delete everything explicitly, that isn't contained in the parenting tree! 101 * things contained in the tree are deleted automaticaly 102 */ 104 } 105 106 107 #include "threading.h" 108 void SimpleGameMenu::execURL() const 109 { 110 std::string URL = "http://www.orxonox.net"; 111 SDL_CreateThread(startURL, (void*)&URL); 112 } 113 114 #ifdef __OSX__ 115 #include <ApplicationServices/ApplicationServices.h> 116 #elif defined __WIN32__ 117 #include <shellapi.h> 118 #endif 119 120 int SimpleGameMenu::startURL(void* url) 121 { 122 std::string URL = *(std::string*)url; 123 #ifdef __linux__ 124 system ((std::string("firefox ") + URL).c_str()); 125 #elif defined __OSX__ 126 CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(), 127 kCFStringEncodingASCII, NULL); 128 LSOpenCFURLRef (url_handle, NULL); 129 CFRelease (url_handle); 130 #elif defined __WIN32__ 131 ShellExecute(GetActiveWindow(), 132 "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL); 133 } 134 #endif 135 PRINTF(3)("loaded external webpage %s\n", URL.c_str()); 136 } 137 138 /** 139 * @brief remove the SimpleGameMenu from memory 140 * 141 * delete everything explicitly, that isn't contained in the parenting tree! 142 * things contained in the tree are deleted automaticaly 143 */ 103 144 SimpleGameMenu::~SimpleGameMenu () 104 145 { … … 112 153 113 154 /** 114 115 116 155 * @brief loads the parameters of a SimpleGameMenu from an XML-element 156 * @param root the XML-element to load from 157 */ 117 158 void SimpleGameMenu::loadParams(const TiXmlElement* root) 118 159 { … … 126 167 127 168 /** 128 129 130 131 132 169 * @brief this is executed just before load 170 * 171 * since the load function sometimes needs data, that has been initialized 172 * before the load and after the proceeding storyentity has finished 173 */ 133 174 ErrorMessage SimpleGameMenu::init() 134 175 { … … 152 193 153 194 /** 154 155 195 * @brief load the data 196 */ 156 197 ErrorMessage SimpleGameMenu::loadData() 157 198 { … … 172 213 { 173 214 element = element->FirstChildElement(); 174 // load Players/Objects/Whatever215 // load Players/Objects/Whatever 175 216 PRINTF(4)("Loading Elements\n"); 176 217 while( element != NULL) … … 219 260 this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL); 220 261 this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f, 221 262 State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f)); 222 263 this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity)); 223 264 } … … 267 308 268 309 /** 269 270 271 310 * @brief set the Sound to play when switching menu entry. 311 * @param selectorSound the sound to load. 312 */ 272 313 void SimpleGameMenu::setSelectorSound(const std::string& selectorSound) 273 314 { … … 303 344 304 345 /** 305 306 346 * @brief start the menu 347 */ 307 348 bool SimpleGameMenu::start() 308 349 { … … 316 357 317 358 /** 318 319 359 * stop the menu 360 */ 320 361 bool SimpleGameMenu::stop() 321 362 { … … 328 369 329 370 /** 330 331 371 * override the standard tick for more functionality 372 */ 332 373 void SimpleGameMenu::tick() 333 374 { … … 342 383 343 384 /** 344 345 385 * @brief no collision detection in the menu 386 */ 346 387 void SimpleGameMenu::collide() 347 388 { 348 // this->dataTank->localCamera->349 } 350 351 352 /** 353 354 389 // this->dataTank->localCamera-> 390 } 391 392 393 /** 394 * @brief animate the scene 395 */ 355 396 void SimpleGameMenu::animateScene(float dt) 356 397 { … … 369 410 370 411 /** 371 372 373 412 * @brief event dispatcher funciton 413 * @param event the incoming event 414 */ 374 415 void SimpleGameMenu::process(const Event &event) 375 416 { … … 454 495 455 496 /** 456 457 458 459 497 * @brief switches to from one meny layer to an other 498 * @param layer1 from layer 499 * @param layer2 to layer 500 */ 460 501 void SimpleGameMenu::switchMenuLayer(int layer1, int layer2) 461 502 { … … 517 558 518 559 /********************************************************************************************** 519 520 521 522 523 /** 524 525 560 SimpleGameMenuData 561 **********************************************************************************************/ 562 563 564 /** 565 * SimpleGameMenuData constructor 566 */ 526 567 SimpleGameMenuData::SimpleGameMenuData() 527 568 {} 528 569 529 570 /** 530 531 571 * SimpleGameMenuData decontructor 572 */ 532 573 SimpleGameMenuData::~SimpleGameMenuData() 533 574 {} … … 535 576 536 577 /** 537 538 578 * initialize the GameWorldDataData 579 */ 539 580 ErrorMessage SimpleGameMenuData::init() 540 581 { … … 545 586 546 587 /** 547 548 549 588 * loads the GUI data 589 * @param root reference to the xml root element 590 */ 550 591 ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root) 551 592 { … … 556 597 557 598 /** 558 559 599 * unloads the GUI data 600 */ 560 601 ErrorMessage SimpleGameMenuData::unloadGUI() 561 602 { … … 566 607 567 608 /** 568 569 570 609 * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) 610 * @param root reference to the xml root parameter 611 */ 571 612 ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root) 572 613 { … … 577 618 if( element != NULL) 578 619 { 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 620 element = element->FirstChildElement(); 621 PRINTF(4)("Loading WorldEntities\n"); 622 while(element != NULL) 623 { 624 BaseObject* created = Factory::fabricate(element); 625 if( created != NULL ) 626 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 627 628 if( element->Value() == "SkyBox") 629 this->sky = dynamic_cast<WorldEntity*>(created); 630 if( element->Value() == "Terrain") 631 this->terrain = dynamic_cast<Terrain*>(created); 632 element = element->NextSiblingElement(); 633 } 634 635 PRINTF(4)("Done loading WorldEntities\n"); 595 636 } 596 637 … … 602 643 603 644 /** 604 605 645 * unloads the world entities from the xml file 646 */ 606 647 ErrorMessage SimpleGameMenuData::unloadWorldEntities() 607 648 { … … 612 653 613 654 /** 614 615 616 655 * loads the scene data 656 * @param root reference to the xml root element 657 */ 617 658 ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root) 618 659 { … … 623 664 624 665 /** 625 626 666 * unloads the scene data 667 */ 627 668 ErrorMessage SimpleGameMenuData::unloadScene() 628 669 { -
branches/gui/src/story_entities/simple_game_menu.h
r7884 r7918 49 49 virtual ~SimpleGameMenu(); 50 50 51 /// TODO TAKE THIS OUT 52 void enterGui(); 53 void execURL() const; 54 static int startURL(void* data); 55 /// 51 56 virtual void loadParams(const TiXmlElement* root); 52 57
Note: See TracChangeset
for help on using the changeset viewer.