Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 15, 2009, 10:36:45 PM (15 years ago)
Author:
rgrieder
Message:

Improved synchronisability of the sound classes (not yet Synchronisable though!).

File:
1 edited

Legend:

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

    r6069 r6071  
    3232#include "core/EventIncludes.h"
    3333#include "core/GameMode.h"
     34#include "core/Resource.h"
    3435#include "core/XMLPort.h"
    3536#include "SoundManager.h"
     37#include "MoodManager.h"
    3638
    3739namespace orxonox
     
    5658        SUPER(AmbientSound, XMLPort, xmlelement, mode);
    5759        XMLPortParamExtern(AmbientSound, BaseSound, this, "volume", setVolume, getVolume, xmlelement, mode);
    58         XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
    59         XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
    60         XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
     60        XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLooping, getLooping, xmlelement, mode);
     61        XMLPortParamExtern(AmbientSound, BaseSound, this, "play", play, isPlaying, xmlelement, mode);
     62        XMLPortParam(AmbientSound, "source", setAmbientSource, getAmbientSource, xmlelement, mode);
    6163    }
    6264
     
    107109    }
    108110
    109     void AmbientSound::setSource(const std::string& source)
     111    void AmbientSound::setAmbientSource(const std::string& source)
    110112    {
     113        this->ambientSource_ = source;
    111114        if (GameMode::playsSound())
    112115        {
    113             std::string filePath = SoundManager::getInstance().getAmbientPath(source);
    114             if (!filePath.empty())
    115             {
    116                 BaseSound::setSource(filePath);
    117                 return;
    118             }
    119             COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl;       
     116            std::string path = "ambient/" + MoodManager::getInstance().getMood() + "/" + source;
     117            shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
     118            if (fileInfo != NULL)
     119                this->setSource(path);
     120            else
     121                COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl;       
    120122        }
    121123    }
Note: See TracChangeset for help on using the changeset viewer.