Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2009, 4:03:03 PM (16 years ago)
Author:
youngk
Message:

Implemented automatic ambient sound file path fetch according to current mood.
Valid moods are: default and dnb
BUG Loading of a second sound fails (independent of the file used). Probably an error in BaseSound::setSource().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound3/src/orxonox/sound/SoundManager.cc

    r5982 r6031  
    3434#include "util/Math.h"
    3535#include "util/ScopeGuard.h"
     36#include "util/StringUtils.h"
    3637#include "core/GameMode.h"
    3738#include "core/ScopedSingletonManager.h"
     39#include "core/Resource.h"
    3840#include "BaseSound.h"
     41#include "MoodManager.h"
    3942
    4043namespace orxonox
     
    127130    void SoundManager::unregisterAmbientSound(BaseSound* currentAmbient)
    128131    {
     132        if(currentAmbient == NULL || ambientSounds_.empty())
     133        {
     134            return;
     135        }
    129136        if(this->ambientSounds_.front() == currentAmbient)
    130137        {
    131138            this->ambientSounds_.pop_front();
    132             this->ambientSounds_.front()->replay();
     139            if(!(this->ambientSounds_.empty()))
     140            {
     141                this->ambientSounds_.front()->replay();
     142            }
    133143        }
    134144        else
     
    144154        }
    145155    }
     156
     157    // Get the current mood and return the full path string to the requested sound.
     158    const std::string& SoundManager::getAmbientPath(const std::string& source)
     159    {
     160        lastReqPath = "ambient/" + MoodManager::getInstance().getMood() + "/" + source;
     161        shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(lastReqPath);
     162        if(fileInfo == NULL)
     163        {
     164            return BLANKSTRING;
     165        }
     166        return lastReqPath;
     167    }
    146168}
Note: See TracChangeset for help on using the changeset viewer.