- Timestamp:
- Jun 21, 2006, 3:43:44 PM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/defs/class_id.h
r8619 r8673 146 146 CL_MOVIE_LOADER = 0x00000109, 147 147 148 CL_GAME_MENU = 0x00000110, 149 CL_GAME_MENU_DATA = 0x00000111, 150 151 148 152 CL_MULTIPLAYER_TEAM_DEATHMATCH= 0x00000121, 149 153 CL_SINGLEPLAYER_SHOOTEMUP = 0x00000122, -
branches/gui/src/lib/gui/gl/glgui_handler.cc
r8672 r8673 102 102 void GLGuiHandler::selectNext() 103 103 { 104 printf("searching next Widget\n");105 104 // retrieve Objects. 106 105 const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET); -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8667 r8673 48 48 /** @returns true if the widget is focusable */ 49 49 bool focusable() const { return this->_focusable; }; 50 /** @param focusable sets if the Widget should be focusable */51 void setFocusable(bool focusable = true) { this->_focusable = focusable; };52 50 /** @returns true if the position is inside of the Widget. @param position the position to check */ 53 51 bool focusOverWidget(const Vector2D& position) const; … … 63 61 /** @returns true if the Widget is selectable */ 64 62 bool selectable() const { return this->_selectable; } 65 /** @param selectable true if the widget should be selectable */66 void setSelectable(bool selectable) { this->_selectable = selectable; }67 63 68 64 /** @returns the currently Selected Widget (NULL if none is selected). */ … … 74 70 void release(const Vector2D& pos); 75 71 bool clickable() const { return this->_clickable; }; 76 void setClickable(bool clickable = true) { this->_clickable = clickable; };77 72 78 73 static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor); … … 238 233 239 234 protected: 235 /** @param focusable sets if the Widget should be focusable */ 236 void setFocusable(bool focusable = true) { this->_focusable = focusable; }; 237 /** @param selectable true if the widget should be selectable */ 238 void setSelectable(bool selectable) { this->_selectable = selectable; } 239 /** @param focusable true if the widget should be focusable */ 240 void setClickable(bool clickable = true) { this->_clickable = clickable; }; 241 242 240 243 /// RENDERING 241 244 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; -
branches/gui/src/story_entities/Makefile.am
r6634 r8673 13 13 story_entities/multi_player_world_data.cc \ 14 14 story_entities/movie_loader.cc \ 15 story_entities/game_menu.cc \ 15 16 story_entities/simple_game_menu.cc 16 17 … … 27 28 story_entities/multi_player_world_data.h \ 28 29 story_entities/movie_loader.h \ 30 story_entities/game_menu.h \ 29 31 story_entities/simple_game_menu.h -
branches/gui/src/story_entities/game_menu.cc
r8667 r8673 17 17 18 18 19 #include " simple_game_menu.h"19 #include "game_menu.h" 20 20 21 21 #include "event_handler.h" … … 44 44 #include "gui/gl/specials/glgui_notifier.h" 45 45 46 //! This creates a Factory to fabricate a SimpleGameMenu47 CREATE_FACTORY( SimpleGameMenu, CL_SIMPLE_GAME_MENU);48 49 50 51 SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)46 //! This creates a Factory to fabricate a GameMenu 47 CREATE_FACTORY(GameMenu, CL_GAME_MENU); 48 49 50 51 GameMenu::GameMenu(const TiXmlElement* root) 52 52 : GameWorld() 53 53 { 54 this->setClassID(CL_ SIMPLE_GAME_MENU, "SimpleGameMenu");55 this->setName(" SimpleGameMenu uninitialized");56 57 this->dataTank = new SimpleGameMenuData();54 this->setClassID(CL_GAME_MENU, "GameMenu"); 55 this->setName("GameMenu uninitialized"); 56 57 this->dataTank = new GameMenuData(); 58 58 59 59 this->cameraVector = Vector(50.0, 0.0, 0.0); 60 this->menuLayers.push_back(MenuLayer()); 61 this->menuLayers.push_back(MenuLayer()); 62 63 this->layerIndex = 0; 64 this->menuSelectedIndex = 0; 65 this->selectorSource = NULL; 66 67 68 /// GUI 69 ///(this is as modular as it is possible). 70 OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME"); 71 //pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui)); 72 pb->connect(SIGNAL(pb, released), this, SLOT(SimpleGameMenu, enterGui)); 73 pb->show(); 74 pb->setAbsCoor2D(50, 50); 60 75 61 76 62 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 77 63 OrxGui::GLGuiHandler::getInstance()->activate(); 78 64 OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 1, 49); 79 /////80 65 81 66 if (root != NULL) … … 86 71 87 72 /// HACK only for testing. 88 void SimpleGameMenu::enterGui() 89 { 90 91 OrxGui::GLGuiNotifier* notifier = new OrxGui::GLGuiNotifier(); 92 notifier->show(); 93 notifier->setAbsCoor2D(300, 300); 94 95 96 97 OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox(); 98 { 99 /// 100 OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button"); 101 102 box->pack(dnpb); 103 104 OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!"); 105 rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu)); 106 107 box->pack(rdnpb); 108 109 OrxGui::GLGuiCheckButton* fullscreen = new OrxGui::GLGuiCheckButton("Fullscreen"); 110 fullscreen->connect(SIGNAL(fullscreen, toggled), GraphicsEngine::getInstance(), SLOT(GraphicsEngine, setFullscreen)); 111 112 box->pack(fullscreen); 113 114 OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine(); 115 input->setText("input some text here"); 116 input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage)); 117 118 box->pack(input); 119 120 OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider(); 121 slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST)); 122 slider->setRange(0, 1); 123 slider->setValue(slider->min()); 124 box->pack(slider); 125 126 127 OrxGui::GLGuiTable* table = new OrxGui::GLGuiTable(3, 3); 128 std::vector<std::string> headers; 129 headers.push_back("1"); 130 headers.push_back("2"); 131 headers.push_back("3"); 132 table->setHeader(headers); 133 table->setEntry(1, 2, "Test"); 134 table->setEntry(2, 1, "MultiLine SuperTest to see how it works"); 135 136 137 box->pack(table); 138 } 139 box->setAbsCoor2D(50, 200); 140 141 box->showAll(); 142 143 144 OrxGui::GLGuiBox* imageSelector = new OrxGui::GLGuiBox(); 145 { 146 image = new OrxGui::GLGuiImage(); 147 image->setWidgetSize(300, 300); 148 image->setAbsCoor2D(300, 300); 149 imageSelector->pack(image); 150 151 imageName = new OrxGui::GLGuiInputLine(); 152 imageSelector->pack(imageName); 153 154 OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider(); 155 slider->setWidgetSize(200, 30); 156 slider->setRange(0, 100); 157 slider->setStep(1); 158 slider->setValue(slider->min()); 159 slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, setImage)); 160 161 imageSelector->pack(slider); 162 slider->setValue(0); 163 } 164 imageSelector->showAll(); 165 imageSelector->setAbsCoor2D(400, 30); 166 167 168 ///// 169 } 170 171 172 #include "class_list.h" 173 void SimpleGameMenu::setImage(int i) 174 { 175 const std::list<BaseObject*>* textures = ClassList::getList(CL_TEXTURE); 176 177 if(textures) 178 { 179 std::list<BaseObject*>::const_iterator test = textures->begin(); 180 std::list<BaseObject*>::const_iterator lastOK = textures->begin(); 181 while (true) 182 { 183 if (--i == 0 || test == textures->end()) 184 break; 185 if (dynamic_cast<Texture*>(*test)->getTexture() != 0) 186 lastOK = test; 187 test++; 188 } 189 this->image->loadImageFromTexture(*dynamic_cast<Texture*>(*lastOK)); 190 this->imageName->setText((*lastOK)->getName()); 191 } 192 } 193 194 195 #include "threading.h" 196 void SimpleGameMenu::execURL() const 197 { 198 std::string URL = "http://www.orxonox.net"; 199 SDL_CreateThread(startURL, (void*)&URL); 200 } 201 202 #ifdef __OSX__ 203 #include <ApplicationServices/ApplicationServices.h> 204 #elif defined __WIN32__ 205 //#include <shellapi.h> 206 #endif 207 208 int SimpleGameMenu::startURL(void* url) 209 { 210 std::string URL = *(std::string*)url; 211 #ifdef __linux__ 212 system ((std::string("firefox ") + URL).c_str()); 213 #elif defined __OSX__ 214 CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(), 215 kCFStringEncodingASCII, NULL); 216 LSOpenCFURLRef (url_handle, NULL); 217 CFRelease (url_handle); 218 #elif defined __WIN32__ 219 /* ShellExecute(GetActiveWindow(), 220 "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL); 221 }*/ 222 #endif 223 PRINTF(3)("loaded external webpage %s\n", URL.c_str()); 224 } 225 226 /** 227 * @brief remove the SimpleGameMenu from memory 73 void GameMenu::enterGui() 74 { 75 } 76 77 /** 78 * @brief remove the GameMenu from memory 228 79 * 229 80 * delete everything explicitly, that isn't contained in the parenting tree! 230 81 * things contained in the tree are deleted automaticaly 231 82 */ 232 SimpleGameMenu::~SimpleGameMenu ()233 { 234 PRINTF(3)(" SimpleGameMenu::~SimpleGameMenu() - deleting current world\n");83 GameMenu::~GameMenu () 84 { 85 PRINTF(3)("GameMenu::~GameMenu() - deleting current world\n"); 235 86 236 87 if( this->dataTank) … … 241 92 242 93 /** 243 * @brief loads the parameters of a SimpleGameMenu from an XML-element94 * @brief loads the parameters of a GameMenu from an XML-element 244 95 * @param root the XML-element to load from 245 96 */ 246 void SimpleGameMenu::loadParams(const TiXmlElement* root)97 void GameMenu::loadParams(const TiXmlElement* root) 247 98 { 248 99 /* skip the GameWorld, since it does not define any useful loadParams for this class */ … … 250 101 GameWorld::loadParams(root); 251 102 252 PRINTF(4)("Loaded SimpleGameMenu specific stuff\n");103 PRINTF(4)("Loaded GameMenu specific stuff\n"); 253 104 } 254 105 … … 260 111 * before the load and after the proceeding storyentity has finished 261 112 */ 262 ErrorMessage SimpleGameMenu::init()113 ErrorMessage GameMenu::init() 263 114 { 264 115 /* call underlying init funciton */ … … 275 126 GraphicsEngine::getInstance()->displayFPS(false); 276 127 277 this->layerIndex = 0;278 this->menuSelectedIndex = 0;279 128 } 280 129 … … 283 132 * @brief load the data 284 133 */ 285 ErrorMessage SimpleGameMenu::loadData()134 ErrorMessage GameMenu::loadData() 286 135 { 287 136 GameWorld::loadData(); 288 289 if (this->dataXML != NULL)290 {291 LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound);292 293 TiXmlElement* element = this->dataXML->FirstChildElement("Elements");294 295 296 if( element == NULL)297 {298 PRINTF(1)("SimpleGameMenu is missing 'Elements'\n");299 }300 else301 {302 element = element->FirstChildElement();303 // load Players/Objects/Whatever304 PRINTF(4)("Loading Elements\n");305 while( element != NULL)306 {307 BaseObject* created = Factory::fabricate(element);308 if( created != NULL )309 {310 PRINTF(4)("Created a %s::%s\n", created->getClassName(), created->getName());311 if (!created->isA(CL_ELEMENT_2D))312 PRINTF(2)("Error the Created Entity is not an Element2D but an %s::%s\n", created->getClassName(), created->getName());313 }314 element = element->NextSiblingElement();315 }316 PRINTF(4)("Done loading Elements\n");317 }318 }319 320 /* get the menu list */321 const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY);322 std::list<BaseObject*>::const_iterator entity;323 for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)324 {325 326 if( !strcmp("Selector_Menu", (*entity)->getName()))327 {328 this->menuSelector = dynamic_cast<ImageEntity*>(*entity);329 this->menuSelector->setBindNode((const PNode*)NULL);330 }331 }332 333 imageEntityList = ClassList::getList(CL_TEXT_ELEMENT);334 for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)335 {336 if( !strcmp( "StartGame_Menu", (*entity)->getName()))337 {338 this->menuStartGame = dynamic_cast<TextElement*>(*entity);339 this->menuStartGame->setBindNode((const PNode*)NULL);340 this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f,341 State::getResY() / 2.0f - 60.0f);342 this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));343 344 }345 else if( !strcmp( "Multiplayer_Menu", (*entity)->getName()))346 {347 this->menuStartMultiplayerGame = dynamic_cast<TextElement*>(*entity);348 this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);349 this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,350 State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));351 this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));352 }353 else if( !strcmp( "Quit_Menu", (*entity)->getName()))354 {355 this->menuQuitGame = dynamic_cast<TextElement*>(*entity);356 this->menuQuitGame->setBindNode((const PNode*)NULL);357 this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f,358 State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f));359 this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));360 }361 }362 this->menuSelected->getNullElement()->update2D(0.1f);363 this->menuSelectedIndex = 0;364 this->menuSelected = this->menuLayers[0].menuList[this->menuSelectedIndex];365 this->sliderTo(this->menuSelected, 0.0f);366 367 368 // loading the storyentities submenu (singleplayer)369 const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY);370 std::list<BaseObject*>::const_iterator it;371 for( it = storyEntities->begin(); it != storyEntities->end(); it++)372 {373 StoryEntity* se = dynamic_cast<StoryEntity*>(*it);374 if( se->isContainedInMenu())375 {376 this->menuLayers[1].storyList.push_back(se);377 378 // generating menu item379 TextElement* te = new TextElement();380 te->setVisibility(false);381 te->setText(se->getName());382 te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f));383 this->menuLayers[1].menuList.push_back(te);384 385 // generating screenshoot item386 ImageEntity* ie = new ImageEntity();387 ie->setVisibility(false);388 ie->setBindNode((const PNode*)NULL);389 ie->setTexture(se->getMenuScreenshoot());390 ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f);391 ie->setSize2D(140.0f, 105.0f);392 this->menuLayers[1].screenshootList.push_back(ie);393 }394 }395 137 } 396 138 … … 399 141 * @param selectorSound the sound to load. 400 142 */ 401 void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)143 void GameMenu::setSelectorSound(const std::string& selectorSound) 402 144 { 403 145 this->selectorSource = OrxSound::SoundEngine::getInstance()->createSource(selectorSound, NULL); 404 146 } 405 147 406 ErrorMessage SimpleGameMenu::unloadData()148 ErrorMessage GameMenu::unloadData() 407 149 { 408 150 this->unsubscribeEvents(ES_MENU); 409 151 410 std::vector<MenuLayer>::iterator mit;411 for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++)412 {413 while(!(*mit).menuList.empty())414 {415 delete (*mit).menuList.back();416 (*mit).menuList.pop_back();417 }418 419 (*mit).menuList.clear();420 (*mit).storyList.clear();421 (*mit).screenshootList.clear();422 }423 424 // delete the SoundSource.425 if (this->selectorSource != NULL)426 delete this->selectorSource;427 this->selectorSource = NULL;428 429 152 GameWorld::unloadData(); 430 153 } … … 434 157 * @brief start the menu 435 158 */ 436 bool SimpleGameMenu::start()159 bool GameMenu::start() 437 160 { 438 161 EventHandler::getInstance()->pushState(ES_MENU); … … 447 170 * stop the menu 448 171 */ 449 bool SimpleGameMenu::stop()172 bool GameMenu::stop() 450 173 { 451 174 EventHandler::getInstance()->popState(); … … 459 182 * override the standard tick for more functionality 460 183 */ 461 void SimpleGameMenu::tick()184 void GameMenu::tick() 462 185 { 463 186 GameWorld::tick(); … … 473 196 * @brief no collision detection in the menu 474 197 */ 475 void SimpleGameMenu::collide()198 void GameMenu::collide() 476 199 { 477 200 // this->dataTank->localCamera-> … … 482 205 * @brief animate the scene 483 206 */ 484 void SimpleGameMenu::animateScene(float dt)207 void GameMenu::animateScene(float dt) 485 208 { 486 209 Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0)); … … 490 213 } 491 214 492 void SimpleGameMenu::quitMenu()215 void GameMenu::quitMenu() 493 216 { 494 217 this->setNextStoryID(WORLD_ID_GAMEEND); … … 501 224 * @param event the incoming event 502 225 */ 503 void SimpleGameMenu::process(const Event &event) 504 { 505 /* ----------------- LAYER 1 ---------------*/ 506 if( this->layerIndex == 0) 507 { 508 if( event.type == SDLK_RETURN && event.bPressed == true) 509 { 510 if( this->menuSelected == this->menuQuitGame) 511 { 512 this->setNextStoryID(WORLD_ID_GAMEEND); 513 this->stop(); 514 } 515 if( this->menuSelected == this->menuStartGame) 516 { 517 // switch to first submenu 518 if( this->menuLayers[1].menuList.size() == 0) 519 { 520 PRINTF(1)("Haven't got any StoryEntities to play!\n"); 521 return; 522 } 523 524 this->switchMenuLayer(this->layerIndex, 1); 525 } 526 } 527 if( event.type == SDLK_ESCAPE && event.bPressed == true) 528 { 529 this->setNextStoryID(WORLD_ID_GAMEEND); 530 this->stop(); 531 } 532 } /* ----------------- LAYER 2 ---------------*/ 533 else if( this->layerIndex == 1) 534 { 535 if( event.type == SDLK_RETURN && event.bPressed == true) 536 { 537 this->setNextStoryID( this->menuLayers[1].storyList[this->menuSelectedIndex]->getStoryID()); 538 this->stop(); 539 } 540 if( event.type == SDLK_ESCAPE && event.bPressed == true) 541 { 542 this->switchMenuLayer(this->layerIndex, 0); 543 } 544 } 545 546 547 548 // The menu selction cursor 549 if( event.type == SDLK_DOWN && event.bPressed == true) 550 { 551 if(this->menuSelectedIndex < (this->menuLayers[this->layerIndex].menuList.size() - 1)) 552 { 553 this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex]; 554 this->sliderTo(this->menuSelected, 5.0f); 555 if (this->selectorSource != NULL) 556 this->selectorSource->play(); 557 558 if( this->layerIndex == 1) 559 { 560 this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true); 561 this->menuLayers[1].screenshootList[this->menuSelectedIndex-1]->setVisibility(false); 562 } 563 } 564 } 565 else if( event.type == SDLK_UP && event.bPressed == true) 566 { 567 if(this->menuSelectedIndex > 0) 568 { 569 this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex]; 570 this->sliderTo(this->menuSelected, 5.0f); 571 if (this->selectorSource != NULL) 572 this->selectorSource->play(); 573 574 if( this->layerIndex == 1) 575 { 576 this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true); 577 this->menuLayers[1].screenshootList[this->menuSelectedIndex+1]->setVisibility(false); 578 } 579 } 580 } 581 } 582 583 584 /** 585 * @brief switches to from one meny layer to an other 586 * @param layer1 from layer 587 * @param layer2 to layer 588 */ 589 void SimpleGameMenu::switchMenuLayer(int layer1, int layer2) 590 { 591 // wrong sizes 592 if(layer1 >= this->menuLayers.size() || layer2 >= this->menuLayers.size()) 593 return; 594 595 596 PRINTF(0)("Removing layer %i\n", layer1); 597 std::vector<TextElement*>::iterator te; 598 // fade old menu 599 for( te = this->menuLayers[layer1].menuList.begin(); te != this->menuLayers[layer1].menuList.end(); te++) 600 { 601 (*te)->setVisibility(false); 602 } 603 604 std::vector<ImageEntity*>::iterator it; 605 606 //also fade the screenshots if in level choosement mode 607 for( it = this->menuLayers[layer1].screenshootList.begin(); it != this->menuLayers[layer1].screenshootList.end(); it++) 608 { 609 (*it)->setVisibility(false); 610 } 611 612 613 PRINTF(0)("Showing layer %i\n", layer1); 614 // beam here the new menu 615 for( te = this->menuLayers[layer2].menuList.begin(); te != this->menuLayers[layer2].menuList.end(); te++ ) 616 { 617 (*te)->setVisibility(true); 618 } 619 620 621 this->layerIndex = layer2; 622 this->menuSelected = this->menuLayers[layer2].menuList[0]; 623 this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D() + Vector2D(0, this->menuSelected->getSizeY2D() *.5)); 624 this->menuSelector->setSize2D(this->menuSelected->getSizeX2D()*.7, this->menuSelected->getSizeY2D()); 625 this->menuSelectedIndex = 0; 626 627 if( layer2 == 1) 628 this->menuLayers[layer2].screenshootList[0]->setVisibility(true); 629 } 630 631 void SimpleGameMenu::sliderTo(const Element2D* element, float bias) 632 { 633 if (bias > 0.0) 634 { 635 this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias); 636 this->menuSelector->setSizeSoft2D(element->getSizeX2D()*.7, element->getSizeY2D(), bias); 637 } 638 else 639 { 640 this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5)); 641 this->menuSelector->setSize2D(element->getSizeX2D()*.7, element->getSizeY2D()); 642 } 226 void GameMenu::process(const Event &event) 227 { 643 228 } 644 229 … … 646 231 647 232 /********************************************************************************************** 648 SimpleGameMenuData233 GameMenuData 649 234 **********************************************************************************************/ 650 235 651 236 652 237 /** 653 * SimpleGameMenuData constructor654 */ 655 SimpleGameMenuData::SimpleGameMenuData()238 * GameMenuData constructor 239 */ 240 GameMenuData::GameMenuData() 656 241 {} 657 242 658 243 /** 659 * SimpleGameMenuData decontructor660 */ 661 SimpleGameMenuData::~SimpleGameMenuData()244 * GameMenuData decontructor 245 */ 246 GameMenuData::~GameMenuData() 662 247 {} 663 248 … … 666 251 * initialize the GameWorldDataData 667 252 */ 668 ErrorMessage SimpleGameMenuData::init()253 ErrorMessage GameMenuData::init() 669 254 { 670 255 /* call underlying function */ … … 677 262 * @param root reference to the xml root element 678 263 */ 679 ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)264 ErrorMessage GameMenuData::loadGUI(const TiXmlElement* root) 680 265 { 681 266 /* call underlying function */ … … 687 272 * unloads the GUI data 688 273 */ 689 ErrorMessage SimpleGameMenuData::unloadGUI()274 ErrorMessage GameMenuData::unloadGUI() 690 275 { 691 276 /* call underlying function */ … … 698 283 * @param root reference to the xml root parameter 699 284 */ 700 ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)285 ErrorMessage GameMenuData::loadWorldEntities(const TiXmlElement* root) 701 286 { 702 287 GameWorldData::loadWorldEntities(root); 703 /*704 const TiXmlElement* element = root->FirstChildElement("WorldEntities");705 706 if( element != NULL)707 {708 element = element->FirstChildElement();709 PRINTF(4)("Loading WorldEntities\n");710 while(element != NULL)711 {712 BaseObject* created = Factory::fabricate(element);713 if( created != NULL )714 printf("Created a %s: %s\n", created->getClassName(), created->getName());715 716 if( element->Value() == "SkyBox")717 this->sky = dynamic_cast<WorldEntity*>(created);718 if( element->Value() == "Terrain")719 this->terrain = dynamic_cast<Terrain*>(created);720 element = element->NextSiblingElement();721 }722 723 PRINTF(4)("Done loading WorldEntities\n");724 }725 726 // init the pnode tree727 PNode::getNullParent()->init();728 */729 288 } 730 289 … … 733 292 * unloads the world entities from the xml file 734 293 */ 735 ErrorMessage SimpleGameMenuData::unloadWorldEntities()294 ErrorMessage GameMenuData::unloadWorldEntities() 736 295 { 737 296 /* call underlying function */ … … 744 303 * @param root reference to the xml root element 745 304 */ 746 ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)305 ErrorMessage GameMenuData::loadScene(const TiXmlElement* root) 747 306 { 748 307 /* call underlying function */ … … 754 313 * unloads the scene data 755 314 */ 756 ErrorMessage SimpleGameMenuData::unloadScene()315 ErrorMessage GameMenuData::unloadScene() 757 316 { 758 317 /* call underlying function */ -
branches/gui/src/story_entities/game_menu.h
r8667 r8673 1 1 /*! 2 * @file simple_game_menu.h2 * @file game_menu.h 3 3 * a StoryEntity that contains a simple game menu 4 4 */ 5 5 6 #ifndef _ SIMPLE_GAME_MENU_H7 #define _ SIMPLE_GAME_MENU_H6 #ifndef _GAME_MENU_H 7 #define _GAME_MENU_H 8 8 9 9 10 10 #include "game_world.h" 11 #include "event_listener.h"12 11 #include "game_world_data.h" 13 12 #include <vector> 14 #include "vector.h"15 16 17 #include "elements/text_element.h"18 19 13 #include "glgui.h" 20 14 21 class SimpleGameMenuData;22 class TiXmlElement;23 class ImageEntity;24 25 15 namespace OrxSound { class SoundSource; } 26 27 class MenuLayer28 {29 public:30 MenuLayer() {}31 virtual ~MenuLayer() {}32 33 34 public:35 std::vector<TextElement*> menuList; //!< the list of the menu items36 std::vector<StoryEntity*> storyList; //!< the list of the StoryEntities for the menu37 std::vector<ImageEntity*> screenshootList; //!< list of the screen shoots FIXME: make a better structure for this stuff38 };39 40 16 41 17 //! a simple game menu based on a story entity … … 44 20 * loadable and is exchangeable very easely :D 45 21 */ 46 class SimpleGameMenu : virtual public GameWorld, virtual public EventListener22 class GameMenu : virtual public GameWorld, virtual public EventListener 47 23 { 48 24 49 25 public: 50 SimpleGameMenu(const TiXmlElement* root = NULL);51 virtual ~ SimpleGameMenu();26 GameMenu(const TiXmlElement* root = NULL); 27 virtual ~GameMenu(); 52 28 53 29 /// TODO TAKE THIS OUT … … 75 51 void quitMenu(); 76 52 77 void TEST(int val) { printf("TEST %d\n", val); }78 79 53 protected: 80 54 virtual void tick(); … … 90 64 91 65 private: 92 std::vector<MenuLayer> menuLayers; //!< the menu layer 93 MenuLayer* selectedLayer; //!< the selected menu layer 94 int layerIndex; 95 96 //std::vector<ImageEntity*> menuList; //!< the list of the menu items 97 ImageEntity* menuSelector; //!< ref to the selector image 98 TextElement* menuSelected; //!< ref to the selected menu entity 99 TextElement* menuStartGame; 100 TextElement* menuStartMultiplayerGame; 101 TextElement* menuQuitGame; 102 int menuSelectedIndex; 66 OrxGui::GLGuiBox* mainMenu; 67 OrxGui::GLGuiBox* audioBox; 68 OrxGui::GLGuiBox* videoBox; 69 OrxGui::GLGuiBox* controlBox; 70 OrxGui::GLGuiBox* levelsBox; 103 71 104 72 Vector cameraVector; … … 110 78 111 79 //! the simple game menu data 112 class SimpleGameMenuData : public GameWorldData80 class GameMenuData : public GameWorldData 113 81 { 114 82 115 83 public: 116 SimpleGameMenuData();117 virtual ~ SimpleGameMenuData();84 GameMenuData(); 85 virtual ~GameMenuData(); 118 86 119 87 virtual ErrorMessage init();
Note: See TracChangeset
for help on using the changeset viewer.