Changeset 6069 for code/branches/sound3/src/orxonox/sound/AmbientSound.cc
- Timestamp:
- Nov 15, 2009, 3:43:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound3/src/orxonox/sound/AmbientSound.cc
r6046 r6069 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/EventIncludes.h" 33 #include "core/GameMode.h" 33 34 #include "core/XMLPort.h" 34 35 #include "SoundManager.h" … … 42 43 { 43 44 RegisterObject(AmbientSound); 45 46 // Ambient sounds always fade in 47 this->setVolume(0); 44 48 } 45 49 … … 51 55 { 52 56 SUPER(AmbientSound, XMLPort, xmlelement, mode); 53 XMLPortParamExtern(AmbientSound, BaseSound, this, " source", setSource, getSource, xmlelement, mode);57 XMLPortParamExtern(AmbientSound, BaseSound, this, "volume", setVolume, getVolume, xmlelement, mode); 54 58 XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode); 55 59 XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode); 60 XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode); 56 61 } 57 62 … … 64 69 void AmbientSound::play() 65 70 { 66 COUT(3) << this->getSource() << ": Playing" << std::endl; 67 if(GameMode::playsSound()) 71 if (GameMode::playsSound()) 68 72 { 73 COUT(3) << "Sound: " << this->getSource() << ": Playing" << std::endl; 69 74 SoundManager::getInstance().registerAmbientSound(this); 70 this->BaseSound::play();71 75 } 72 76 } 73 77 74 void AmbientSound:: replay()78 void AmbientSound::doPlay() 75 79 { 76 this->BaseSound::play();80 BaseSound::play(); 77 81 } 78 82 79 83 void AmbientSound::stop() 80 84 { 81 if (GameMode::playsSound())85 if (GameMode::playsSound()) 82 86 { 83 87 SoundManager::getInstance().unregisterAmbientSound(this); … … 87 91 void AmbientSound::doStop() 88 92 { 89 this->BaseSound::stop(); 93 BaseSound::stop(); 94 } 95 96 void AmbientSound::pause() 97 { 98 if (GameMode::playsSound()) 99 { 100 SoundManager::getInstance().pauseAmbientSound(this); 101 } 102 } 103 104 void AmbientSound::doPause() 105 { 106 BaseSound::pause(); 90 107 } 91 108 92 109 void AmbientSound::setSource(const std::string& source) 93 110 { 94 if (source.find('/') == std::string.npos &&GameMode::playsSound())111 if (GameMode::playsSound()) 95 112 { 96 113 std::string filePath = SoundManager::getInstance().getAmbientPath(source); 97 if (!(filePath.empty()))114 if (!filePath.empty()) 98 115 { 99 this->BaseSound::setSource(filePath);116 BaseSound::setSource(filePath); 100 117 return; 101 118 } 119 COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl; 102 120 } 103 COUT(3) << source << ": Not a valid name! Ambient sound will not change." << std::endl;104 121 } 105 122 106 123 void AmbientSound::changedActivity() 107 124 { 108 COUT(3) << this->getSource() << ": ChangedActivity: " << this->isActive() << std::endl;125 COUT(3) << "Sound: " << this->getSource() << ": ChangedActivity: " << this->isActive() << std::endl; 109 126 this->BaseObject::changedActivity(); 110 if (this->isActive())127 if (this->isActive()) 111 128 { 112 129 this->play();
Note: See TracChangeset
for help on using the changeset viewer.