Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/story_entities/simple_game_menu.cc @ 9140

Last change on this file since 9140 was 9140, checked in by bensch, 18 years ago

merged back

File size: 20.4 KB
RevLine 
[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
[7868]21#include "event_handler.h"
22
[6502]23#include "state.h"
24#include "class_list.h"
25
[7193]26#include "util/loading/load_param.h"
[6502]27#include "fast_factory.h"
[7193]28#include "util/loading/factory.h"
[8324]29#include "loading/resource_manager.h"
[6502]30
31#include "world_entity.h"
[7016]32#include "elements/image_entity.h"
[9140]33#include "terrain_entity.h"
[6521]34#include "camera.h"
[6502]35
[6524]36#include "graphics_engine.h"
[6841]37#include "object_manager.h"
[7318]38#include "sound_engine.h"
39#include "sound_source.h"
[6504]40
[6502]41#include "cd_engine.h"
42
[7919]43#include "glgui.h"
[8518]44#include "gui/gl/specials/glgui_notifier.h"
[6502]45
46//! This creates a Factory to fabricate a SimpleGameMenu
47CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU);
48
49
50
51SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)
[7919]52    : GameWorld()
[6502]53{
54  this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu");
55  this->setName("SimpleGameMenu uninitialized");
56
57  this->dataTank = new SimpleGameMenuData();
58
[6521]59  this->cameraVector = Vector(50.0, 0.0, 0.0);
[6991]60  this->menuLayers.push_back(MenuLayer());
61  this->menuLayers.push_back(MenuLayer());
[6862]62
[6837]63  this->layerIndex = 0;
[6862]64  this->menuSelectedIndex = 0;
[7318]65  this->selectorSource = NULL;
[6521]66
[7919]67
68  /// GUI
69  ///(this is as modular as it is possible).
70  OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
[8035]71  //pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
72  pb->connect(SIGNAL(pb, released), this, SLOT(SimpleGameMenu, enterGui));
[7919]73  pb->show();
74  pb->setAbsCoor2D(50, 50);
75
76  OrxGui::GLGuiHandler::getInstance()->activateCursor();
77  OrxGui::GLGuiHandler::getInstance()->activate();
[8376]78  OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 1, 49);
[7919]79  /////
80
[7221]81  if (root != NULL)
82    this->loadParams(root);
[6878]83
[7032]84  State::setMenuID(this->getNextStoryID());
[6502]85}
86
[7919]87/// HACK only for testing.
88void SimpleGameMenu::enterGui()
89{
[6502]90
[8518]91  OrxGui::GLGuiNotifier* notifier = new OrxGui::GLGuiNotifier();
92  notifier->show();
93  notifier->setAbsCoor2D(300, 300);
94
95
96
[8035]97  OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox();
98  {
99    ///
100    OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
[7919]101
[8035]102    box->pack(dnpb);
[7919]103
[8035]104    OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
105    rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu));
[7919]106
[8035]107    box->pack(rdnpb);
108
[8518]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
[8035]114    OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
115    input->setText("input some text here");
[8518]116    input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage));
117
[8035]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);
[8619]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);
[8717]133    table->setEntry(1, 2, "Test");
134    table->setEntry(2, 1, "MultiLine SuperTest to see how it works");
[8619]135
136
137    box->pack(table);
[8035]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
[7919]168  /////
169}
170
171
[8035]172#include "class_list.h"
173void 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
[7919]195#include "threading.h"
196void 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__
[8523]205//#include <shellapi.h>
[7919]206#endif
207
208int 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__
[8035]214  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
215                        kCFStringEncodingASCII, NULL);
216  LSOpenCFURLRef (url_handle, NULL);
217  CFRelease (url_handle);
[7919]218#elif defined __WIN32__
[8523]219  /*  ShellExecute(GetActiveWindow(),
[8035]220               "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
[8523]221               }*/
[7919]222#endif
223  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
224}
225
[6501]226/**
[7919]227*  @brief remove the SimpleGameMenu from memory
228*
229*  delete everything explicitly, that isn't contained in the parenting tree!
230*  things contained in the tree are deleted automaticaly
231*/
[6502]232SimpleGameMenu::~SimpleGameMenu ()
233{
234  PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n");
[7287]235
236  if( this->dataTank)
237    delete this->dataTank;
[7919]238  delete OrxGui::GLGuiHandler::getInstance( );
[6502]239}
[6501]240
[6502]241
242/**
[7919]243* @brief loads the parameters of a SimpleGameMenu from an XML-element
244* @param root the XML-element to load from
245*/
[6502]246void SimpleGameMenu::loadParams(const TiXmlElement* root)
247{
248  /* skip the GameWorld, since it does not define any useful loadParams for this class */
[6696]249  //static_cast<GameWorld*>(this)->loadParams(root);
250  GameWorld::loadParams(root);
[6501]251
[6502]252  PRINTF(4)("Loaded SimpleGameMenu specific stuff\n");
253}
[6501]254
[6502]255
[6501]256/**
[7919]257* @brief this is executed just before load
258*
259* since the load function sometimes needs data, that has been initialized
260* before the load and after the proceeding storyentity has finished
261*/
[6504]262ErrorMessage SimpleGameMenu::init()
263{
264  /* call underlying init funciton */
265  GameWorld::init();
266
[7868]267  this->subscribeEvent(ES_MENU, SDLK_UP);
268  this->subscribeEvent(ES_MENU, SDLK_DOWN);
269  this->subscribeEvent(ES_MENU, SDLK_RETURN);
270  this->subscribeEvent(ES_MENU, SDLK_SPACE);
271  this->subscribeEvent(ES_MENU, SDLK_ESCAPE);
[6521]272
273  this->dataTank->localCamera->setRelCoor(this->cameraVector);
[6524]274
275  GraphicsEngine::getInstance()->displayFPS(false);
[6862]276
277  this->layerIndex = 0;
278  this->menuSelectedIndex = 0;
[6504]279}
280
281
[6524]282/**
[7919]283* @brief load the data
284*/
[6521]285ErrorMessage SimpleGameMenu::loadData()
[6504]286{
[6521]287  GameWorld::loadData();
[6504]288
[6845]289  if (this->dataXML != NULL)
290  {
[7318]291    LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound);
292
[6845]293    TiXmlElement* element = this->dataXML->FirstChildElement("Elements");
294
[7318]295
[6845]296    if( element == NULL)
297    {
298      PRINTF(1)("SimpleGameMenu is missing 'Elements'\n");
299    }
300    else
301    {
302      element = element->FirstChildElement();
[7919]303      // load Players/Objects/Whatever
[6845]304      PRINTF(4)("Loading Elements\n");
305      while( element != NULL)
306      {
307        BaseObject* created = Factory::fabricate(element);
308        if( created != NULL )
[6852]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        }
[6851]314        element = element->NextSiblingElement();
[6845]315      }
316      PRINTF(4)("Done loading Elements\n");
317    }
318  }
319
[6520]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);
[6878]329      this->menuSelector->setBindNode((const PNode*)NULL);
[6520]330    }
[7019]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()))
[6520]337    {
[7019]338      this->menuStartGame = dynamic_cast<TextElement*>(*entity);
[6878]339      this->menuStartGame->setBindNode((const PNode*)NULL);
[6883]340      this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f,
[7316]341                                        State::getResY() / 2.0f - 60.0f);
[7019]342      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6835]343
[6520]344    }
345    else if( !strcmp( "Multiplayer_Menu", (*entity)->getName()))
346    {
[7019]347      this->menuStartMultiplayerGame = dynamic_cast<TextElement*>(*entity);
[6878]348      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
[6883]349      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
[7919]350          State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
[7019]351      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6520]352    }
353    else if( !strcmp( "Quit_Menu", (*entity)->getName()))
354    {
[7019]355      this->menuQuitGame = dynamic_cast<TextElement*>(*entity);
[6878]356      this->menuQuitGame->setBindNode((const PNode*)NULL);
[6883]357      this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f,
[7316]358                                       State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f));
[7019]359      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6520]360    }
361  }
[6980]362  this->menuSelected->getNullElement()->update2D(0.1f);
[6520]363  this->menuSelectedIndex = 0;
[6991]364  this->menuSelected = this->menuLayers[0].menuList[this->menuSelectedIndex];
[7063]365  this->sliderTo(this->menuSelected, 0.0f);
[6839]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    {
[6991]376      this->menuLayers[1].storyList.push_back(se);
[6874]377
378      // generating menu item
[7019]379      TextElement* te = new TextElement();
380      te->setVisibility(false);
381      te->setText(se->getName());
[7316]382      te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f));
[7019]383      this->menuLayers[1].menuList.push_back(te);
384
385      // generating screenshoot item
[6841]386      ImageEntity* ie = new ImageEntity();
[6848]387      ie->setVisibility(false);
[6878]388      ie->setBindNode((const PNode*)NULL);
389      ie->setTexture(se->getMenuScreenshoot());
[7316]390      ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f);
[6884]391      ie->setSize2D(140.0f, 105.0f);
[6991]392      this->menuLayers[1].screenshootList.push_back(ie);
[6839]393    }
394  }
[6521]395}
[6520]396
[7318]397/**
[7919]398* @brief set the Sound to play when switching menu entry.
399* @param selectorSound the sound to load.
400*/
[7318]401void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
402{
[7460]403  this->selectorSource = OrxSound::SoundEngine::getInstance()->createSource(selectorSound, NULL);
[7318]404}
[6521]405
[6862]406ErrorMessage SimpleGameMenu::unloadData()
407{
[7868]408  this->unsubscribeEvents(ES_MENU);
[6862]409
[6991]410  std::vector<MenuLayer>::iterator mit;
411  for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++)
[6862]412  {
[7019]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();
[6991]421    (*mit).screenshootList.clear();
[6862]422  }
[7029]423
[7318]424  // delete the SoundSource.
425  if (this->selectorSource != NULL)
426    delete this->selectorSource;
427  this->selectorSource = NULL;
[7029]428
429  GameWorld::unloadData();
[6862]430}
431
432
[6524]433/**
[7919]434* @brief start the menu
435*/
[6521]436bool SimpleGameMenu::start()
437{
438  EventHandler::getInstance()->pushState(ES_MENU);
439
[6504]440  /* now call the underlying*/
441  GameWorld::start();
442}
443
444
445
[6524]446/**
[7919]447* stop the menu
448*/
[6504]449bool SimpleGameMenu::stop()
450{
451  EventHandler::getInstance()->popState();
452
453  /* now call the underlying*/
454  GameWorld::stop();
455}
456
457
[6521]458/**
[7919]459*  override the standard tick for more functionality
460*/
[6521]461void SimpleGameMenu::tick()
462{
463  GameWorld::tick();
[6504]464
[7919]465  // Make the GLGui tick.
466  OrxGui::GLGuiHandler::getInstance()->tick(this->dtS);
467
[7131]468  this->animateScene(this->dtS);
[6521]469}
470
471
[6504]472/**
[7919]473* @brief no collision detection in the menu
474*/
[6502]475void SimpleGameMenu::collide()
[6521]476{
[7919]477  //   this->dataTank->localCamera->
[6521]478}
[6501]479
480
[6504]481/**
[7919]482* @brief animate the scene
483*/
[6521]484void SimpleGameMenu::animateScene(float dt)
485{
[7131]486  Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0));
[6521]487  this->cameraVector = q.apply(this->cameraVector);
488  this->dataTank->localCamera->setRelCoor(this->cameraVector);
489  this->dataTank->localCamera->getTarget()->setRelCoorSoft(0,0,0);
490}
491
[7919]492void SimpleGameMenu::quitMenu()
493{
494  this->setNextStoryID(WORLD_ID_GAMEEND);
495  this->stop();
496}
[6521]497
[7919]498
[6521]499/**
[7919]500* @brief event dispatcher funciton
501* @param event the incoming event
502*/
[6504]503void SimpleGameMenu::process(const Event &event)
504{
[6839]505  /* ----------------- LAYER 1 ---------------*/
[6837]506  if( this->layerIndex == 0)
[6504]507  {
[6837]508    if( event.type == SDLK_RETURN && event.bPressed == true)
[6520]509    {
[6837]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
[6991]518        if( this->menuLayers[1].menuList.size() == 0)
[6837]519        {
[6839]520          PRINTF(1)("Haven't got any StoryEntities to play!\n");
[6837]521          return;
522        }
523
524        this->switchMenuLayer(this->layerIndex, 1);
525      }
[6520]526    }
[6854]527    if( event.type == SDLK_ESCAPE && event.bPressed == true)
528    {
529      this->setNextStoryID(WORLD_ID_GAMEEND);
530      this->stop();
531    }
[6839]532  }  /* ----------------- LAYER 2 ---------------*/
[6837]533  else if( this->layerIndex == 1)
[6520]534  {
[6848]535    if( event.type == SDLK_RETURN && event.bPressed == true)
536    {
[6991]537      this->setNextStoryID( this->menuLayers[1].storyList[this->menuSelectedIndex]->getStoryID());
[6848]538      this->stop();
539    }
[6854]540    if( event.type == SDLK_ESCAPE && event.bPressed == true)
541    {
542      this->switchMenuLayer(this->layerIndex, 0);
543    }
[6520]544  }
[6853]545
546
547
548  // The menu selction cursor
549  if( event.type == SDLK_DOWN && event.bPressed == true)
550  {
[6991]551    if(this->menuSelectedIndex < (this->menuLayers[this->layerIndex].menuList.size() - 1))
[6853]552    {
[6991]553      this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex];
[7063]554      this->sliderTo(this->menuSelected, 5.0f);
[7318]555      if (this->selectorSource != NULL)
556        this->selectorSource->play();
[6883]557
558      if( this->layerIndex == 1)
559      {
[6991]560        this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
561        this->menuLayers[1].screenshootList[this->menuSelectedIndex-1]->setVisibility(false);
[6883]562      }
[6853]563    }
564  }
565  else if( event.type == SDLK_UP && event.bPressed == true)
566  {
567    if(this->menuSelectedIndex > 0)
568    {
[6991]569      this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex];
[7063]570      this->sliderTo(this->menuSelected, 5.0f);
[7318]571      if (this->selectorSource != NULL)
572        this->selectorSource->play();
[6883]573
574      if( this->layerIndex == 1)
575      {
[6991]576        this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
577        this->menuLayers[1].screenshootList[this->menuSelectedIndex+1]->setVisibility(false);
[6883]578      }
[6853]579    }
580  }
[6504]581}
[6502]582
583
[6837]584/**
[7919]585* @brief switches to from one meny layer to an other
586* @param layer1 from layer
587* @param layer2 to layer
588*/
[6837]589void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
590{
591  // wrong sizes
[6991]592  if(layer1 >= this->menuLayers.size() || layer2 >= this->menuLayers.size())
[6837]593    return;
[6502]594
595
[6837]596  PRINTF(0)("Removing layer %i\n", layer1);
[7019]597  std::vector<TextElement*>::iterator te;
[6837]598  // fade old menu
[7019]599  for( te = this->menuLayers[layer1].menuList.begin(); te != this->menuLayers[layer1].menuList.end(); te++)
[6837]600  {
[7019]601    (*te)->setVisibility(false);
[6837]602  }
[7019]603
604  std::vector<ImageEntity*>::iterator it;
605
[6878]606  //also fade the screenshots if in level choosement mode
[6991]607  for( it = this->menuLayers[layer1].screenshootList.begin(); it != this->menuLayers[layer1].screenshootList.end(); it++)
[6878]608  {
609    (*it)->setVisibility(false);
610  }
[6502]611
612
[6837]613  PRINTF(0)("Showing layer %i\n", layer1);
614  // beam here the new menu
[7019]615  for( te = this->menuLayers[layer2].menuList.begin(); te != this->menuLayers[layer2].menuList.end(); te++ )
[6848]616  {
[7019]617    (*te)->setVisibility(true);
[6848]618  }
[6837]619
[6878]620
[6837]621  this->layerIndex = layer2;
[6991]622  this->menuSelected = this->menuLayers[layer2].menuList[0];
[7765]623  this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D() + Vector2D(0, this->menuSelected->getSizeY2D() *.5));
624  this->menuSelector->setSize2D(this->menuSelected->getSizeX2D()*.7, this->menuSelected->getSizeY2D());
[6855]625  this->menuSelectedIndex = 0;
[6883]626
627  if( layer2 == 1)
[6991]628    this->menuLayers[layer2].screenshootList[0]->setVisibility(true);
[6837]629}
630
[7063]631void SimpleGameMenu::sliderTo(const Element2D* element, float bias)
632{
633  if (bias > 0.0)
634  {
[7316]635    this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias);
[7764]636    this->menuSelector->setSizeSoft2D(element->getSizeX2D()*.7, element->getSizeY2D(), bias);
[7063]637  }
638  else
639  {
[7316]640    this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5));
[7764]641    this->menuSelector->setSize2D(element->getSizeX2D()*.7, element->getSizeY2D());
[7063]642  }
643}
[6837]644
645
646
[6502]647/**********************************************************************************************
[7919]648SimpleGameMenuData
649**********************************************************************************************/
[6502]650
651
[6501]652/**
[7919]653* SimpleGameMenuData constructor
654*/
[6502]655SimpleGameMenuData::SimpleGameMenuData()
[6501]656{}
657
658/**
[7919]659* SimpleGameMenuData decontructor
660*/
[6502]661SimpleGameMenuData::~SimpleGameMenuData()
[6501]662{}
663
664
665/**
[7919]666*  initialize the GameWorldDataData
667*/
[6502]668ErrorMessage SimpleGameMenuData::init()
669{
670  /* call underlying function */
671  GameWorldData::init();
672}
[6501]673
674
675/**
[7919]676*  loads the GUI data
677* @param root reference to the xml root element
678*/
[7370]679ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
[6502]680{
681  /* call underlying function */
682  GameWorldData::loadGUI(root);
683}
[6501]684
685
686/**
[7919]687*  unloads the GUI data
688*/
[6502]689ErrorMessage SimpleGameMenuData::unloadGUI()
690{
691  /* call underlying function */
692  GameWorldData::unloadGUI();
693}
694
695
696/**
[7919]697*  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
698* @param root reference to the xml root parameter
699*/
[7370]700ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
[6502]701{
[7370]702  GameWorldData::loadWorldEntities(root);
703  /*
704  const TiXmlElement* element = root->FirstChildElement("WorldEntities");
[6502]705
706  if( element != NULL)
707  {
[7919]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());
[6502]715
[7919]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  }
[7370]722
[7919]723  PRINTF(4)("Done loading WorldEntities\n");
[6502]724  }
725
[7370]726  // init the pnode tree
[6502]727  PNode::getNullParent()->init();
[7370]728  */
[6502]729}
730
731
732/**
[7919]733*  unloads the world entities from the xml file
734*/
[6502]735ErrorMessage SimpleGameMenuData::unloadWorldEntities()
736{
737  /* call underlying function */
738  GameWorldData::unloadWorldEntities();
739}
740
741
742/**
[7919]743*  loads the scene data
744* @param root reference to the xml root element
745*/
[7370]746ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
[6502]747{
748  /* call underlying function */
749  GameWorldData::loadScene(root);
750}
751
752
753/**
[7919]754*  unloads the scene data
755*/
[6502]756ErrorMessage SimpleGameMenuData::unloadScene()
757{
758  /* call underlying function */
759  GameWorldData::unloadScene();
760}
761
762
763
Note: See TracBrowser for help on using the repository browser.