Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7318 in orxonox.OLD for trunk/src/story_entities/simple_game_menu.cc


Ignore:
Timestamp:
Apr 17, 2006, 2:55:51 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: SoundSource in the Menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/simple_game_menu.cc

    r7317 r7318  
    3535#include "graphics_engine.h"
    3636#include "object_manager.h"
    37 
     37#include "sound_engine.h"
     38#include "sound_source.h"
    3839
    3940#include "cd_engine.h"
     
    6263  this->layerIndex = 0;
    6364  this->menuSelectedIndex = 0;
     65  this->selectorSource = NULL;
    6466
    6567  if (root != NULL)
     
    134136  if (this->dataXML != NULL)
    135137  {
     138    LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound);
     139
    136140    TiXmlElement* element = this->dataXML->FirstChildElement("Elements");
     141
    137142
    138143    if( element == NULL)
     
    237242}
    238243
     244/**
     245 * @brief set the Sound to play when switching menu entry.
     246 * @param selectorSound the sound to load.
     247 */
     248void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
     249{
     250  this->selectorSource = SoundEngine::getInstance()->createSource(selectorSound, NULL);
     251  printf("=============== %s\n", selectorSound.c_str());
     252}
    239253
    240254ErrorMessage SimpleGameMenu::unloadData()
     
    257271  }
    258272
     273  // delete the SoundSource.
     274  if (this->selectorSource != NULL)
     275    delete this->selectorSource;
     276  this->selectorSource = NULL;
    259277
    260278  GameWorld::unloadData();
     
    375393      this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex];
    376394      this->sliderTo(this->menuSelected, 5.0f);
     395      if (this->selectorSource != NULL)
     396        this->selectorSource->play();
    377397
    378398      if( this->layerIndex == 1)
     
    389409      this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex];
    390410      this->sliderTo(this->menuSelected, 5.0f);
     411      if (this->selectorSource != NULL)
     412        this->selectorSource->play();
    391413
    392414      if( this->layerIndex == 1)
Note: See TracChangeset for help on using the changeset viewer.