Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8965 was 8697, checked in by patrick, 18 years ago

merged the terrain with the new trunk (MARK TERRAIN)

File size: 20.3 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"
[8697]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);
133
134
135    box->pack(table);
[8035]136  }
137  box->setAbsCoor2D(50, 200);
138
139  box->showAll();
140
141
142  OrxGui::GLGuiBox* imageSelector = new OrxGui::GLGuiBox();
143  {
144    image = new OrxGui::GLGuiImage();
145    image->setWidgetSize(300, 300);
146    image->setAbsCoor2D(300, 300);
147    imageSelector->pack(image);
148
149    imageName = new OrxGui::GLGuiInputLine();
150    imageSelector->pack(imageName);
151
152    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
153    slider->setWidgetSize(200, 30);
154    slider->setRange(0, 100);
155    slider->setStep(1);
156    slider->setValue(slider->min());
157    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, setImage));
158
159    imageSelector->pack(slider);
160    slider->setValue(0);
161  }
162  imageSelector->showAll();
163  imageSelector->setAbsCoor2D(400, 30);
164
165
[7919]166  /////
167}
168
169
[8035]170#include "class_list.h"
171void SimpleGameMenu::setImage(int i)
172{
173  const std::list<BaseObject*>* textures = ClassList::getList(CL_TEXTURE);
174
175  if(textures)
176  {
177    std::list<BaseObject*>::const_iterator test = textures->begin();
178    std::list<BaseObject*>::const_iterator lastOK = textures->begin();
179    while (true)
180    {
181      if (--i == 0 || test == textures->end())
182        break;
183      if (dynamic_cast<Texture*>(*test)->getTexture() != 0)
184        lastOK = test;
185      test++;
186    }
187    this->image->loadImageFromTexture(*dynamic_cast<Texture*>(*lastOK));
188    this->imageName->setText((*lastOK)->getName());
189  }
190}
191
192
[7919]193#include "threading.h"
194void SimpleGameMenu::execURL() const
195{
196  std::string URL = "http://www.orxonox.net";
197  SDL_CreateThread(startURL, (void*)&URL);
198}
199
200#ifdef __OSX__
201#include <ApplicationServices/ApplicationServices.h>
202#elif defined __WIN32__
[8523]203//#include <shellapi.h>
[7919]204#endif
205
206int SimpleGameMenu::startURL(void* url)
207{
208  std::string URL = *(std::string*)url;
209#ifdef __linux__
210  system ((std::string("firefox ") + URL).c_str());
211#elif defined __OSX__
[8035]212  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
213                        kCFStringEncodingASCII, NULL);
214  LSOpenCFURLRef (url_handle, NULL);
215  CFRelease (url_handle);
[7919]216#elif defined __WIN32__
[8523]217  /*  ShellExecute(GetActiveWindow(),
[8035]218               "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
[8523]219               }*/
[7919]220#endif
221  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
222}
223
[6501]224/**
[7919]225*  @brief remove the SimpleGameMenu from memory
226*
227*  delete everything explicitly, that isn't contained in the parenting tree!
228*  things contained in the tree are deleted automaticaly
229*/
[6502]230SimpleGameMenu::~SimpleGameMenu ()
231{
232  PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n");
[7287]233
234  if( this->dataTank)
235    delete this->dataTank;
[7919]236  delete OrxGui::GLGuiHandler::getInstance( );
[6502]237}
[6501]238
[6502]239
240/**
[7919]241* @brief loads the parameters of a SimpleGameMenu from an XML-element
242* @param root the XML-element to load from
243*/
[6502]244void SimpleGameMenu::loadParams(const TiXmlElement* root)
245{
246  /* skip the GameWorld, since it does not define any useful loadParams for this class */
[6696]247  //static_cast<GameWorld*>(this)->loadParams(root);
248  GameWorld::loadParams(root);
[6501]249
[6502]250  PRINTF(4)("Loaded SimpleGameMenu specific stuff\n");
251}
[6501]252
[6502]253
[6501]254/**
[7919]255* @brief this is executed just before load
256*
257* since the load function sometimes needs data, that has been initialized
258* before the load and after the proceeding storyentity has finished
259*/
[6504]260ErrorMessage SimpleGameMenu::init()
261{
262  /* call underlying init funciton */
263  GameWorld::init();
264
[7868]265  this->subscribeEvent(ES_MENU, SDLK_UP);
266  this->subscribeEvent(ES_MENU, SDLK_DOWN);
267  this->subscribeEvent(ES_MENU, SDLK_RETURN);
268  this->subscribeEvent(ES_MENU, SDLK_SPACE);
269  this->subscribeEvent(ES_MENU, SDLK_ESCAPE);
[6521]270
271  this->dataTank->localCamera->setRelCoor(this->cameraVector);
[6524]272
273  GraphicsEngine::getInstance()->displayFPS(false);
[6862]274
275  this->layerIndex = 0;
276  this->menuSelectedIndex = 0;
[6504]277}
278
279
[6524]280/**
[7919]281* @brief load the data
282*/
[6521]283ErrorMessage SimpleGameMenu::loadData()
[6504]284{
[6521]285  GameWorld::loadData();
[6504]286
[6845]287  if (this->dataXML != NULL)
288  {
[7318]289    LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound);
290
[6845]291    TiXmlElement* element = this->dataXML->FirstChildElement("Elements");
292
[7318]293
[6845]294    if( element == NULL)
295    {
296      PRINTF(1)("SimpleGameMenu is missing 'Elements'\n");
297    }
298    else
299    {
300      element = element->FirstChildElement();
[7919]301      // load Players/Objects/Whatever
[6845]302      PRINTF(4)("Loading Elements\n");
303      while( element != NULL)
304      {
305        BaseObject* created = Factory::fabricate(element);
306        if( created != NULL )
[6852]307        {
308          PRINTF(4)("Created a %s::%s\n", created->getClassName(), created->getName());
309          if (!created->isA(CL_ELEMENT_2D))
310            PRINTF(2)("Error the Created Entity is not an Element2D but an %s::%s\n", created->getClassName(), created->getName());
311        }
[6851]312        element = element->NextSiblingElement();
[6845]313      }
314      PRINTF(4)("Done loading Elements\n");
315    }
316  }
317
[6520]318  /* get the menu list */
319  const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY);
320  std::list<BaseObject*>::const_iterator entity;
321  for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)
322  {
323
324    if( !strcmp("Selector_Menu", (*entity)->getName()))
325    {
326      this->menuSelector = dynamic_cast<ImageEntity*>(*entity);
[6878]327      this->menuSelector->setBindNode((const PNode*)NULL);
[6520]328    }
[7019]329  }
330
331  imageEntityList = ClassList::getList(CL_TEXT_ELEMENT);
332  for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)
333  {
334    if( !strcmp( "StartGame_Menu", (*entity)->getName()))
[6520]335    {
[7019]336      this->menuStartGame = dynamic_cast<TextElement*>(*entity);
[6878]337      this->menuStartGame->setBindNode((const PNode*)NULL);
[6883]338      this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f,
[7316]339                                        State::getResY() / 2.0f - 60.0f);
[7019]340      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6835]341
[6520]342    }
343    else if( !strcmp( "Multiplayer_Menu", (*entity)->getName()))
344    {
[7019]345      this->menuStartMultiplayerGame = dynamic_cast<TextElement*>(*entity);
[6878]346      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
[6883]347      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
[7919]348          State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
[7019]349      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6520]350    }
351    else if( !strcmp( "Quit_Menu", (*entity)->getName()))
352    {
[7019]353      this->menuQuitGame = dynamic_cast<TextElement*>(*entity);
[6878]354      this->menuQuitGame->setBindNode((const PNode*)NULL);
[6883]355      this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f,
[7316]356                                       State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f));
[7019]357      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
[6520]358    }
359  }
[6980]360  this->menuSelected->getNullElement()->update2D(0.1f);
[6520]361  this->menuSelectedIndex = 0;
[6991]362  this->menuSelected = this->menuLayers[0].menuList[this->menuSelectedIndex];
[7063]363  this->sliderTo(this->menuSelected, 0.0f);
[6839]364
365
366  // loading the storyentities submenu (singleplayer)
367  const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY);
368  std::list<BaseObject*>::const_iterator it;
369  for( it = storyEntities->begin(); it != storyEntities->end(); it++)
370  {
371    StoryEntity* se = dynamic_cast<StoryEntity*>(*it);
372    if( se->isContainedInMenu())
373    {
[6991]374      this->menuLayers[1].storyList.push_back(se);
[6874]375
376      // generating menu item
[7019]377      TextElement* te = new TextElement();
378      te->setVisibility(false);
379      te->setText(se->getName());
[7316]380      te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f));
[7019]381      this->menuLayers[1].menuList.push_back(te);
382
383      // generating screenshoot item
[6841]384      ImageEntity* ie = new ImageEntity();
[6848]385      ie->setVisibility(false);
[6878]386      ie->setBindNode((const PNode*)NULL);
387      ie->setTexture(se->getMenuScreenshoot());
[7316]388      ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f);
[6884]389      ie->setSize2D(140.0f, 105.0f);
[6991]390      this->menuLayers[1].screenshootList.push_back(ie);
[6839]391    }
392  }
[6521]393}
[6520]394
[7318]395/**
[7919]396* @brief set the Sound to play when switching menu entry.
397* @param selectorSound the sound to load.
398*/
[7318]399void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
400{
[7460]401  this->selectorSource = OrxSound::SoundEngine::getInstance()->createSource(selectorSound, NULL);
[7318]402}
[6521]403
[6862]404ErrorMessage SimpleGameMenu::unloadData()
405{
[7868]406  this->unsubscribeEvents(ES_MENU);
[6862]407
[6991]408  std::vector<MenuLayer>::iterator mit;
409  for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++)
[6862]410  {
[7019]411    while(!(*mit).menuList.empty())
412    {
413      delete (*mit).menuList.back();
414      (*mit).menuList.pop_back();
415    }
416
417    (*mit).menuList.clear();
418    (*mit).storyList.clear();
[6991]419    (*mit).screenshootList.clear();
[6862]420  }
[7029]421
[7318]422  // delete the SoundSource.
423  if (this->selectorSource != NULL)
424    delete this->selectorSource;
425  this->selectorSource = NULL;
[7029]426
427  GameWorld::unloadData();
[6862]428}
429
430
[6524]431/**
[7919]432* @brief start the menu
433*/
[6521]434bool SimpleGameMenu::start()
435{
436  EventHandler::getInstance()->pushState(ES_MENU);
437
[6504]438  /* now call the underlying*/
439  GameWorld::start();
440}
441
442
443
[6524]444/**
[7919]445* stop the menu
446*/
[6504]447bool SimpleGameMenu::stop()
448{
449  EventHandler::getInstance()->popState();
450
451  /* now call the underlying*/
452  GameWorld::stop();
453}
454
455
[6521]456/**
[7919]457*  override the standard tick for more functionality
458*/
[6521]459void SimpleGameMenu::tick()
460{
461  GameWorld::tick();
[6504]462
[7919]463  // Make the GLGui tick.
464  OrxGui::GLGuiHandler::getInstance()->tick(this->dtS);
465
[7131]466  this->animateScene(this->dtS);
[6521]467}
468
469
[6504]470/**
[7919]471* @brief no collision detection in the menu
472*/
[6502]473void SimpleGameMenu::collide()
[6521]474{
[7919]475  //   this->dataTank->localCamera->
[6521]476}
[6501]477
478
[6504]479/**
[7919]480* @brief animate the scene
481*/
[6521]482void SimpleGameMenu::animateScene(float dt)
483{
[7131]484  Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0));
[6521]485  this->cameraVector = q.apply(this->cameraVector);
486  this->dataTank->localCamera->setRelCoor(this->cameraVector);
487  this->dataTank->localCamera->getTarget()->setRelCoorSoft(0,0,0);
488}
489
[7919]490void SimpleGameMenu::quitMenu()
491{
492  this->setNextStoryID(WORLD_ID_GAMEEND);
493  this->stop();
494}
[6521]495
[7919]496
[6521]497/**
[7919]498* @brief event dispatcher funciton
499* @param event the incoming event
500*/
[6504]501void SimpleGameMenu::process(const Event &event)
502{
[6839]503  /* ----------------- LAYER 1 ---------------*/
[6837]504  if( this->layerIndex == 0)
[6504]505  {
[6837]506    if( event.type == SDLK_RETURN && event.bPressed == true)
[6520]507    {
[6837]508      if( this->menuSelected == this->menuQuitGame)
509      {
510        this->setNextStoryID(WORLD_ID_GAMEEND);
511        this->stop();
512      }
513      if( this->menuSelected == this->menuStartGame)
514      {
515        // switch to first submenu
[6991]516        if( this->menuLayers[1].menuList.size() == 0)
[6837]517        {
[6839]518          PRINTF(1)("Haven't got any StoryEntities to play!\n");
[6837]519          return;
520        }
521
522        this->switchMenuLayer(this->layerIndex, 1);
523      }
[6520]524    }
[6854]525    if( event.type == SDLK_ESCAPE && event.bPressed == true)
526    {
527      this->setNextStoryID(WORLD_ID_GAMEEND);
528      this->stop();
529    }
[6839]530  }  /* ----------------- LAYER 2 ---------------*/
[6837]531  else if( this->layerIndex == 1)
[6520]532  {
[6848]533    if( event.type == SDLK_RETURN && event.bPressed == true)
534    {
[6991]535      this->setNextStoryID( this->menuLayers[1].storyList[this->menuSelectedIndex]->getStoryID());
[6848]536      this->stop();
537    }
[6854]538    if( event.type == SDLK_ESCAPE && event.bPressed == true)
539    {
540      this->switchMenuLayer(this->layerIndex, 0);
541    }
[6520]542  }
[6853]543
544
545
546  // The menu selction cursor
547  if( event.type == SDLK_DOWN && event.bPressed == true)
548  {
[6991]549    if(this->menuSelectedIndex < (this->menuLayers[this->layerIndex].menuList.size() - 1))
[6853]550    {
[6991]551      this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex];
[7063]552      this->sliderTo(this->menuSelected, 5.0f);
[7318]553      if (this->selectorSource != NULL)
554        this->selectorSource->play();
[6883]555
556      if( this->layerIndex == 1)
557      {
[6991]558        this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
559        this->menuLayers[1].screenshootList[this->menuSelectedIndex-1]->setVisibility(false);
[6883]560      }
[6853]561    }
562  }
563  else if( event.type == SDLK_UP && event.bPressed == true)
564  {
565    if(this->menuSelectedIndex > 0)
566    {
[6991]567      this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex];
[7063]568      this->sliderTo(this->menuSelected, 5.0f);
[7318]569      if (this->selectorSource != NULL)
570        this->selectorSource->play();
[6883]571
572      if( this->layerIndex == 1)
573      {
[6991]574        this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
575        this->menuLayers[1].screenshootList[this->menuSelectedIndex+1]->setVisibility(false);
[6883]576      }
[6853]577    }
578  }
[6504]579}
[6502]580
581
[6837]582/**
[7919]583* @brief switches to from one meny layer to an other
584* @param layer1 from layer
585* @param layer2 to layer
586*/
[6837]587void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
588{
589  // wrong sizes
[6991]590  if(layer1 >= this->menuLayers.size() || layer2 >= this->menuLayers.size())
[6837]591    return;
[6502]592
593
[6837]594  PRINTF(0)("Removing layer %i\n", layer1);
[7019]595  std::vector<TextElement*>::iterator te;
[6837]596  // fade old menu
[7019]597  for( te = this->menuLayers[layer1].menuList.begin(); te != this->menuLayers[layer1].menuList.end(); te++)
[6837]598  {
[7019]599    (*te)->setVisibility(false);
[6837]600  }
[7019]601
602  std::vector<ImageEntity*>::iterator it;
603
[6878]604  //also fade the screenshots if in level choosement mode
[6991]605  for( it = this->menuLayers[layer1].screenshootList.begin(); it != this->menuLayers[layer1].screenshootList.end(); it++)
[6878]606  {
607    (*it)->setVisibility(false);
608  }
[6502]609
610
[6837]611  PRINTF(0)("Showing layer %i\n", layer1);
612  // beam here the new menu
[7019]613  for( te = this->menuLayers[layer2].menuList.begin(); te != this->menuLayers[layer2].menuList.end(); te++ )
[6848]614  {
[7019]615    (*te)->setVisibility(true);
[6848]616  }
[6837]617
[6878]618
[6837]619  this->layerIndex = layer2;
[6991]620  this->menuSelected = this->menuLayers[layer2].menuList[0];
[7765]621  this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D() + Vector2D(0, this->menuSelected->getSizeY2D() *.5));
622  this->menuSelector->setSize2D(this->menuSelected->getSizeX2D()*.7, this->menuSelected->getSizeY2D());
[6855]623  this->menuSelectedIndex = 0;
[6883]624
625  if( layer2 == 1)
[6991]626    this->menuLayers[layer2].screenshootList[0]->setVisibility(true);
[6837]627}
628
[7063]629void SimpleGameMenu::sliderTo(const Element2D* element, float bias)
630{
631  if (bias > 0.0)
632  {
[7316]633    this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias);
[7764]634    this->menuSelector->setSizeSoft2D(element->getSizeX2D()*.7, element->getSizeY2D(), bias);
[7063]635  }
636  else
637  {
[7316]638    this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5));
[7764]639    this->menuSelector->setSize2D(element->getSizeX2D()*.7, element->getSizeY2D());
[7063]640  }
641}
[6837]642
643
644
[6502]645/**********************************************************************************************
[7919]646SimpleGameMenuData
647**********************************************************************************************/
[6502]648
649
[6501]650/**
[7919]651* SimpleGameMenuData constructor
652*/
[6502]653SimpleGameMenuData::SimpleGameMenuData()
[6501]654{}
655
656/**
[7919]657* SimpleGameMenuData decontructor
658*/
[6502]659SimpleGameMenuData::~SimpleGameMenuData()
[6501]660{}
661
662
663/**
[7919]664*  initialize the GameWorldDataData
665*/
[6502]666ErrorMessage SimpleGameMenuData::init()
667{
668  /* call underlying function */
669  GameWorldData::init();
670}
[6501]671
672
673/**
[7919]674*  loads the GUI data
675* @param root reference to the xml root element
676*/
[7370]677ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
[6502]678{
679  /* call underlying function */
680  GameWorldData::loadGUI(root);
681}
[6501]682
683
684/**
[7919]685*  unloads the GUI data
686*/
[6502]687ErrorMessage SimpleGameMenuData::unloadGUI()
688{
689  /* call underlying function */
690  GameWorldData::unloadGUI();
691}
692
693
694/**
[7919]695*  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
696* @param root reference to the xml root parameter
697*/
[7370]698ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
[6502]699{
[7370]700  GameWorldData::loadWorldEntities(root);
701  /*
702  const TiXmlElement* element = root->FirstChildElement("WorldEntities");
[6502]703
704  if( element != NULL)
705  {
[7919]706  element = element->FirstChildElement();
707  PRINTF(4)("Loading WorldEntities\n");
708  while(element != NULL)
709  {
710  BaseObject* created = Factory::fabricate(element);
711  if( created != NULL )
712  printf("Created a %s: %s\n", created->getClassName(), created->getName());
[6502]713
[7919]714  if( element->Value() == "SkyBox")
715  this->sky = dynamic_cast<WorldEntity*>(created);
716  if( element->Value() == "Terrain")
717  this->terrain = dynamic_cast<Terrain*>(created);
718  element = element->NextSiblingElement();
719  }
[7370]720
[7919]721  PRINTF(4)("Done loading WorldEntities\n");
[6502]722  }
723
[7370]724  // init the pnode tree
[6502]725  PNode::getNullParent()->init();
[7370]726  */
[6502]727}
728
729
730/**
[7919]731*  unloads the world entities from the xml file
732*/
[6502]733ErrorMessage SimpleGameMenuData::unloadWorldEntities()
734{
735  /* call underlying function */
736  GameWorldData::unloadWorldEntities();
737}
738
739
740/**
[7919]741*  loads the scene data
742* @param root reference to the xml root element
743*/
[7370]744ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
[6502]745{
746  /* call underlying function */
747  GameWorldData::loadScene(root);
748}
749
750
751/**
[7919]752*  unloads the scene data
753*/
[6502]754ErrorMessage SimpleGameMenuData::unloadScene()
755{
756  /* call underlying function */
757  GameWorldData::unloadScene();
758}
759
760
761
Note: See TracBrowser for help on using the repository browser.