- Timestamp:
- Nov 22, 2009, 4:01:16 PM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2
- Property svn:mergeinfo changed
/code/branches/sound3 (added) merged: 5941,5943,5946,5954,5956-5957,5962,5982,6031,6046,6069-6072,6074,6088,6093,6097,6100,6102
- Property svn:mergeinfo changed
-
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
r5929 r6117 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/EventIncludes.h" 33 #include "core/GameMode.h" 34 #include "core/Resource.h" 33 35 #include "core/XMLPort.h" 36 #include "SoundManager.h" 37 #include "MoodManager.h" 34 38 35 39 namespace orxonox … … 41 45 { 42 46 RegisterObject(AmbientSound); 47 48 // Ambient sounds always fade in 49 this->setVolume(0); 43 50 } 44 51 … … 50 57 { 51 58 SUPER(AmbientSound, XMLPort, xmlelement, mode); 52 XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode); 53 XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode); 54 XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode); 59 BaseSound::XMLPortExtern(xmlelement, mode); 60 XMLPortParam(AmbientSound, "ambientsource", setAmbientSource, getAmbientSource, xmlelement, mode); 55 61 } 56 62 … … 60 66 XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode); 61 67 } 68 69 void AmbientSound::play() 70 { 71 if (GameMode::playsSound()) 72 { 73 COUT(3) << "Sound: " << this->getSource() << ": Playing" << std::endl; 74 SoundManager::getInstance().registerAmbientSound(this); 75 } 76 } 77 78 void AmbientSound::doPlay() 79 { 80 BaseSound::play(); 81 } 82 83 void AmbientSound::stop() 84 { 85 if (GameMode::playsSound()) 86 { 87 SoundManager::getInstance().unregisterAmbientSound(this); 88 } 89 } 90 91 void AmbientSound::doStop() 92 { 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(); 107 } 108 109 void AmbientSound::setAmbientSource(const std::string& source) 110 { 111 this->ambientSource_ = source; 112 if (GameMode::playsSound()) 113 { 114 std::string path = "ambient/" + MoodManager::getInstance().getMood() + "/" + source; 115 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path); 116 if (fileInfo != NULL) 117 this->setSource(path); 118 else 119 COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl; 120 } 121 } 122 123 void AmbientSound::changedActivity() 124 { 125 SUPER(AmbientSound, changedActivity); 126 if (this->isActive()) 127 this->play(); 128 else 129 this->stop(); 130 } 62 131 }
Note: See TracChangeset
for help on using the changeset viewer.